Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'hcawe1'
- import tkinter as tk
- root=tk.Tk()
- root.geometry("300x200")
- root.title("TRSDatabase")
- w = 300
- h = 200
- ws = root.winfo_screenwidth() # width of the screen
- hs = root.winfo_screenheight() # height of the screen
- x = (ws/2) - (w/2)
- y = (hs/2) - (h/2) - 50
- root.geometry('%dx%d+%d+%d' % (w, h, x, y))
- def logonScreen():
- global StringV
- treeRoad=tk.Label(root,text="Tree Road\nSchool", justify='center')
- treeRoad.grid(row=0,columnspan=5)
- treeRoad.config(font=("bold", 28))
- userLabel=tk.Label(root, text="Username:")
- userLabel.grid(row=2,column=1,padx=10)
- userLabel.config(font=("Ariel", 14))
- userEntry=tk.Entry(root)
- userEntry.grid(row=2,column=2,columnspan=3,padx=25)
- passLabel=tk.Label(root, text="Password:")
- passLabel.grid(row=3,column=1,padx=10)
- passLabel.config(font=("Ariel", 14))
- passEntry=tk.Entry(root)
- passEntry.grid(row=3,column=2,columnspan=3,padx=25)
- passEntry.config(show="*")
- StringV = tk.StringVar()
- invalidLabel=tk.Label(root, textvariable=StringV)
- invalidLabel.grid(row=4,column=1,columnspan=2,padx=10)
- tk.Button(root,text="Enter",command=lambda:Login()).grid(row=4,column=4)
- root.bind("<KeyRelease-Return>",lambda x:Login(passEntry.get(),userEntry.get()))
- def Login(password,username):
- if username.lower() == 'leeman' and password == 'tree':
- print("worked")
- else:
- StringV.set("Invalid, please try again.")
- logonScreen()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement