我有这段代码,它的作用是在物品按钮被按下时更改Instruction
标签的文本。由于某种原因,它并没有生效,并且我不完全确定原因。我尝试在press()
函数中创建另一个按钮,名称和参数相同,但文本不同。
import tkinter
import Theme
import Info
Tk = tkinter.Tk()
message = 'Not pressed.'
#Sets window Options
Tk.wm_title(Info.Title)
Tk.resizable(width='FALSE', height='FALSE')
Tk.wm_geometry("%dx%d%+d%+d" % (720, 480, 0, 0))
#Method run by item button
def press():
message = 'Button Pressed'
Tk.update()
#item button
item = tkinter.Button(Tk, command=press).pack()
#label
Instruction = tkinter.Label(Tk, text=message, bg=Theme.GUI_hl2, font='size, 20').pack()
#Background
Tk.configure(background=Theme.GUI_bg)
Tk.mainloop()
pack
的位置,因为该方法返回None
。点击这里获取更多信息。 - user2555451