progress bar and loop
- From: Martynas Jocius <mjoc delfi lt>
- To: gtk-list gnome org
- Subject: progress bar and loop
- Date: Sat, 11 May 2002 15:55:49 +0200
Hello,
I'm writing a program in python and I'm using pygtk. I found a problem and
couldn't find a solution on the web, so I decided to look for help in gtk
hackers mailing list.
There is a window with it's widgets and progress bar. There is an array of
commands and these commands are executed while the loop.
For example, the array is:
["mpg123 track1.mp3 -w track1.wav",
"mpg123 track2.mp3 -w track2.wav",
"mpg123 track3.mp3 -w track3.wav"]
These commands do the execution of mpg123, which converts mp3 files to wav.
The simplified code is some like that:
# ---
i = 0
while i < 3:
add_timeout(...)
# adding progress bar timeout here
# The program forks here and child process executes a command from
# the array:
[...]
fork...
[...]
# child
exec array[i]
exit when done
i += 1
def add_timeout(...):
# while executing a command, wav file size grows up
# progress bar show the size (current_size / full_size)
The problem is:
while executing a shell command, the while loop should not add new timeouts
and execute next shell commands. So it can continue() until exec process
is alive.
But if I do so, the gtk window hangs and stops, and loop makes a very big
CPU usage. sleep() doesn't help for GUI application.
If someone knows what to do or can give some links about that, please help.
I know few programs (like grip) where the task as mine works very well, but C
code is too hard to understand for me, I'm searching for some examples for
loops and progress bars.
Thanks.
--
Martynas Jocius
http://mjoc.infoseka.lt
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]