Guest User

Untitled

a guest
Nov 9th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. import tkinter as tk
  2. def validate_login():
  3. userid = username_entry.get()
  4. password = password_entry.get()
  5.  
  6. if userid == "123" and password == "library":
  7. # Creates the libraary window one the correct userid and password are answered
  8.  
  9. def validate_choice():
  10. openName = opentions_entry.get()
  11.  
  12. if optionName.lower() == "withdraw":
  13. def validate_withdraw():
  14. wbook = withdraw_entry.get()
  15.  
  16. withdraw = tk.Tk()
  17. withdraw.title("Withdraw System")
  18. wbookname_label = tk.Label(withdraw, text="Book Name:")
  19. wbookname_label.pack()
  20.  
  21. wbookname_entry = tk.Entry(withdraw)
  22. wbookname_entry.pack(padx=70, pady=20)
  23. elif optionName.lower() == "return":
  24. def validate_return():
  25. rbook = return_entry.get()
  26.  
  27. return_book = tk.Tk()
  28. return_book.title("Return System")
  29. rbookname_label = tk.Label(return_book, text="Book Name:")
  30. rbookname_label.pack()
  31.  
  32. rbookname_entry = tk.Entry(return_book)
  33. rbookname_entry.pack(padx=70, pady=20)
  34. return_book.mainloop()
  35. else:
  36. messagebox.showerror("Invalid option", "Please try again")
  37. choice = tk.Tk()
  38. # optional extra 3: choice of withdrawing or returning a book
  39. choice.title("Withdraw or Return System")
  40.  
  41. options_label = tk.Label(choice, text="Would you like to withdraw or return a book?")
  42. options_label.pack()
  43.  
  44. options_entry = tk.Entry(choice)
  45. options_entry.pack(padx=70, pady=20)
  46. option_button = tk.Button(choice, text="Enter", command=validate_choice)
  47. option_button.pack(pady=20)
  48. choice.mainloop()
  49.  
  50. else:
  51. messagebox.showerror("Login Failed", "Invalid username or password")
  52.  
  53. # Creates the main window
  54. parent = tk.Tk()
  55. parent.title("Login Form")
  56.  
  57. # Creates and places the username label and entry
  58. username_label = tk.Label(parent, text="Userid:")
  59. username_label.pack()
Advertisement
Add Comment
Please, Sign In to add comment