progress && loop

Martynas Jocius mjoc at delfi.lt
Fri May 10 17:45:49 EDT 2002


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.



More information about the Python-list mailing list