[英]Python Tkinter Button Appear at the First Window
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。你为什么不直接使用
.deiconify()
和.withdraw()
?你让它变得更复杂。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.