Tk::DialogBox3pm
Create and manipulate a dialog screen.
Usage
use Tk::DialogBox...$d = $top->DialogBox(-title => "Title", -buttons => ["OK", "Cancel"]);$w = $d->add(Widget, args)->pack;...$button = $d->Show;
Overview
DialogBox is very similar to Dialog except that it allows any widget in the top Frame. DialogBox creates two Frames, top and bottom. The bottom Frame shows all the specified Buttons, lined up from left to right. The top Frame acts as a container for all other widgets that can be added with the add() method.
Options
The options recognized by DialogBox are as follows:
-
-title -
Specify the title of the DialogBox. If this is not set, then the name of the program is used.
-
-buttons -
The button names to display in the bottom Frame. This is a reference to an array of strings containing the text to put on each Button. There is no default value for this. If you do not specify any button names, no Buttons are displayed.
-
-default_button -
Specifies the default Button that is considered invoked when user presses <Return> on the DialogBox. This Button is highlighted. If no default Button is specified, then the first element of the array whose reference is passed to the
-buttonsoption is used as the default.
-
-cancel_button -
Specifies the Button that is considered invoked when the user closes the DialogBox using the window manager's close button. If the
-cancel_buttonoption is not given, and if there's only one button configured, then this button is also used as the cancel button. Otherwise no button is considered as the cancel button; in such a caseShowjust returns"undef"when the user closes the DialogBox.
-
-command -
A callback which is executed after invoking an action to close the DialogBox, but before restoring focus and grab information. The selected button is passed as the first argument.
-
-focus -
Specify the widget to receive the initial focus after popping up the DialogBox. By default the
-default_buttonwidget receives the initial focus.
-
-showcommand -
A callback which is executed before displaying the DialogBox and waiting for user input. The DialogBox itself is passed as the first argument.
Methods
DialogBox supports only two methods as of now:
add(widget, options)-
Add the widget indicated by widget. Widget can be the name of any Tk widget (standard or contributed). options are the options that the widget accepts. The widget is advertized as a subwidget of
DialogBox. The name of widget is lower-cased and used as the advertised name. If multiple instances of widget are created in theDialogBox, then only the last one gets the advertised name.add()does not automaticallypack()orgrid()widget into theDialogBox.
Show(?-global?)-
Displays the Dialog until the user invokes one of the Buttons in the bottom Frame. If the grab type -global is specified, then
Showuses that grab; otherwise it defaults to a local grab. Returns the name of the Button invoked.The actual Dialog is shown using the
Popupmethod. Any other options supplied toShoware passed toPopup, and can be used to position the Dialog on the screen. Please read Tk::Popup for details.
Exit()-
Close the dialogbox, by emulating a click on the default button.
Advertised widgets
top-
The subwidget reference to the top half of the DialogBox widget, the Frame containing widgets added by the
addmethod.
bottom-
The subwidget reference to the bottom half of the DialogBox widget, the Frame containing the Button widgets.
B_"button-text"-
Individual subwidget references to the Buttons in the DialogBox widget. The subwidget name is the string B_ concatenated with the Button's -text value.
Releases
16 releases since Debian 2.0 (Hamm); the text changed 15 times.
-cancel_button since Debian 5.0 (Lenny);
-command since Debian 4.0 (Etch);
-focus since Debian 4.0 (Etch);
-showcommand since Debian 4.0 (Etch).