Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Perl/Tk window contents disappear when obscured then revealed

by choroba (Cardinal)
on Jan 21, 2013 at 15:18 UTC ( [id://1014460]=note: print w/replies, xml ) Need Help??


in reply to Perl/Tk window contents disappear when obscured then revealed

I cannot find Tk::mySplashScreen in Tk.

For the second example, just move the update line inside the loop. You have to update the window to make it redraw itself.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Perl/Tk window contents disappear when obscured then revealed
by Another Ed (Sexton) on Jan 21, 2013 at 15:34 UTC

    Hi, thanks for your reply. I don't think I made myself clear: the loops in the example code I posted are not there for any purpose other than for the Perl script to do something while the message window is displayed. In the real code, there would be a Perl 'system' call to a scanner program, requiring user interaction, at that point. Therefore there is no loop in the real code.

    I must confess that, even if I had a loop in the real code, I wouldn't feel comfortable with putting in a forced "refresh" every time round it: surely there's a less crude way of not losing the contents of a window?

      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...

        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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1014460]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-03-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found