/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import pygtk pygtk.require('2.0') import gtk import gobject class Base(gtk.Window): def __init__(self): gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL) self.connect('delete-event', self.on_win_delete_event) self.b = gtk.Button() self.b.set_label("Test bouton") self.b.connect('button-press-event', self.oncc) self.add(self.b) self.show_all() def loop(self): self.__inLoop=gobject.MainLoop() self.__inLoop.run() def on_win_delete_event(self,*args): self.destroy() gobject.MainLoop.quit(self.__inLoop) # quit the loop def oncc(self,widget,event): print "coucou" if __name__ == "__main__": base = Base() base.loop()