user401304 user401304 - 6 months ago 18
Perl Question

Hide window in Perl/Tk and show again incl. all widgets

I want to hide the mainwindow for a certain amount of time then show it again.
Example:

use Tk;

my $mw = new MainWindow;
my $lblMsg = $mw -> Label(-text=>"blabla")-> grid();
my $btnPostpone = $mw -> Button(-text=>"Postpone for (min): ",
-command =>\&postpone)-> grid();

MainLoop;

sub postpone{
$mw-> withdraw();
sleep(1);
$mw->deiconify();
$mw->raise();
sleep(1);
exit;
}


With the above code the main window will reappear but none of the widgets are displayed.
What do I have to do so everything will look exactly the way it did before it was hidden?

Any hints appreciated.

Answer

You need to call $mw->update(); after you raise() the main window.

The Tcl Tk Wiki explains why in a bit of detail.

Comments