【发布时间】:2011-05-16 22:12:28
【问题描述】:
我希望以下两个脚本的输出相同。
但是当我执行 Script 1 时,按钮上没有图像。但是,脚本 2 运行良好。
脚本 1
from Tkinter import *
class fe:
def __init__(self,master):
self.b=Button(master,justify = LEFT)
photo=PhotoImage(file="mine32.gif")
self.b.config(image=photo,width="10",height="10")
self.b.pack(side=LEFT)
root = Tk()
front_end=fe(root)
root.mainloop()
脚本 2
from Tkinter import *
root=Tk()
b=Button(root,justify = LEFT)
photo=PhotoImage(file="mine32.gif")
b.config(image=photo,width="10",height="10")
b.pack(side=LEFT)
root.mainloop()
【问题讨论】:
标签: python image button tkinter