异步,永不止步

【python】GTK 例子

# encoding:utf-8
# box_multi_button_data.py

import pygtk, gtk

def destroy(widget, data=None):
    gtk.main_quit()

def button1(widget, data=None):
    print 'WoW ~ You\'ve touch me successfully , enn ~ this is your datas : {}' .format(data)

class app:
    def __init__(self):
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window = window
        self.window.set_border_width(10)
        self.window.set_default_size(400, 10)
        window.connect("destroy",destroy)

    # def button2(self, name, cbevent):
    #     self.button = gtk.Button(name)
    #     self.button.connect("clicked",cbevent,None)
    #     self.window.add(self.button)
    #     self.button.show()

    def newbox(self):
        self.box1 = gtk.HBox(False, 0)
        self.window.add(self.box1)

    def newbutton(self,name,cbevent):
        b = gtk.Button(name)
        b.connect('clicked',cbevent,name)
        self.box1.pack_start(b, True, True, 0)
        b.show()

w = app()
# w.button2('TOUCH IT', button1)
w.newbox()
w.newbutton(u'1',button1)
w.newbutton(u'2',button1)

w.box1.show()
w.window.show()
gtk.main()

  

posted on 2016-03-03 10:34  gaopq  阅读(1682)  评论(0编辑  收藏  举报

导航