Python tkinter页面未消失,destroy()不工作
我正在使用tkinter进行python gui应用程序开发 我想在用户扫描到新页面时消失一页。 我刚刚打开了一个新类的新对象,并希望通过destroy()将其消失,但destroy不起作用 代码-Python tkinter页面未消失,destroy()不工作,python,tkinter,Python,Tkinter,我正在使用tkinter进行python gui应用程序开发 我想在用户扫描到新页面时消失一页。 我刚刚打开了一个新类的新对象,并希望通过destroy()将其消失,但destroy不起作用 代码- import reg as r from tkinter import * import tkinter as tk LARGE_FONT = ("Verdana", 12) class Main(tk.Frame): def __init__(self, pare
import reg as r
from tkinter import *
import tkinter as tk
LARGE_FONT = ("Verdana", 12)
class Main(tk.Frame):
def __init__(self, parent):
tk.Frame.__init__(self, parent)
self.parent = parent
label = tk.Label(self, text="Tech Eye", font=LARGE_FONT)
label.pack()
self.button2 = Button(self.parent, text="Admin Registration", command=self.reg).place(x=260, y=300)
self.button3 = Button(self.parent, text="Exit", command=self.destroy).place(x=220, y=350)
#this destroy also not working
def reg(self):
new = tk.Tk()
new.geometry("600x600")
new.title("Third Eye")
self.destroy()
st = r.Registration(new)
#r is the another python file what i imported and Registration is the class
st.mainloop()
if __name__ == '__main__':
root = tk.Tk()
root.geometry("600x600")
root.title("Third Eye")
run = Main(root)
root.mainloop()
我现在能做什么?您不需要创建新的
Tk()
实例,只需使用root
进行注册类。销毁不起作用,看起来很奇怪。请查看此信息,然后尝试self.parent.destroy()
而不是self.destroy()
。