spoonfeeding
unknown
python
2 years ago
1.5 kB
4
Indexable
Never
# Imports import tkinter as tk from tkinter import ttk from tkinter.ttk import Label # Commands def authorise(entry_username, entry_password): """ Authorise a user's entry into the program. :param entry_username: The ttk.Entry object for the username :param entry_password: The ttk.Entry object for the password """ user = (entry_username.get("1.0","end")) passw = (entry_password.get("1.0","end")) if user == "Gracie" and passw == "Smudge25": print("Access Granted") elif user == "Callum" and passw == "Doggo": print("Acces Granted") else: print("Access Denied.") # Window root = tk.Tk("Authorisation") # Window Customisation root.title("User Authorisation") root.iconbitmap(bitmap = "User.ico") # Labels username = Label(text = "Please enter your username") username.grid(column = 0, row = 0) password = Label(text = "Please enter your password") password.grid(column = 0, row = 3) # Buttons quitButton = ttk.Button(root, text = "Quit", command = root.destroy) quitButton.grid(column = 1 , row = 1) authoriseButton = ttk.Button(root, text = "Authorise" , command = authorise) authoriseButton.grid(column = 1 , row = 4 ) # Text boxes usernameEnter = ttk.Entry(root) usernameEnter.grid(column = 0, row = 1) str(usernameEnter) passwordEnter = ttk.Entry(root) passwordEnter.grid(column = 0, row = 4) str(passwordEnter) # Main loop - Runs GUI root.mainloop()