1DialogBox(3) User Contributed Perl Documentation DialogBox(3)
2
3
4
6 Tk::DialogBox - create and manipulate a dialog screen.
7
9 use Tk::DialogBox
10 ...
11 $d = $top->DialogBox(-title => "Title", -buttons => ["OK", "Cancel"]);
12 $w = $d->add(Widget, args)->pack;
13 ...
14 $button = $d->Show;
15
17 DialogBox is very similar to Dialog except that it allows any widget in
18 the top Frame. DialogBox creates two Frames, top and bottom. The bottom
19 Frame shows all the specified Buttons, lined up from left to right. The
20 top Frame acts as a container for all other widgets that can be added
21 with the add() method.
22
24 The options recognized by DialogBox are as follows:
25
26 -title
27 Specify the title of the DialogBox. If this is not set, then the
28 name of the program is used.
29
30 -buttons
31 The button names to display in the bottom Frame. This is a
32 reference to an array of strings containing the text to put on each
33 Button. There is no default value for this. If you do not specify
34 any button names, no Buttons are displayed.
35
36 -default_button
37 Specifies the default Button that is considered invoked when user
38 presses <Return> on the DialogBox. This Button is highlighted. If
39 no default Button is specified, then the first element of the array
40 whose reference is passed to the -buttons option is used as the
41 default.
42
43 -cancel_button
44 Specifies the Button that is considered invoked when the user
45 closes the DialogBox using the window manager's close button. If
46 the -cancel_button option is not given, and if there's only one
47 button configured, then this button is also used as the cancel
48 button. Otherwise no button is considered as the cancel button; in
49 such a case Show just returns "undef" when the user closes the
50 DialogBox.
51
52 -command
53 A callback which is executed after invoking an action to close the
54 DialogBox, but before restoring focus and grab information. The
55 selected button is passed as the first argument.
56
57 -focus
58 Specify the widget to receive the initial focus after popping up
59 the DialogBox. By default the -default_button widget receives the
60 initial focus.
61
62 -showcommand
63 A callback which is executed before displaying the DialogBox and
64 waiting for user input. The DialogBox itself is passed as the first
65 argument.
66
68 DialogBox supports only two methods as of now:
69
70 add(widget, options)
71 Add the widget indicated by widget. Widget can be the name of any
72 Tk widget (standard or contributed). options are the options that
73 the widget accepts. The widget is advertized as a subwidget of
74 DialogBox. The name of widget is lower-cased and used as the
75 advertised name. If multiple instances of widget are created in the
76 DialogBox, then only the last one gets the advertised name. add()
77 does not automatically pack() or grid() widget into the DialogBox.
78
79 Show(?-global?)
80 Displays the Dialog until the user invokes one of the Buttons in
81 the bottom Frame. If the grab type -global is specified, then Show
82 uses that grab; otherwise it defaults to a local grab. Returns the
83 name of the Button invoked.
84
85 The actual Dialog is shown using the Popup method. Any other
86 options supplied to Show are passed to Popup, and can be used to
87 position the Dialog on the screen. Please read Tk::Popup for
88 details.
89
90 Exit()
91 Close the dialogbox, by emulating a click on the default button.
92
94 top The subwidget reference to the top half of the DialogBox widget,
95 the Frame containing widgets added by the add method.
96
97 bottom
98 The subwidget reference to the bottom half of the DialogBox widget,
99 the Frame containing the Button widgets.
100
101 B_"button-text"
102 Individual subwidget references to the Buttons in the DialogBox
103 widget. The subwidget name is the string B_ concatenated with the
104 Button's -text value.
105
107 There is no way of removing a widget once it has been added to the top
108 Frame, unless you access the top subwidget and go through the child
109 widgets.
110
111 There is no control over the appearance of the Buttons in the bottom
112 Frame nor is there any way to control the placement of the two Frames
113 with respect to each other.
114
116 Rajappa Iyer rsi@earthling.net
117
118 This code is distributed under the same terms as Perl.
119
120
121
122perl v5.34.0 2021-07-23 DialogBox(3)