嗨,我正在使用 Tkinter() 在 python 中开发单个登录,我只希望当用户正确登录时,登录 UI 将被隐藏并且内容 UI 将显示......所以我认为 ui 可以隐藏或者可见性将被隐藏?例如我有这个代码......
def httpGETCheck(username, password):
....
# assumed that the user is correct
if registeredUser:
# how can I hide or set visible is false to all the UI in the showLogin() Module
# and how can I show the showContent() UI or replaced the showContent() UI from showLogin() UI
class ContentUI():
def showContent(self, frame):
button1 = Button(frame, text="+", width=15, command=counterPlus)
button1.grid()
def showLogin(self, frame):
self.contentUI = ContentUI()
L1 = Label(frame, text="User Name")
L1.pack( side = LEFT)
L1.grid()
E1 = Entry(frame, bd =5)
E1.pack(side = RIGHT)
E1.grid()
L2 = Label(frame, text="Password")
L2.pack( side = LEFT)
L2.grid()
E2 = Entry(frame, bd =5, show="*")
E2.pack(side = RIGHT)
E2.grid()
submit = Button(frame, text="Login", width=15, command=lambda: httpGETCheck(E1.get(), E2.get()))
submit.grid()
class UIDisplay():
def play(self):
root = Tk()
root.title(title)
root.geometry(dimension)
app = Frame(root)
contentUI = ContentUI()
contentUI.showLogin(app)
app.grid()
root.mainloop()
ad = UIDisplay()
ad.play()