my $dialog = $mw->Dialog( [ option => value ] );Some basic options are
my $answer = $dialog->Show(-global);In this, -global, if specified, results in a global (rather than a local) grab being done.
An example of the use of a dialogue box follows.
#!perl # file dialog.pl use Tk; use strict; use warnings; my $message = 'nothing yet ...'; my $mw = MainWindow->new; $mw->title('Dialog'); my $label = $mw->Label(-textvariable => \$message); my $save = $mw->Button(-text => 'Press to save!', -command => \&dialog); my $exit = $mw->Button(-text => 'Exit', -command => [$mw => 'destroy']); $exit->pack(-side => 'bottom'); $save->pack(-side=>'top'); $label->pack(-side => 'top'); MainLoop; sub dialog { use Tk::Dialog; my $dialog = $mw->Dialog(-text => 'Save File?', -bitmap => 'question', -title => 'Save File Dialog', -default_button => 'Yes', -buttons => [qw/Yes No Cancel/]); my $answer = $dialog->Show(); $message = qq{You pressed '$answer'}; }In this example, when the user presses the ``Press to save!'' button, a dialogue box will pop up, asking for confirmation. The value selected will subsequently be reflected in the label appearing in the main window. The dialogue box appears in the figure below.
Randy Kobes 2003-11-17