class Login(tk.Frame):
def __init__(self, parent, controller):
def switch():
e_name.delete(0, 'end')
e_password.delete(0, 'end')
controller.show_frame("Registration")
tk.Frame.__init__(self, parent)
self.controller = controller
self.configure(bg=white)
Title = tk.Label(self, text="Login", font=('Verdana 17 bold'), height = 1, width=20, anchor='nw', bg=seafoam, fg=white)
Title.pack(side="top", fill="x", pady=10)
def login():
global name
name = e_name.get()
password = e_password.get()
if name == '' or password == '':
messagebox.showwarning('data', 'Please fill in all fields')
e_name.delete(0,"end")
e_password.delete(0, "end")
else:
A = login_user(name, password)
if A == True:
e_name.delete(0,"end")
e_password.delete(0, "end")
controller.show_frame('Application')
else:
e_name.delete(0,"end")
e_password.delete(0, "end")
messagebox.showwarning('data', 'Wrong Name or Password')
t_name = tk.Label(self, text="Name *", width=5, height=1, font=('Ivy 10'), bg=white, anchor='nw')
t_name.place(x=10, y=50)
e_name = tk.Entry(self, width=25, justify='left', highlightthickness=1, relief="solid")
e_name.place(x=100, y=50)
l_password = tk.Label(self, text="Password *", height=1, font=('Ivy 10'), bg=white, anchor='nw')
l_password.place(x=10, y=110)
e_password = tk.Entry(self, width=25, justify='left', highlightthickness=1, relief="solid", show = "*")
e_password.place(x=100, y=110)
button1 = tk.Button(self, text="Login",
command=login, bg=seafoam, fg=white, font=('Ivy 10'))
button1.place(x=10, y=170)
button2 = tk.Button(self, text="Register here",
command=switch, bg=seafoam, fg=white, font=('Ivy 10'), relief='ridge')
button2.place(x=350, y=15)
class Application(tk.Frame):
def __init__(self, parent, controller):
def switch():
e_name.delete(0, 'end')
e_telephone.delete(0, 'end')
e_email.delete(0, 'end')
e_location.delete(0, 'end')
controller.show_frame("Login")
tk.Frame.__init__(self, parent)
self.controller = controller
self.configure(bg=white)
Title = tk.Label(self, text="Phonebook", font=('Verdana 17 bold'), height = 1, width=20, anchor='nw', bg=seafoam, fg=white)
Title.pack(side="top", fill="x", pady=10)
button = tk.Button(self, text="Logout",
command=switch, bg=seafoam, fg=white, font=('Ivy 8 bold'), relief='ridge', width=10, height=1)
button.place(x=400, y=15)
user = tk.Label(self, text=name)
user.place(x=300, y=15
I need the 'name' from the Login frame to pass to the Application frame. I have tried using global variables but that does not seem to be working. I mentioned Global variables outside the Login page as well inside it, but both don't work. I use the frame switching code from this Switch between two frames in tkinter?.
Thanks in advance.