I'm trying to make a GUI for a password storage and hashing system, but I have hit a roadblock. I am having 2 buttons, one to log in, and one to make an account. When the login button is clicked, a new tkinter window opens with the login page. however, the login button is supposed to show on the second page, but it doesn't, and I have no clue why. Here is the code for the full system:
import tkinter
from tkinter import*
username = ("Tom")
password = ("test")
usernameguess1 = ("")
passwordguess1 = ("")
def trylogin():
print ("Trying to login...")
if usernameguess.get() == username:
print ("Complete sucsessfull!")
messagebox.showinfo("Sucess ", "Successfully logged in.")
else:
print ("Error: (Incorrect value entered)")
messagebox.showinfo("Error", "Sorry, but your username or password is incorrect. Try again")
def loginpage():
#Gui Formatting
window = tkinter.Tk()
window.resizable(width=FALSE, height=FALSE)
window.title("HasherTest_V0.1 Login")
window.geometry("300x150")
#Username and password boxes
usernametext = tkinter.Label(window, text="Username:")
usernameguess = tkinter.Entry(window)
passwordtext = tkinter.Label(window, text="Password:")
passwordguess = tkinter.Entry(window, show="*")
usernameguess1 = usernameguess
#login button
attemptlogin = tkinter.Button(text="Login", command=trylogin)
usernametext.pack()
usernameguess.pack()
passwordtext.pack()
passwordguess.pack()
attemptlogin.pack()
window.mainloop()
#Gui Formatting (again)
window = tkinter.Tk()
window.resizable(width=FALSE, height=FALSE)
window.title("HasherTest_V0.1")
window.geometry("300x150")
loginbutton = tkinter.Button(text="Login", command=loginpage)
loginbutton.pack()
And here is the code for just the second window on its own. For some reason I have to import tkinter message boxes aswell, or my IDLE errors out.
import tkinter
from tkinter import *
from tkinter import messagebox
username = ("Tom")
password = ("test")
usernameguess1 = ("")
passwordguess1 = ("")
def trylogin():
print ("Trying to login...")
if usernameguess.get() == username:
print ("Complete sucsessfull!")
messagebox.showinfo("Sucess ", "Successfully logged in.")
else:
print ("Error: (Incorrect value entered)")
messagebox.showinfo("Error", "Sorry, but your username or password is incorrect. Try again")
#Gui Formatting
window = tkinter.Tk()
window.resizable(width=FALSE, height=FALSE)
window.title("HasherTest_V0.1 Login")
window.geometry("300x150")
#Username and password boxes
usernametext = tkinter.Label(window, text="Username:")
usernameguess = tkinter.Entry(window)
passwordtext = tkinter.Label(window, text="Password:")
passwordguess = tkinter.Entry(window, show="*")
usernameguess1 = usernameguess
#login button
attemptlogin = tkinter.Button(text="Login", command=trylogin)
usernametext.pack()
usernameguess.pack()
passwordtext.pack()
passwordguess.pack()
attemptlogin.pack()
window.mainloop()
Thanks for your help!