1

I would like to know a good way to make a GUI progress bar. I'm using python, Glade/GTK. An example of a program I'd like to get more than just a pulse bar. Something that could give the user a more accurate way to know the progress. The program I'm trying to capture this for is cdparanoia, but would like to know how to do this in general for other programs like wget. Important to note on these two programs is the the info is output on stderr.

I should mention that when doing a

output = p.stderr.read(1)
print output

Doesn't show that the text progress bar is showing. It is almost like it is treating a non-interactive shell differently. There are no carriage returns (\r) like I thought it would be doing.

Codings is as such:

import subprocess, shlex, gtk

command = 'cdparanoia -w -Z 1- - | sox -t wav - "my disk.flac"'

p = subprocess(shlex.split(command), stderr=subprocess.PIPE)

gui = gtk.Builder()
gui.add_from_file("pulsebar.glade")
#do magic here to make a good pulsebar

Gratefully, Narnie

narnie
  • 1,742
  • 1
  • 18
  • 34
  • 1
    It could very well be that it is treating a non-interactive shell differently. For a text progress bar it probably uses something like ncurses, which doesn't work if it's not on a terminal. I don't know the specifics. – ptomato May 07 '11 at 06:43
  • any luck? Did `-e` help? I tested it -- it did appear to output to stderr when called with `-e`; and the position of the `>` character seems like a quick, simple and easy way to calculate an appropriate fraction. – senderle May 10 '11 at 22:02
  • Sadly, I dropped of developing this app long enough that glade changed in my repo to the next version that is GTK3. I hope one day to port this over and might resume developing, but I'm in the middle of another project and need to start and finish yet another before I can come back to this. – narnie Mar 03 '12 at 03:23

1 Answers1

0

gtk.ProgressBar? (Note the .set_fraction() method.)

Here's some info about doing non-blocking reads from a subprocess. The suggestion of polling with timeout seems appropriate. Also, this answer.

My dim memory of cdparanoia's progress indicator is that it is very idiosyncratic. But I'm guessing it's just some silly stuff + '\r'; shouldn't be too hard to extract a fraction from it.

Edit: Ok, actually, perhaps the above is incorrect under normal usage situations; but have you tried -e?

-e --stderr-progress
          Force  output  of  progress  information  to stderr (for wrapper
          scripts).
Community
  • 1
  • 1
senderle
  • 145,869
  • 36
  • 209
  • 233
  • as above, I have found out that the text progress bar doesn't show as the edit to the question above. – narnie May 07 '11 at 04:15