Python赢得了';无法识别属性
我正在编写我的第一个GUI应用程序,为一家公司寻找产品Python赢得了';无法识别属性,python,oop,user-interface,tkinter,Python,Oop,User Interface,Tkinter,我正在编写我的第一个GUI应用程序,为一家公司寻找产品 from Tkinter import * import tkMessageBox def debug(): buttonText = relStatus.get() tkMessageBox.showinfo("You Clicked ", buttonText) return app = Tk() app.title("Ironcraft Product Finder") app.geometry("700x
from Tkinter import *
import tkMessageBox
def debug():
buttonText = relStatus.get()
tkMessageBox.showinfo("You Clicked ", buttonText)
return
app = Tk()
app.title("Ironcraft Product Finder")
app.geometry("700x500")
labelText = StringVar()
labelText.set("Choose an Appliance Type")
topLabel = Label(app, textvariable = labelText, height = 5).pack()
fire = Button(app, text="Fire", width=20, command=debug)
fire.pack(padx=10)
relStatus = StringVar()
relStatus.set(fire.text)
app.mainloop()
当我运行此命令时,它会显示错误消息:
AttributeError: Button instance has no attribute 'text'
但在“火”的创造中,它说
text="fire"
这不是一个属性吗?Tkinter模块有点旧了;
文本
值可通过项目查找访问:
relStatus.set(fire['text'])
请参阅Tkinter文档的第页。谢谢,我自己永远不会得到它:)
topLabel = Label(app, textvariable = labelText, height = 5).pack() # so topLabel is None
topLabel = Label(app, textvariable = labelText, height = 5)
topLabel.pack() # topLabel is Label