simple gtk window


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import pygtk
  2. pygtk.require('2.0')
  3. import gtk
  4. import gobject
  5.  
  6. class Base(gtk.Window):
  7. def __init__(self):
  8. gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL)
  9. self.connect('delete-event', self.on_win_delete_event)
  10.  
  11. self.b = gtk.Button()
  12. self.b.set_label("Test bouton")
  13. self.b.connect('button-press-event', self.oncc)
  14.  
  15. self.add(self.b)
  16.  
  17. self.show_all()
  18.  
  19. def loop(self):
  20. self.__inLoop=gobject.MainLoop()
  21. self.__inLoop.run()
  22.  
  23. def on_win_delete_event(self,*args):
  24. self.destroy()
  25. gobject.MainLoop.quit(self.__inLoop) # quit the loop
  26.  
  27. def oncc(self,widget,event):
  28. print "coucou"
  29.  
  30. if __name__ == "__main__":
  31. base = Base()
  32. base.loop()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.