在customtkinter中创建新的顶层窗口时,我试图关闭顶层窗口。我在函数的末尾使用destroy()
来关闭它,但我得到了这个错误_tkinter.TclError: bad window path name ".!ctktoplevel.!ctkentry2.!entry"
。
有看一些问题,但他们是关于框架,按钮,标签,但还没有发现同样的错误,关于一个顶层窗口。
有人能帮我弄清楚如何解决这个pls?
先谢谢你了
def IDoptions(): #run first
global idoptions,input1,input2
idoptions = customtkinter.CTkToplevel(app, fg_color='#27333b')
idoptions.geometry("430x400") # size of window
idoptions.title('Pulley Selection') # tittle of the window
# pselection.iconbitmap('Itipack_icon_cmyk_rev_l.ico')
idoptions.resizable(False, False)
app.attributes('-topmost', False)
idoptions.attributes('-topmost', True)
idoptions.after(201, lambda:
idoptions.iconbitmap('Itipack_icon_cmyk_rev_l.ico'))
nextbutton = customtkinter.CTkButton(idoptions, width=100, height=28, text='Next', font=("Industry-Medium", 14),
corner_radius=1, fg_color='#00AAE9',command=run_table)
nextbutton.grid(row=20,column=2,padx=5,pady=5,sticky='e')
def run_table(): #run second
currenth=380
dashboard = customtkinter.CTkToplevel(app,fg_color='#27333b')
dashboard.geometry(f"450x{currenth}") #size of window
dashboard.title('Itipack Systems Cals') #tittle of the window
dashboard.attributes('-topmost', True) # note - before topmost
dashboard.resizable(False, False)
dashboard.after(201, lambda: dashboard.iconbitmap('Itipack_icon_cmyk_rev_l.ico'))
idoptions.destroy()
字符串
1条答案
按热度按时间brccelvz1#
错误消息
_tkinter.TclError: bad window path name ".!ctktoplevel.!ctkentry2.!entry"
意味着您正在尝试销毁一个不再存在的小部件。您还应该删除全局变量并通过函数调用传递它们。这将帮助您更容易地发现设计中的缺陷