python - 使用函数时如何在Tkinter中销毁小部件

标签 python user-interface tkinter error-handling

使用函数时,我无法在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
谁能告诉这个错误的解决方案

最佳答案

您可以使用def des(var)下的def(first)销毁

关于python - 使用函数时如何在Tkinter中销毁小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63091301/

相关文章:

python - Sklearn.LogisticRegression 是否添加一列 1?

python - tkinter.TclError : couldn't recognize data in image file 错误

python - Tkinter 如何在不使用字典的情况下制作动态选项菜单

python - Ambari 2.4.1.0 构建失败

Python2 : Should I use Pickle or cPickle?

来自网站的 Python 抓取表?

android - 像文件浏览器一样的选项卡

c++ - 如何将 VB 程序与 C++ 程序混合使用

android - 如何在首次和后续应用程序使用时呈现不同的 UI?

python - Tkinter 用 window 打开控制台窗口