progress && loop
Michael Gilfix
mgilfix at eecs.tufts.edu
Sun May 12 01:32:07 EDT 2002
Hiya. Sounds like you want to use the Event () synchronization
object in the threading module. That way, you can have your loop wait
until something is set and then wake up. You can then set the event
every time you want to update the gui. Hope that helps point
you in the right direction. Remember to use threads_enter ()
and threads_leave () from inside your calling thread :)
-- Mike
On Fri, May 10 @ 23:45, Martynas Jocius wrote:
> Hello,
>
> I'm writing a program in python and my question can be applyed for any
> other program using GUI toolkit (I use pygtk).
>
> I have a progress bar and timout function. I have a loop:
> i = 0
> while i < 10:
> # do some action, for example exec a shell program
> add_timeout(...) # This sets a progress bar timeout for some
> # action. For example I'm execing mpg123 in
> # a shell and playing an mp3 file.
> # Progress bar shows how much it is already
> # played.
>
> # I want to sleep() or something there until timeout returns FALSE,
> # then continue the loop with i=1,2,3 etc
>
> i += 1
>
> So I don't know how to do that. If I check for executed program is done
> and continue the loop if it's still working, I get a loop with a big
> percent CPU usage and Gtk Window "sleeps" until the loop is over.
>
> I could'n find any example how to do that, I know it is possible. For
> example "grip" do something what I want, but it's C code is too hard for
> me and I'm searching for simpler exmample, maybe in python.
>
> Thanks a lot for help.
> --
> http://mail.python.org/mailman/listinfo/python-list
`-> (mjoc)
--
Michael Gilfix
mgilfix at eecs.tufts.edu
For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html
More information about the Python-list
mailing list