Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Threading Tk

by dooberwah (Pilgrim)
on May 17, 2002 at 23:02 UTC ( #167432=perlquestion: print w/replies, xml ) Need Help??
dooberwah has asked for the wisdom of the Perl Monks concerning the following question:

Hello brothers and sisters,

I'm working on writing an application that uses Tk for it's GUI. One of the functions of the program is to download content from a webpage. So far this is all fine and good, Tk handles the GUI and LWP takes care of the webpage-fetching. The problem is that while the webpage is being downloaded the Tk interface freezes up. It stops handling input or output and just turns into an annoying blob of a window. I'd like to know a way to download my webpage, while at the same time keeping the functionality of my Tk program intact.

I sifted through various nodes on in the monastary and looked at some modules on CPAN, but I couldn't find what I was looking for. Actually, it's not that I couldn't find what I was looking for; it was that I didn't know exactly what I was looking for. Two things that looked nice were Parallel::ForkManager and fork. Unfortunetaly I havn't used either, and I don't know their pro's and cons.

If you have any advice for me it would be more than welcome. Thanks.

-Ben Jacobs (dooberwah)
http://dooberwah.perlmonk.org
"one thing i can tell you is you got to be free"

Replies are listed 'Best First'.
Re: Threading Tk
by {NULE} (Hermit) on May 17, 2002 at 23:40 UTC
    Hi dooberwah,

    We actually just discussed this topic in some detail a day ago. Take a look here for some hopefully useful thoughts.

    Basically this is a usable technique that can help you achieve your goal of making your app appear not to block. Just for a quick, drawn-on-a-napkin design of the app, I would think about forking first, have the parent do the Tk stuff and the child do the LWP stuff. Connect them with the socket of your choice and then take a look at IO::Socket and IO::Select for doing non-blocking communication. Also recommended is Lincoln Stein's excellent book Network Programming with Perl, which covers the two modules in great detail.

    Good luck,
    {NULE}
    --
    http://www.nule.org

Re: Threading Tk
by DamnDirtyApe (Curate) on May 18, 2002 at 21:58 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://167432]
Approved by Elian
Front-paged by sparkyichi
help
Chatterbox?
[Discipulus]: śledzie!! the only sweet my father in law eat

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2017-11-21 11:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (297 votes). Check out past polls.

    Notices?