http://www.perlmonks.org?node_id=1014488


in reply to Re^2: Perl/Tk window contents disappear when obscured then revealed
in thread Perl/Tk window contents disappear when obscured then revealed

Perhaps you need to run your system command as a background process? The problem is that when you run a system command that seizes control of the current process, the Tk event loop doesn't get executed, so no window updates occur. If you call external programs in their own process, it allows the Tk events some processing time.

See below: (Windows example, adjust as necessary to call background processes in your OS)

use strict; use warnings; use Tk; my $mw = MainWindow->new; my $m = $mw->Message(-text => "testing, one, two, three...")->pack; $mw->update; system("start notepad.exe"); MainLoop;

For your sleep example? Well, if you don't call your event loop periodically, don't be surprised if your events don't get processed...

  • Comment on Re^3: Perl/Tk window contents disappear when obscured then revealed
  • Download Code

Replies are listed 'Best First'.
Re^4: Perl/Tk window contents disappear when obscured then revealed
by Another Ed (Sexton) on Jan 22, 2013 at 13:01 UTC
    Hi thundergnat, thanks for your reply. I am indeed (and unfortunately) trying to do this on Windows. Invoking the external program with 'start' seems to mean that Perl doesn't wait for it. I guess this is equivalent to a background command in a Linux shell. The problem is that I need the Perl script to wait for the external command: the user uses that command to scan a document, then the Perl script needs to go on and handle the scanned file. So I cannot see that 'start' helps.