Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import ttk
- root = tkinter.Tk()
- root.geometry("800x600")
- root.wm_title("Registration Form")
- users = {"root": {
- "password": "dean",
- "group": "admin"}}
- def validate(form):
- if len(form) > 0:
- return False
- return True
- def authorize(username, password):
- if username in users:
- if password == users[username]["password"]:
- print("Login Successful!")
- return True
- return False
- def signin():
- while True:
- username = input("Username: ")
- if not len(username) > 0:
- print("Username can't be blank")
- else:
- break
- while True:
- password = input("Password: ")
- if not len(password) > 0:
- print("Password can't be blank")
- else:
- break
- if authorize(username, password):
- print("Welcome to the System.")
- else:
- print("Invalid username or password")
- def signup():
- while True:
- username = input("New username: ")
- if not len(username) > 0:
- print("Username can't be blank")
- continue
- else:
- break
- while True:
- password = input("New password: ")
- if not len(password) > 0:
- print("Password can't be blank")
- continue
- else:
- break
- users[username] = {}
- users[username]["password"] = password
- users[username]["group"] = "user"
- print("Account has been created")
- while True:
- option = input("> ")
- if option == "login":
- signin()
- elif option == "register":
- signup()
- elif option == "exit":
- break
- else:
- print(option + " is not an option")
Add Comment
Please, Sign In to add comment