Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Keeping the user informed: A Tk/Threads question

by Joost (Canon)
on Jul 07, 2004 at 14:45 UTC ( #372401=note: print w/replies, xml ) Need Help??

in reply to Keeping the user informed: A Tk/Threads question

Good question. If you can spread your processing in smaller bits and you can get the smaller bits called from the MainLoop, everything will work. The way I do it in one application is that I build my own MainLoop:

use Tk::Event qw(DONT_WAIT); while (1) { if ($self->run) { # test if we need to process $self->process_a_bit() # process a tiny bit } return if $self->quit; # test if quit status was set DoOneEvent(DONT_WAIT); # do normal Tk event select undef,undef,undef,0.0001; # wait for a bit }
I did this, because my processing was not easily adjusted into the normal Tk::Eventloop processing and it needed to be called a lot ("live" 44Kz audio stream processing, with 100 samples per process_a_bit call)

If you want to go this route, you want to adjust the timing of the select() and process_a_bit() calls until your GUI and processing run fast enough, and it doesn't lock up the whole machine when there is no processing being done :-)

Alternatively, if you're able to run your processing based on file events or signals, you can take a look at the Tk::Eventloop documentation for registering extra events in the normal MainLoop.

Oh yes, and you want something like Tk::ProgressBar but you probably know that already :-)

Replies are listed 'Best First'.
Re^2: Keeping the user informed: A Tk/Threads question
by Grygonos (Chaplain) on Jul 07, 2004 at 15:32 UTC

    Yeah Tk::ProgressBar would be best, but I don't know (until its already over) how far along a file would be at point X. Basically the data is being read from the file in a while <DATA> loop, to me that doesn' tmuch lend itself to that... is there a way to pop up a dialog and auto-dismiss it? or something?

    /me needs to buy Mastering Tk

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://372401]
[Lady_Aleena]: s/latter/ladder/; # ? marioroy
[karlgoethebier]: marioroy: Praise the Lord
[marioroy]: Well, that's why there must be angels around, invisible or not.
[marioroy]: Lady_Aleena yes, ladder.
[marioroy]: Corion, no not intentionally. not at all.
[Lady_Aleena]: /ne tries to decide whther or not to take a hammer to hubby's alarm clock.
[Lady_Aleena]: He never hears it.
[marioroy]: Back in HighSchool, I came late to Gym class. There was a fellow who was picked last, no team wanted him for racketball. So it was us two against everybody. I looked at him in the eye and said to let your body loose and let the powers to be help us win.
[marioroy]: We made it all the way to the end. The expience was magical. I not good at sports. Someone or thing was there.

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2017-05-29 08:38 GMT
Find Nodes?
    Voting Booth?