1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| import pygtk
pygtk.require('2.0')
import gtk, gobject
class ProgressBar:
def affiche(self, widget, data=None):
for i in range(100000):
self.pbar.set_text(str(i))
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_resizable(True)
self.window.connect("destroy", self.destroy_progress)
self.window.set_title("ProgressBar")
self.window.set_border_width(0)
vbox = gtk.VBox(False, 5)
vbox.set_border_width(10)
self.window.add(vbox)
vbox.show()
# Create a centering alignment object
align = gtk.Alignment(0.5, 0.5, 0, 0)
vbox.pack_start(align, False, False, 5)
align.show()
# Create the ProgressBar
self.pbar = gtk.ProgressBar()
align.add(self.pbar)
self.pbar.show()
# Add a button to exit the program
button = gtk.Button("Affiche")
button.connect("clicked", self.affiche)
vbox.pack_start(button, False, False, 0)
# This makes it so the button is the default.
button.set_flags(gtk.CAN_DEFAULT)
button.grab_default ()
button.show()
self.window.show()
def main():
gtk.main()
return 0
if __name__ == "__main__":
ProgressBar()
main() |
Partager