So, I am making a login system in python with tkinter and I want it to move to another page after the email and password have been validated. The only way I have found to do this is by using a button click command. I only want it to move on to the next page after the email and password have been validated. Thanks in advance.
from tkinter import *
class login:
def __init__(self, master, *args, **kwargs):
self.emailGranted = False
self.passwordGranted = False
self.attempts = 8
self.label_email = Label(text="email:", font=('Serif', 13))
self.label_email.grid(row=0, column=0, sticky=E)
self.label_password = Label(text="password:", font=('Serif', 13))
self.label_password.grid(row=1, column=0, sticky=E)
self.entry_email = Entry(width=30)
self.entry_email.grid(row=0, column=1, padx=(3, 10))
self.entry_password = Entry(width=30, show="•")
self.entry_password.grid(row=1, column=1, padx=(3, 10))
self.login = Button(text="Login", command=self.validate)
self.login.grid(row=2, column=1, sticky=E, padx=(0, 10), pady=(2, 2))
self.label_granted = Label(text="")
self.label_granted.grid(row=3, columnspan=3, sticky=N+E+S+W)
def validate(self):
self.email = self.entry_email.get()
self.password = self.entry_password.get()
if self.email == "email":
self.emailGranted = True
else:
self.emailGranted = False
self.label_granted.config(text="wrong email")
self.attempts -= 1
self.entry_email.delete(0, END)
if self.attempts == 0:
root.destroy()
if self.password == "password":
self.passwordGranted = True
else:
self.passwordGranted = False
self.label_granted.config(text="wrong password")
self.attempts -= 1
self.entry_password.delete(0, END)
if self.attempts == 0:
root.destroy()
if self.emailGranted is False and self.passwordGranted is False:
self.label_granted.config(text="wrong email and password")
if self.emailGranted is True and self.passwordGranted is True:
self.label_granted.config(text="access granted")
// I want it to move on to PageOne here but I'm not sure how
class PageOne:
def __init__(self, master, *args, **kwargs):
Button(text="it works").grid(row=0, column=0)
if __name__ == "__main__":
root = Tk()
root.resizable(False, False)
root.title("login")
login(root)
root.mainloop()