Hi, folks!
I am developing a GUI to process a lot of data files in batch. So, the user
selects a folder, press a button and the application process all the files
in this folder. As the processing of each files takes a couple of seconds or
more, and there may be dozens of files, I want to display a nice progress
bar.
First problem: my first approach was to put a gtk.ProgressBar overlapping a
part of the gtk.StatusBar of the main window (please, bear in mind that I am
using Glade3 to develop my application). So, I would keep the ProgressBar
hidden, show it when necessary and hide it again. Using this approach (a
gtk.ProgressBar as a child of a gtk.StatusBar), the progress bar widget is
not found in the gladefile when I run get_wiget(). The relevant part ot the
__init__ function of my GUI is:
(...)
self.pbProgresso = self.wTree.get_widget( "pbProgresso" )
print self.pbProgresso
(...)
and I just get a "None" printed to the terminal. I checked my gladefile, and
the gtk.ProgressBar is there, and the name is right ("pbProgresso"). I am
copying below the relevant part of my gladefile:
(...)
<widget class="GtkStatusbar" id="statusbar1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkProgressBar" id="pbProgresso">
<property name="no_show_all">True</property>
<property name="show_text">True</property>
<property name="text" translatable="yes"></property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">GTK_PACK_END</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
(...)
Then I substituted this approach by anothet one: I put a HBox in the bottom
of my window, and inside this HBox there is a gtk.StatusBar (first widget,
to the left) and a gtk.ProgressBar (second widget, to the right). The names
of the widgets are the same. When I run the code again, the ProgessBar is
loaded, and "<gtk.ProgressBar object at 0x85a66e4 (GtkProgressBar at
0x87f7ea0)>" is printed to the terminal.
So, my question is: what difference does it make the gtk.ProgressBar being a
child of gtk.HBox instead of a child of gtk.StatusBar?
Second problem: I am running a loop and want to increment the fraction of
the ProgressBar once per pass. However, when I run my code, I only see the
final ProgressBar, fully painted at the end of the loop. How can I force the
ProgressBar to be immediately updated, before the next pass of my loop? The
loop looks like
(...)
indice = 0
self.pbProgresso.show()
for item in modelo:
arquivoTXT = item[ 0 ]
print arquivoTXT
print ( ( indice/items ) ), indice, items
self.pbProgresso.set_fraction( ( indice/items ) )
<... does a lot of stuff ...>
indice = indice + 1
(...)
Thanks in advance,
--
Marcus Vinicius Eiffle Duarte
[EMAIL PROTECTED]
NiterĂ³i, RJ, Brasil
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/