I wanted to create a multiple windows that can go back at the first window and can open another window.
I created a button that can transfer me to the first window but when I click the Go back Button, The Go Back Button also appear at the first window
from tkinter import *
class testing:
def __init__(self,root):
self.btn_Init(root)
def btn_Init(self,root):
self.btn = Button(root, text="Go back Login",command = lambda:window(root))
self.btn.pack()
class window:
def __init__(self,root):
root.config(bg='orange')
root.geometry("500x500")
self.btn_view = Button(root,text="View", bg='green',width=13,height=4,command =lambda:self.view_onclick(root))
self.btn_view.place(x=130,y=220)
def view_onclick(self,root):
self.top = testing(Toplevel(root))
root.withdraw()
root = Tk()
window(root)
root.mainloop()
change
class testing:
def __init__(self,root):
self.btn_Init(root)
def btn_Init(self,root):
self.btn = Button(root, text="Go back Login",command = lambda:window(root))
self.btn.pack()
to
class testing:
def __init__(self,root):
self.btn_Init(root)
def btn_Init(self,root):
self.btn = Button(root, text="Go back Login",command = lambda:window(root) and self.btn.pack_forget())
self.btn.pack()
But I think your code is very odd.
Why don't you just use .deiconify()
and .withdraw()
?You make it more complicated。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.