Python-Ref > GUI programming with PyGTK > Glade UI designer > Hello Glade
 
 

^^->
Klíčová slova
Moduly
Knihovní funkce

Hello Glade

Expand/Shrink
Zdroj: (glade1-1.py)
  1   import pygtk
  2   pygtk.require("2.0")
  3   import gtk
  4   import gtk.glade
  5   
  6   class HelloGlade(object):
  7   
  8     def __init__(self):
  9       self.widgets = gtk.glade.XML("infiles/hello_glade.glade") 
 10       self.window = self.widgets.get_widget("window1")
 11       self.window.connect("destroy", gtk.main_quit)
 12       self.window.show()
 13   
 14   app = HelloGlade()
 15   gtk.main()
Screenshot:
Program screenshot glade1-1.png
Doba běhu: 2463.1 ms
Expand/Shrink
Zdroj: (glade1-2.py)
  1   import pygtk
  2   pygtk.require("2.0")
  3   import gtk
  4   import gtk.glade
  5   
  6   class HelloGlade(object):
  7   
  8     def __init__(self):
  9       self.widgets = gtk.glade.XML("infiles/hello_glade2.glade") 
 10       self.widgets.signal_autoconnect(self)
 11       self.window = self.widgets.get_widget("window1")
 12       self.window.connect("destroy", gtk.main_quit)
 13       self.window.show()
 14   
 15     def on_button1_clicked(self, w):
 16       print "Button 1 clicked"
 17   
 18     def on_button2_clicked(self, w):
 19       print "Button 2 clicked"
 20   
 21   
 22   app = HelloGlade()
 23   gtk.main()
stdout:
Button 1 clicked
Button 2 clicked
Screenshot:
Program screenshot glade1-2.png
Doba běhu: 1815.6 ms