ff has asked for the wisdom of the Perl Monks concerning the following question:

I recently experienced a problem that I found had been better stated at comp.lang.perl.tk. I asked Peter if he had a solution yet and he sent a nice update which I now post with his permission. I extended his suggestion a bit to handle transient windows.


From: Peter Signell
Subject: refreshing mw after overlaid window

Newsgroups: comp.lang.perl.tk
Date: 2002-09-16 07:37:21 PST

Hi - In Tk I call another program via system(), which program displays its own window. When I dismiss that program, its window vanishes and the mw reappears but any part covered by the previous window is blank (devoid of color and widgets). If I now mouse-move the mw at all, it refreshes and all is well. Can I program in a refresh (of course I have tried a number of things that don't work)? I seem to only have this problem since switching to XP.

Someone else wrote:

Did you try:
$mw->update;

It sounds like a window manager bug.

Pete said:
Yes, $mw->update; was one of the numerous things I tried, to no avail. I just tried it again with no result. Thanks, though. Perhaps it is indeed an XP bug.

I asked Pete if he had yet found a solution.

Pete said (1/20/03):
Hi - Yes, I did get a solution from Stephen O. Lidie, author of the Perl/TK book, to whom I had sent a plea via e-mail. He suggested using iconify and deiconify, and it worked doubly well for me since the visual result of the deiconify shows that the rather lengthy system command has completed. I like it!

if ($choice eq 'rev_hist') { $mw->iconify; system($frontpage.' '.$mods_rev_file); system('scp2 $rev_hist_file $destination'); $mw->deiconify; return;

My own application of "iconify/deiconify" follows.

In the midst of a subroutine to which I pass a label-widget reference ($last_action_value_l) I invoke 'system'. Sometimes I call the subroutine from the MainWindow, sometimes from a transient (child?) window of the MainWindow. The iconify/deiconify process above doesen't seem to work for transient windows, so perform appropriate checks:

my $spec_tl = $last_action_value_l->toplevel(); ## if $spec_tl signifies a transient window, find its master ## and iconify/deiconify it. Otherwise, ic/deic $spec_tl, which ## is the master/toplevel of the $last_action_value_l button. my $spec_tl_trans = $spec_tl->transient(); # "tests" whether $spec_tl is a transient window, # saves a ref to its MainWindow if it is. ## The "pre-system" iconify $spec_tl_trans ? $spec_tl_trans->iconify() : $spec_tl->iconify(); print STDERR "spec_tl_trans:$spec_tl_trans\n" if $spec_tl_trans; my $prob_found = system "$path_of_wp $$dd_con_hr{db_filename}"; if ( $prob_found ) { warn "menu_DD_SuppDB: xls system prob $!"; $rc = 'red_40'; } ## The "post-system" deiconify $spec_tl_trans ? $spec_tl_trans->deiconify() : $spec_tl->deiconify();

update (broquaint): fixed <readmore>