in reply to Re: Perl/Tk and exit(0)
in thread Perl/Tk and exit(0)
Thanks for the reply. I know exit causes the program to exit, but I believe the call to the subroutine preceding the exit statement should cause the message window to display before the program exits. I know sub timedDialog executes because I inserted a print statement in it and it does indeed print but the message window never displays; and I put a sleep statement between the sub call and exit in hope of allowing time for the message to display but no go.
I just noticed I called timedDialog both in sub checkDays and in sub setupGUI I fixed this and still no message shows
Fixed code follows
#!/usr/bin/perl ###################################################################### +## use strict; use warnings; use Tk; my $mw = MainWindow -> new; my $timedDialogTitle = ''; my $timedDialogText = ''; my $svBtn = undef; #Option window SAVE button. &setupGUI; $mw->deiconify(); $mw->raise(); MainLoop; exit(0); ################################################ ################################################ sub setupGUI{ $svBtn = $mw->Button( -text => "SAVE", -command => sub {&checkDays +; exit(0);}); $svBtn->grid(-row => 9, -column => 2, -sticky => 'e'); $mw->bind('<KeyPress-Return>' => sub {&checkDays; exit(0);}); $mw-> withdraw(); } ##################################### sub checkDays { &timedDialog("Exiting", "O.K., no backup will be made, + then....Exiting", 25_000); sleep 15; } ##################################### sub timedDialog { print ("in timedDialog\n"); my $subwindow = MainWindow->new; $subwindow->geometry("490x150+400+400"); $subwindow->title($_[0]); my $label = $subwindow->Label(-text => $_[1]); $label->pack; $subwindow->after($_[2], sub {$subwindow->destroy;}); } #####################################
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl/Tk and exit(0)
by jcb (Parson) on Apr 03, 2020 at 01:56 UTC | |
by saw55 (Novice) on Apr 03, 2020 at 04:46 UTC | |
by tybalt89 (Monsignor) on Apr 03, 2020 at 06:37 UTC | |
by saw55 (Novice) on Apr 03, 2020 at 11:13 UTC | |
by AnomalousMonk (Archbishop) on Apr 03, 2020 at 20:33 UTC | |
by soonix (Chancellor) on Apr 04, 2020 at 09:33 UTC |