Python, Tkinter, SQlite3 after login successful redirecting the user to a new window -
i'm new within programming , created following source code verify if user logs in successfully. want redirect user new window , rid of current window, after input correct credentials within entries. possible use top-level method this?
def is_valid(): usernamevalidity=username_entry.get() passwordvalidity=password_entry.get() cursor.execute('''select password users username = ?''', (usernamevalidity,)) cursor.execute('''select username users password = ?''', (passwordvalidity,)) loginattempt = cursor.fetchone()? print (is_valid) # testing if loginattempt: print (" 1 of accounts have logged in ") isvalidtext.config(text=" have logged in! ", fg="black", highlightthickness=1) else:? print (" 1 of accounts inputted wrong credentials! ") isvalidtext.config(text=" invalid username or password! ", fg="black", highlightthickness=1)
assuming program works point, more welcome use toplevel
method. include .after()
give time let user see message.
def newpage(): global newroot root.withdraw() # hide (close) root/tk window newroot = tk.toplevel(root) # use newroot root def is_valid(): # same before... if loginattempt: print (" 1 of accounts have logged in ") isvalidtext.config(text=" have logged in! ", fg="black", highlightthickness=1) root.after(2000, newpage) # or whatever tk called # redirect newpage function after 2 seconds else: print (" 1 of accounts inputted wrong credentials! ") isvalidtext.config(text=" invalid username or password! ", fg="black", highlightthickness=1)
this close original window , pop new blank window. note: .after(ms, callback)
uses ms, 2000ms = 2sec
and want rid of 2 random question marks after cursor.fetchone()
, else
.
Comments
Post a Comment