Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: convert a single thread application to multithread with GUI

by ultibuzz (Monk)
on Jul 11, 2007 at 13:49 UTC ( #626008=note: print w/ replies, xml ) Need Help??


in reply to Re^3: convert a single thread application to multithread with GUI
in thread convert a single thread application to multithread with GUI

thats an awsome exaple, now i know how to make a cmd like text scrollbox ;)
also the thread reuse thing is now a bit clearer
thx for the nice example and i hope it will push me in the right direction

kd ultibuzz


Comment on Re^4: convert a single thread application to multithread with GUI
Re^5: convert a single thread application to multithread with GUI
by zentara (Archbishop) on Jul 11, 2007 at 16:14 UTC
    One thing I forgot to mention is that threads can share a filehandle thru the fileno, so that can help in logging. Your main thread can open the FH to the log, then you send the fileno of the FH to the threads, and they can print to it. See FileHandles and threads

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum

      cheers,
      yeah shared FH i know.
      but i encounter another problem, the TK- Scrolled object wich is used to display eat up all memory ;).
      is there a way to limit the box to 1000 lines and then it shoud overwrite ?, so it will not write the memory full :D.

      kd ultibuzz

        Here is the basic idea, for a sliding buffer of 'x' lines:
        #!/usr/bin/perl use Tk; use Tk::Text; my $mw=tkinit; my $text = $mw->Scrolled('Text')->pack; $text->bind('<Return>',[sub { &check_limit }]); $mw->Button(-text=>'Press Me', -command=>sub { $text->insert('end',$i++."\n"); $text->see('end'); &check_limit; })->pack; $mw->Button(-text=>'Exit', -command=>sub {exit})->pack; for (1..198){ $text->insert('end',$_."\n"); $text->see('end'); } MainLoop; sub check_limit{ $text->delete('1.0', "end -200 lines"); }

        I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-09-02 11:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (21 votes), past polls