Загрузка данных


import tkinter as tk
from tkinter import messagebox
import sys

def lock_screen():
    """Создает окно блокировки экрана."""

    def check_password():
        """Проверяет введенный пароль."""
        password = password_entry.get()
        if password == "12345":
            root.destroy()  # Закрывает окно блокировки, если пароль верен
            messagebox.showinfo("Внимание!", "Вы успешно разблокировали систему!")
            sys.exit(0) # Закрывает программу
        else:
            messagebox.showerror("Ошибка", "Неверный пароль!")
            password_entry.delete(0, tk.END)  # Очищает поле ввода
            password_entry.focus_set() # Возвращаем курсор в поле после ошибки

    root = tk.Tk()
    root.title("Внимание! Система заблокирована!")
    root.attributes('-fullscreen', True)  # Запускает в полноэкранном режиме
    root.attributes('-topmost', True)     # Поверх абсолютно всех окон

    # Удаляет рамку окна
    root.overrideredirect(True)

    # Создание фона
    background_color = "black"
    root.configure(bg=background_color)

    # Создание надписи
    label = tk.Label(root, text="Система заблокирована!", font=("Arial", 24, "bold"), fg="red", bg=background_color)
    label.pack(pady=50)

    # Дополнительный текст для подсказки учителю
    label_hint = tk.Label(root, text="Спокойно, это просто пранк :) Введите код", font=("Arial", 14), fg="white", bg=background_color)
    label_hint.pack(pady=10)

    # Создание поля ввода пароля
    password_entry = tk.Entry(root, show="*", font=("Arial", 20), width=20, justify="center")
    password_entry.pack(pady=20)
    
    # Решение бага с фокусом:
    root.focus_force()          # Принудительно заставляем ОС отдать фокус этому окну
    password_entry.focus_set()  # Ставим курсор в поле ввода

    # Создание кнопки "Разблокировать"
    unlock_button = tk.Button(root, text="Разблокировать", font=("Arial", 16), command=check_password)
    unlock_button.pack(pady=20)

    # Привязка Enter к кнопке "Разблокировать"
    root.bind('<Return>', lambda event=None: unlock_button.invoke())

    # Предотвращение закрытия окна
    root.protocol("WM_DELETE_WINDOW", lambda: None)

    # Анимация: меняем текст надписи
    animation_texts = ["Система заблокирована!", "Внимание! Система заблокирована!", "Срочно! Система заблокирована!"]
    animation_index = 0

    def animate_label():
        nonlocal animation_index
        label.config(text=animation_texts[animation_index])
        animation_index = (animation_index + 1) % len(animation_texts)
        root.after(500, animate_label)

    animate_label()
    root.mainloop()

if __name__ == "__main__":
    lock_screen()