import tkinter as tk
from tkinter import simpledialog, messagebox
import random
CORRECT_PATTERN = [1, 5, 9, 8]
CORRECT_PASSWORD = "universe123"
CORRECT_PIN = "4567"
jokes = [
"Why do programmers prefer dark mode? Because light attracts bugs!",
"Why was the computer cold? It forgot to close its Windows!",
"Why did the coder quit his job? Because he didn’t get arrays.",
"How many programmers does it take to change a light bulb? None, it's a hardware problem.",
"Why do Java developers wear glasses? Because they can't C#.",
"What do you call 8 hobbits? A hobbyte.",
"I told my computer I needed a break, and it said: No problem, I'll go to sleep."
]
pattern = []
def show_joke():
messagebox.showinfo("Joke", random.choice(jokes))
def ask_pin():
pin = simpledialog.askstring("PIN", "Enter PIN:", show="*")
if pin == CORRECT_PIN:
messagebox.showinfo("Success", "Unlocked")
show_joke()
window.destroy()
else:
messagebox.showerror("Error", "Wrong PIN")
def ask_password():
password = simpledialog.askstring("Password", "Enter Password:", show="*")
if password == CORRECT_PASSWORD:
ask_pin()
else:
messagebox.showerror("Error", "Wrong Password")
def press(num):
pattern.append(num)
if len(pattern) == len(CORRECT_PATTERN):
if pattern == CORRECT_PATTERN:
messagebox.showinfo("Pattern", "Correct Pattern")
pattern.clear()
ask_password()
else:
messagebox.showerror("Pattern", "Incorrect Pattern")
pattern.clear()
window = tk.Tk()
window.title("Multi-Lock System")
window.geometry("300x380")
title = tk.Label(window, text="Draw Pattern", font=("Arial", 18))
title.pack(pady=10)
frame = tk.Frame(window)
frame.pack()
num = 1
for r in range(3):
for c in range(3):
btn = tk.Button(frame, text=str(num), width=10, height=4,
command=lambda n=num: press(n))
btn.grid(row=r, column=c)
num += 1
window.mainloop()