本文共 956 字,大约阅读时间需要 3 分钟。
# 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()
转载地址:https://blog.csdn.net/weixin_33283907/article/details/111922914 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!