Login and show menu items by if Login and show menu items by if tkinter tkinter

Login and show menu items by if


You could achieve something like what you're looking for with the below:

from tkinter import *class App:    def __init__(self, root):        self.root = root        self.public = Frame(self.root, borderwidth=1, relief="solid") #public, visible frame        self.hidden = Frame(self.root, borderwidth=1, relief="solid") #hidden, private frame        self.label1 = Label(self.public, text="This text and everything over here is public.") #this is inside the public frame and so is visible        self.entry1 = Entry(self.public) #so is this        self.label2 = Label(self.hidden, text="This text and everything over here is hidden and only appears after login.") #this one is in the hidden frame and so is private before login        self.button1 = Button(self.public, text="Login", command=self.command) #this is in the public frame        self.public.pack(side="left", expand=True, fill="both") #we pack the public frame on the left of the window        self.label1.pack() #then we pack all the widgets for both frames here and below        self.entry1.pack()        self.label2.pack()        self.button1.pack()    def command(self): #whenever the login button is pressed this is called        if self.button1.cget("text") == "Login" and self.entry1.get() == "password": #we check if the button is in login state or not and if the password is correct            self.hidden.pack(side="right", expand=True, fill="both") #if it is we pack the hidden frame which makes it and it's contents visible            self.button1.configure({"text": "Logout"}) #we then set the button to a logout state        elif self.button1.cget("text") == "Logout": #if the button is in logout state            self.hidden.pack_forget() #we pack_forget the frame, which removes it and it's contents from view            self.button1.configure({"text": "Login"}) #and then we set the button to login stateroot = Tk()App(root)root.mainloop()

This is fairly self explanatory and where it isn't I've explained what's happening.

This is just one way of many of achieving what it is you're looking for.

I'd also like to point out that login systems are complicated and if you're looking to use this for anything serious or as a package to sell then the way I have done this is not secure.

I'd recommend looking at other ways people handle sensitive information in tkinter.