想要两个py文件之间互相切换,但是dateentry组件会出现错误_tkinter.TclError: bad window path name ".!dateentry.!entry",无法正常点击,而且出现多个窗口,单个py文件运行的话它是能够正常显示的运行的,一调用就不行,试过用toplevel,但是用了就销毁不了组件,程序退出后取消不了进程
下面这个是代码
test.py
import ttkbootstrap as ttk
class Test:
def __init__(self):
self.win = ttk.Window()
self.win.geometry("300x300")
self.test = ttk.DateEntry(self.win, bootstyle="success")
self.test.grid(row=0, column=0)
self.btn_back = ttk.Button(self.win,text="回上一页",command=self.back())
self.btn_back.grid(row=1,column=0)
self.win.mainloop()
def back(self):
import test1
test1.Test1()
self.win.destroy()
test1.py
import ttkbootstrap as ttk
class Test1:
def __init__(self):
self.win1 = ttk.Window(themename="minty")
self.win1.geometry("600x600")
self.btn = ttk.Button(self.win1, text="click", command=self.test)
self.btn.grid(row=0, column=0)
self.win1.mainloop()
def test(self):
import test
test.Test()
self.win1.destroy()
Test1()