【发布时间】:2016-05-02 01:25:48
【问题描述】:
我正在使用 pygtk...所以我想将图像放在使用 gtk.Table(4,5) 创建的表格的单元格中。数字是尺寸。
我所做的是创建按钮并将它们放入单元格中,然后我加载图像并将它们附加到按钮上,但它不起作用。 我有:
class D:
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_border_width(300)
self.table = gtk.Table(4, 5, True)
self.window.add(self.table)
button = gtk.Button("unicorn")
image = gtk.Image()
image.set_from_file("unicorn.png")
image.show()
button.set_image(image)
button.set_size_request(20,20)
self.table.attach(button, 0, 1, 0, 1)
button.show()
self.table.show()
self.window.show_all()
def main():
gtk.main()
return 0
if __name__ == "__main__":
D()
main()
【问题讨论】:
标签: python python-2.7 interface pygtk