#! /usr/bin/perl -w # use strict; use warnings "all"; use Tk; use Tk::Dialog; our $mw = new MainWindow; my $f_select = $mw->Frame( -bd=>2, -relief=>'groove') ->pack(-side=>'left', -fill=>'y'); my $f_refresh = $f_select->Frame() ->pack(-side=>'bottom', -fill=>'x'); $f_refresh->Button(-text => 'Test', -command => sub {displayMsg()}) ->pack(-side=>'left'); # This one works. $mw->Dialog(-title => "Test", -text => "My test Message", -bitmap=>'question', -buttons => ['Ok'])->Show(); MainLoop; exit; # Should never actually get here. sub displayMsg { print "before\n"; # for some reason, Dialog() does not work from this context. # $mw->Dialog(-title => "Error", -text => "My Error Message", -bitmap=>'error', -buttons => ['Ok'])->Show(); my $dialogWindow = $mw->Dialog(-title => "Error", -text => "My Error Message", -bitmap=>'error', -buttons => ['Ok']); $dialogWindow->Show(); # neither does messageBox :-( #my $answer => $mw->messageBox(-title => 'Please Reply', # -message => 'Would you like to continue?', # -type => 'YesNo', -icon => 'question', -default => 'yes'); print "after\n"; }