Return to Snippet

Revision: 17566
at September 9, 2009 17:22 by manatlan


Initial Code
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()

Initial URL

                                

Initial Description

                                

Initial Title
simple gtk window

Initial Tags
python

Initial Language
Python