#!/usr/bin/perl # Demo new "MainWindow" vs. "withdraw " problem. use Tk; use strict; use warnings; use Tk::DialogBox; require Tk::Dialog; my $mw = MainWindow -> new; my $fontHelv = 'Helvetica 12'; $mw->optionAdd('*font', $fontHelv); my $timedDialogText = ''; my $dest = ''; my $answer = ''; my $renameString; my $excludeFile; my $scriptDir = "FILE"; $timedDialogText = &mainGUI($timedDialogText); $renameString = &timeSinceLastRun; $mw->deiconify(); $mw->raise(); # Show the mainwindow MainLoop; &printRenameMessage($timedDialogText, $dest, $renameString); &exitingPopup($renameString); exit(0); sub mainGUI{ my $timedDialogText; my $svBtn = undef; # SAVE button. my $timedDialogTitle = ''; $svBtn = $mw->Button( -text => "SAVE", -command => sub { keyPressMainGUI($dest, $timedDialogText) } ); $svBtn->grid(-row => 9, -column => 2, -sticky => 'e'); $mw->bind('' => sub { keyPressMainGUI($dest, $timedDialogText) } ); #$mw-> withdraw(); # Uncomment return "timedDialogText"; } sub keyPressMainGUI{ my $dest = $_[0]; my $timedDialogText = $_[1]; $mw->withdraw; #### Switch these 2 #$mw->destroy; #### $timedDialogText = &timedDialog("timedDialogTitle", "timedDialogText", 2_000); } sub QuestionDialogBox{ my $renameString = ("[0]\n"); $mw->raise; #$mw->withdraw; #### Uncomment $answer = $mw->Dialog(-title => $_[0], -text => $_[1], -default_button => 'Finish', -buttons => ['Finish'], -bitmap => 'info' )->Show(-global, -popover => $mw, -overanchor => 'c', -popanchor => 'c' ); $mw->geometry("450x150+10+10"); return "answer"; } sub printRenameMessage { #$mw = MainWindow -> new; #### Uncomment $answer = &QuestionDialogBox( "Create Archives?", "Do you want to save the files in a tarball named renameString?"); &timedDialog("Progress", "timedDialogText", 5_000); &timedDialog("COMPLETE", "timedDialogTextX\n\nCreating fie Date...X\n\nFinished.", 5_000); } sub timeSinceLastRun{ my $answer = &QuestionDialogBox( "Do you want to continue?"); return "renameString"; } sub exitingPopup { my $renameString = $_[0]; my $visibleStr = ''; $answer = $mw->Dialog(-title => "COMPLETE", -text => "visibleStr \n excludeStr", -default_button => 'Finish', -buttons => ['Finish'], -bitmap => 'info' )->Show(-global, -popover => $mw, -overanchor => 'c', -popanchor => 'c' ); $mw->geometry("450x150+10+10"); } sub timedDialog { my $subwindow = MainWindow->new; $subwindow->optionAdd('*font', $fontHelv); $subwindow->geometry("490x150+400+400"); $subwindow->title($_[0]); my $label = $subwindow->Label(-text => $_[1]); $label->pack; $subwindow->after($_[2], sub {$subwindow->destroy;}); }