For things like a simple "are you sure?" dialog box you might want to take a look at Dialog.pm which is discussed in a later question within this FAQ [15.1].
If you don't wish to require Tk::Dialog, you need something more complicated, or you simply want to create your own independent window with widgets; you must first setup a Toplevel in perl/Tk. The fourth example in UserGuide.pod gives a simple example of how to call Toplevel. Quoting from that script:
my $main = new MainWindow; fill_window($main, 'Main'); my $top1 = $main->Toplevel;Where sub fill_window is declared after the call to MainLoop;. When running that script take careful note of which window pops up first, which window has grabbed the active attention of your input device(s), and which widget within the active window has the keyboard/mouse focus when all three windows are open.
The use of Toplevels brings up the issue of grab - or which independent window is presently "active" and which are activatable. To make a Toplevel window active call grab thusly:
$Top_widget->grab(grab_option);where $Top_widget identifies the desired Toplevel (it would be either $top1 or $top2 in the sample script referred to above). grab_option could be -global - but this is discouraged as a sign of "desparate programming style". To give a Toplevel "local grab" you may simply say:
$Top_widget->grab;That is, without an argument.
The use of Toplevels may also bring up the issue of focus - or which window - even which widget within a window - is presently "hot". You may call focus on an entire Toplevel:
$Top_widget->focus;However, focus is most often used with individual widgets rather than a whole Toplevel.
To de-iconify a widget there is in fact a Popup function that may be called thusly:
Previous | Return to table of contents | Next