Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- def validate_login():
- userid = username_entry.get()
- password = password_entry.get()
- if userid == "123" and password == "library":
- # Creates the libraary window one the correct userid and password are answered
- def validate_choice():
- openName = opentions_entry.get()
- if optionName.lower() == "withdraw":
- def validate_withdraw():
- wbook = withdraw_entry.get()
- withdraw = tk.Tk()
- withdraw.title("Withdraw System")
- wbookname_label = tk.Label(withdraw, text="Book Name:")
- wbookname_label.pack()
- wbookname_entry = tk.Entry(withdraw)
- wbookname_entry.pack(padx=70, pady=20)
- elif optionName.lower() == "return":
- def validate_return():
- rbook = return_entry.get()
- return_book = tk.Tk()
- return_book.title("Return System")
- rbookname_label = tk.Label(return_book, text="Book Name:")
- rbookname_label.pack()
- rbookname_entry = tk.Entry(return_book)
- rbookname_entry.pack(padx=70, pady=20)
- return_book.mainloop()
- else:
- messagebox.showerror("Invalid option", "Please try again")
- choice = tk.Tk()
- # optional extra 3: choice of withdrawing or returning a book
- choice.title("Withdraw or Return System")
- options_label = tk.Label(choice, text="Would you like to withdraw or return a book?")
- options_label.pack()
- options_entry = tk.Entry(choice)
- options_entry.pack(padx=70, pady=20)
- option_button = tk.Button(choice, text="Enter", command=validate_choice)
- option_button.pack(pady=20)
- choice.mainloop()
- else:
- messagebox.showerror("Login Failed", "Invalid username or password")
- # Creates the main window
- parent = tk.Tk()
- parent.title("Login Form")
- # Creates and places the username label and entry
- username_label = tk.Label(parent, text="Userid:")
- username_label.pack()
Advertisement
Add Comment
Please, Sign In to add comment