import tkinter as tk
from tkinter import messagebox
from PIL import Image, ImageTk
def open_login_window():
login_win = tk.Tk()
login_win.title("Вход в библиотеку")
login_win.geometry("350x600")
login_win.configure(bg="blue")
login_win.resizable(False, False)
tk.Label(login_win, text="Авторизация", bg="blue", fg="white",
font=("Arial", 20, "bold")).pack(pady=25)
tk.Label(login_win, text="Логин:", bg="blue", fg="white",
font=("Arial", 12)).pack()
entry_login = tk.Entry(login_win, font=("Arial", 12),
justify="center", width=25)
entry_login.pack(pady=5)
tk.Label(login_win, text="Пароль:", bg="blue", fg="white",
font=("Arial", 12)).pack()
entry_pass = tk.Entry(login_win, font=("Arial", 12),
show="*", justify="center", width=25)
entry_pass.pack(pady=5)
def check_login():
login = entry_login.get()
password = entry_pass.get()
if login == "1234" and password == "1234":
login_win.destroy()
open_library_window()
else:
messagebox.showerror("Ошибка", "Неверный логин или пароль!")
btn = tk.Button(login_win, text="Войти", bg="yellow", fg="black",
font=("Arial", 14, "bold"), width=15,
command=check_login, activebackground="#FFD700")
btn.pack(pady=20)
login_win.mainloop()
def open_library_window():
lib_win = tk.Tk()
lib_win.title("Библиотека")
lib_win.geometry("350x600")
lib_win.resizable(False, False)
try:
image = Image.open("NATALIA.jpg")
image = image.resize((350, 600))
bg_photo = ImageTk.PhotoImage(image)
except Exception as e:
messagebox.showerror("Ошибка", f"Не удалось загрузить NATALIA.jpg:\n{e}")
return
bg_label = tk.Label(lib_win, image=bg_photo)
bg_label.place(x=0, y=0, relwidth=1, relheight=1)
bg_label.image = bg_photo
tk.Label(lib_win, text="Личный кабинет",
font=("Arial", 18, "bold"),
bg="white", fg="black", padx=15, pady=5).place(
relx=0.5, y=25, anchor="center")
tk.Label(lib_win, text="Выберите любимый жанр",
font=("Arial", 13, "bold"),
bg="white", fg="darkblue", padx=10, pady=3).place(
relx=0.5, y=90, anchor="center")
genre_var = tk.StringVar(value="")
frame_genres = tk.Frame(lib_win, bg="white", bd=2, relief="ridge")
frame_genres.place(relx=0.5, rely=0.5, anchor="center")
genres = ["Фантастика", "Детектив", "Роман"]
for g in genres:
tk.Radiobutton(frame_genres, text=g, variable=genre_var, value=g,
font=("Arial", 12), bg="white", fg="black",
activebackground="white",
padx=10, pady=3).pack(anchor="w")
tk.Label(lib_win, text="Библиотека, Пищевая 10",
font=("Arial", 13, "bold"),
bg="white", fg="darkred", padx=10, pady=3).place(
relx=0.5, rely=0.95, anchor="center")
lib_win.mainloop()
if __name__ == "__main__":
open_login_window()