[Solved] Tkinter – show dialog with options and change password buttons


So I had a little bit of a play around and I think this is what your after. I also changed your code a little bit as I always feel its best to put self infront of all widgets on multiclass applications.

import tkinter as tk

class FirstFrame(tk.Frame):
    def __init__(self, master, **kwargs):
        tk.Frame.__init__(self, master, **kwargs)
        self.pack()

        master.title("Enter password")
        master.geometry("300x200")
        self.status = tk.Label(self, fg='red')
        self.status.pack()
        self.lbl = tk.Label(self, text="Enter password")
        self.lbl.pack()
        self.pwd = tk.Entry(self, show="*")
        self.pwd.pack()
        self.pwd.focus()
        self.pwd.bind('<Return>', self.check)
        self.btn = tk.Button(self, text="Done", command=self.check)
        self.btn.pack()
        self.btn = tk.Button(self, text="Cancel", command=self.quit)
        self.btn.pack()

    def check(self, event=None):
      if self.pwd.get() == app.password:
        self.destroy() #destroy current window and open next
        self.app= SecondFrame(self.master)
      else:
        self.status.config(text="Wrong password")

class SecondFrame(tk.Frame):
#re organised a lot in here
    def __init__(self, master, **kwargs):
        tk.Frame.__init__(self, master, **kwargs)
        self.pack()
        master.title("Main application")
        master.geometry("600x400")
        self.c = tk.Button(self, text="Options", command=self.options_button)
        self.c.pack()
        self.e = tk.Entry(self.master, show="*")
    def options_button(self):
        self.e.pack()
        self.but1 = tk.Button(self, text="Change password", command=self.set_password)
        self.but1.pack()
    def set_password(self):
        app.password=self.e.get()

if __name__=="__main__":
    root = tk.Tk() #removed your mainframe class
    app=FirstFrame(root)
    #set an attribute of the application for the password
    #similar to a global variable
    app.password = "password"
    root.mainloop()

So with what I have done you get prompted for the password and if you get it right it goes to the next scree, then an options button appears and if it is clicked then an entry box appears allowing the user to change the password

7

solved Tkinter – show dialog with options and change password buttons