Reputation: 813
I have a program with a class Client
I'm working on that has to transition between 2 states: "login" and "message". During the "login" state, I have a LoginFrame
(a simple login screen) that I'm displaying, but when I successfully login, I want to transition to MessageFrame
(the meat of the GUI). I'm still very new to tkinter and I'm unsure how to properly manage this transition, right now this is the code that I have:
class Client:
root = Tk
def __init__(self):
self.root = Tk()
self.prompt_login()
def prompt_login(self):
login = LoginFrame(self.root, self)
self.root.mainloop()
def login(self, username, password):
#perform login logic here
self.transition_to_msg()
def transition_to_msg(self):
mw = MessageFrame(self.root, self)
It is displaying the login window, but rather than transitioning, it just displays the MessageFrame under the login window.
My question is this:
Upvotes: 1
Views: 121
Reputation: 385960
Create two classes, both which inherit from Frame
. In one, put all the widgets for the login window. In the other, the widgets for the message window.
Use the first frame to fill the window. When you want to transition, destroy it and use the other to fill the window.
Upvotes: 1