View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Nick Ing-Simmons (PAUSE Custodial Account) > Tk > Tk::Dialog



Annotate this POD


New  37
Open  67
Stalled  17
View/Report Bugs
Module Version: 4.004   Source   Latest Release: Tk-804.030


Tk::Dialog - Perl/Tk Dialog widget


    require Tk::Dialog;

    $DialogRef = $widget->Dialog(
        -title          => $title,
        -text           => $text,
        -bitmap         => $bitmap,
        -default_button => $default_button,
        -buttons        => [@button_labels],

    $selected = $DialogRef->Show(?-global?);


This is an OO implementation of `tk_dialog'. First, create all your Dialog objects during program initialization. When it's time to use a dialog, invoke the Show method on a dialog object; the method then displays the dialog, waits for a button to be invoked, and returns the text label of the selected button.

A Dialog object essentially consists of two subwidgets: a Label widget for the bitmap and a Label wigdet for the text of the dialog. If required, you can invoke the `configure' method to change any characteristic of these subwidgets.

Because a Dialog object is a Toplevel widget all the 'composite' base class methods are available to you.

Advertised widgets: bitmap, message.


Call the constructor to create the dialog object, which in turn returns a blessed reference to the new composite widget:

    require Tk::Dialog;

    $DialogRef = $widget->Dialog(
        -title          => $title,
        -text           => $text,
        -bitmap         => $bitmap,
        -default_button => $default_button,
        -buttons        => [@button_labels],
  • mw

    a widget reference, usually the result of a MainWindow->new call.

  • title

    Title to display in the dialog's decorative frame.

  • text

    Message to display in the dialog widget.

  • bitmap

    Bitmap to display in the dialog.

  • default_button

    Text label of the button that is to display the default ring (''signifies no default button).

  • button_labels

    A reference to a list of one or more strings to display in buttons across the bottom of the dialog.


Invoke the Show method on a dialog object

    $button_label = $DialogRef->Show;

This returns the text label of the selected button.

(Note: you can request a global grab by passing the string -global to the Show method.)




window, dialog, dialogbox


Stephen O. Lidie, Lehigh University Computing Center. 94/12/27 lusol@Lehigh.EDU (based on John Stoffel's idea).

syntax highlighting: