【发布时间】:2020-07-25 17:21:15
【问题描述】:
使用函数时我无法在 tkinter 中销毁小部件
def first():
photo1 = PhotoImage(file =r"file/start.png")
photoimage1 = photo1.subsample(5,5)
start=Button(root,
width=270,
text="LAUNCH",
font=("orbitron",25),
image=photoimage1,
compound="left",
bg="white",
activebackground="white",
command=lambda:launch(1))
def des(var):
start.destroy()
显示如下错误
NameError: name 'start' is not defined
谁能告诉这个错误的解决方法
【问题讨论】:
-
start是一个局部变量。 -
那么我怎样才能让它全球化
-
在你的
first()函数顶部说global start
标签: python user-interface tkinter error-handling