# data[].attributes.attachment_link.readable_text
import tkinter as tk
from tkinter import messagebox
import random

# ------------------------------
# Seznam ����k��
# ------------------------------
students_all = [
    "Mgr. Tom���� Mili��ka",
    "Dagmar Fl��drov��",
    "Mgr. Vladislav V��lek",
    "Mgr. Romana Hude��kov��",
    "Ing. Roman K��iv��nek",
    "Mgr. Igor Stejskal",
    "Mgr Martina Sovov��",
    "Jaroslav J��cha",
    "Mgr. Lenka Sklen����ov��",
    "Mgr. Ivona T����skov��",
    "Mgr. Pavel Hartman",
    "PaedDr. Ji���� Pavelka",
    "Ing. Dalibor V��ch",
    "Mgr. Veronika Joskov��",
    "Ing. Pavel Roubal",
    "Ing. Veronika Novotn��",
    "Igr. Petr Lunga",
    "Mgr. Jan La��tovi��ka",
    "Marek Hrb����",
    "Bohum��r Soukup",
    "Mgr. Alena ����astn��",
    "Mgr. Ji���� Kraus",
    "Mgr Jan ��imek",
    "Mgr. Ter��zia Vondr����kov��",
    "Mgr. Ivana Dvo������kov��",
    "Jan Sl��de��ek"
]

# ------------------------------
# Hlavn�� aplikace
# ------------------------------
class LosovacApp:
    def __init__(self, root):
        self.root = root
        self.root.title("Losova�� ����k��")
        self.root.geometry("500x600")
        self.root.configure(bg="#1e1e1e")

        # Kopie seznamu pro losov��n��
        self.remaining = students_all.copy()
        self.drawn = []

        # Nadpis
        self.title = tk.Label(root, text="Losova�� ����k��",
                              font=("Arial", 18, "bold"),
                              fg="white", bg="#1e1e1e")
        self.title.pack(pady=10)

        # Vylosovan�� jm��no (velk�� uprost��ed)
        self.result_label = tk.Label(root, text="Klikni na LOSOVAT",
                                     font=("Arial", 20, "bold"),
                                     fg="#4CAF50", bg="#1e1e1e",
                                     wraplength=450, justify="center")
        self.result_label.pack(pady=30)

        # Tla����tko losovat
        self.draw_button = tk.Button(root, text="LOSOVAT",
                                     command=self.draw_student,
                                     font=("Arial", 14, "bold"),
                                     bg="#4CAF50", fg="white",
                                     padx=10, pady=5)
        self.draw_button.pack(pady=10)

        # Tla����tko RESET (kdykoliv b��hem losov��n��)
        self.reset_button = tk.Button(root, text="RESET",
                                      command=self.reset,
                                      font=("Arial", 12, "bold"),
                                      bg="#f44336", fg="white",
                                      padx=10, pady=5)
        self.reset_button.pack(pady=5)

        # Tla����tko restart (po dokon��en��)
        self.restart_button = tk.Button(root, text="Za����t znovu",
                                        command=self.reset,
                                        font=("Arial", 12),
                                        bg="#2196F3", fg="white")

        # Seznam vylosovan��ch
        self.list_label = tk.Label(root, text="Vylosovan�� ����ci:",
                                   font=("Arial", 12),
                                   fg="white", bg="#1e1e1e")
        self.list_label.pack(pady=(20, 5))

        self.listbox = tk.Listbox(root, width=50, height=15,
                                  bg="#2e2e2e", fg="white",
                                  selectbackground="#555")
        self.listbox.pack(pady=5)

    # ------------------------------
    # Losov��n�� ����ka
    # ------------------------------
    def draw_student(self):
        if not self.remaining:
            self.result_label.config(text="V��ichni byli vylosov��ni!", fg="orange")
            self.draw_button.config(state="disabled")
            self.restart_button.pack(pady=10)
            messagebox.showinfo("Hotovo", "V��ichni ����ci byli vylosov��ni.")
            return

        student = random.choice(self.remaining)
        self.remaining.remove(student)
        self.drawn.append(student)

        self.result_label.config(text=student, fg="#4CAF50")
        self.listbox.insert(tk.END, student)

    # ------------------------------
    # RESET / Restart
    # ------------------------------
    def reset(self):
        # potvrzen�� (voliteln�� ��� m����e�� odstranit)
        if not messagebox.askyesno("Reset", "Opravdu chce�� za����t znovu?"):
            return

        self.remaining = students_all.copy()
        self.drawn = []

        self.listbox.delete(0, tk.END)
        self.result_label.config(text="Klikni na LOSOVAT", fg="#4CAF50")
        self.draw_button.config(state="normal")
        self.restart_button.pack_forget()


# ------------------------------
# Spu��t��n�� aplikace
# ------------------------------
root = tk.Tk()
app = LosovacApp(root)
root.mainloop()

# data[].attributes.attachment_link.readable_text
import tkinter as tk
from tkinter import messagebox
import winsound

# --- Hlavn�� okno ---
root = tk.Tk()
root.title("��asova��")
root.geometry("400x400")
root.configure(bg="#1e1e1e")  # tmav�� pozad��

# --- Prom��nn�� ---
timer_running = False   # Stav, zda timer b������
time_left = 0          # Zb��vaj��c�� ��as v sekund��ch
after_id = None        # ID pro cancelov��n�� after

# --- Funkce pro aktualizaci ��asom��ry ---
def update_display():
    """Aktualizuje zobrazen�� zb��vaj��c��ho ��asu."""
    minutes = time_left // 60
    seconds = time_left % 60
    time_label.config(text=f"{minutes:02}:{seconds:02}")
    
    # Zm��na barvy pozad��, pokud zb��v�� m��n�� ne�� 10 sekund
    if time_left <= 10:
        time_label.config(fg="red")
    else:
        time_label.config(fg="white")

def countdown():
    """Funkce odpo����t��v��n��."""
    global time_left, timer_running, after_id
    if timer_running and time_left > 0:
        time_left -= 1
        update_display()
        after_id = root.after(1000, countdown)
    elif timer_running and time_left == 0:
        update_display()
        # Zvukov�� upozorn��n��
        winsound.Beep(1000, 1000)  # frekvence 1000 Hz, 1 sekunda
        messagebox.showinfo("��as vypr��el", "��asova�� skon��il!")
        timer_running = False

def start_timer():
    """Spust�� odpo����t��v��n��."""
    global timer_running, time_left
    if not timer_running:
        try:
            minutes = int(min_entry.get())
            seconds = int(sec_entry.get())
            time_left = minutes * 60 + seconds
            if time_left <= 0:
                messagebox.showwarning("Chyba", "Zadejte ��as v��t���� ne�� 0!")
                return
        except ValueError:
            messagebox.showwarning("Chyba", "Zadejte platn�� ����sla!")
            return
        timer_running = True
        update_display()
        countdown()

def pause_timer():
    """Pozastav�� odpo����t��v��n��."""
    global timer_running
    timer_running = False
    if after_id is not None:
        root.after_cancel(after_id)

def reset_timer():
    """Resetuje ��asova�� na nulu a zastav�� odpo����t��v��n��."""
    global timer_running, time_left
    timer_running = False
    time_left = 0
    update_display()
    time_label.config(fg="white")

# --- GUI prvky ---
# Zad��n�� minut a sekund
input_frame = tk.Frame(root, bg="#1e1e1e")
input_frame.pack(pady=20)

min_label = tk.Label(input_frame, text="Minuty:", bg="#1e1e1e", fg="white", font=("Arial", 12))
min_label.grid(row=0, column=0, padx=5)
min_entry = tk.Entry(input_frame, width=5, font=("Arial", 12))
min_entry.grid(row=0, column=1, padx=5)

sec_label = tk.Label(input_frame, text="Sekundy:", bg="#1e1e1e", fg="white", font=("Arial", 12))
sec_label.grid(row=0, column=2, padx=5)
sec_entry = tk.Entry(input_frame, width=5, font=("Arial", 12))
sec_entry.grid(row=0, column=3, padx=5)

# Zobrazen�� ��asom��ry
time_label = tk.Label(root, text="00:00", font=("Arial", 60), bg="#1e1e1e", fg="white")
time_label.pack(expand=True)

# Tla����tka
button_frame = tk.Frame(root, bg="#1e1e1e")
button_frame.pack(pady=20)

start_btn = tk.Button(button_frame, text="Start", command=start_timer, width=10, bg="#4caf50", fg="white", font=("Arial", 12))
start_btn.grid(row=0, column=0, padx=5)

pause_btn = tk.Button(button_frame, text="Pauza", command=pause_timer, width=10, bg="#ff9800", fg="white", font=("Arial", 12))
pause_btn.grid(row=0, column=1, padx=5)

reset_btn = tk.Button(button_frame, text="Reset", command=reset_timer, width=10, bg="#f44336", fg="white", font=("Arial", 12))
reset_btn.grid(row=0, column=2, padx=5)

# --- Spu��t��n�� hlavn�� smy��ky ---
root.mainloop()

# data[].attributes.attachment_link.readable_text
import random
import copy

SIZE = 9
EMPTY = 0


def print_board(board):
    print("\n   0 1 2   3 4 5   6 7 8")
    for i in range(SIZE):
        if i % 3 == 0:
            print("  +-------+-------+-------+")
        print(i, "|", end=" ")
        for j in range(SIZE):
            if j % 3 == 0 and j != 0:
                print("|", end=" ")
            print(board[i][j] if board[i][j] != 0 else ".", end=" ")
        print("|")
    print("  +-------+-------+-------+")


def find_empty(board):
    for i in range(SIZE):
        for j in range(SIZE):
            if board[i][j] == EMPTY:
                return i, j
    return None


def valid(board, row, col, num):
    for i in range(SIZE):
        if board[row][i] == num or board[i][col] == num:
            return False

    box_x = col // 3
    box_y = row // 3

    for i in range(box_y * 3, box_y * 3 + 3):
        for j in range(box_x * 3, box_x * 3 + 3):
            if board[i][j] == num:
                return False

    return True


def solve(board):
    empty = find_empty(board)
    if not empty:
        return True

    row, col = empty

    nums = list(range(1, 10))
    random.shuffle(nums)

    for num in nums:
        if valid(board, row, col, num):
            board[row][col] = num
            if solve(board):
                return True
            board[row][col] = EMPTY

    return False


def generate():
    board = [[0 for _ in range(SIZE)] for _ in range(SIZE)]
    solve(board)
    return board


def make_puzzle(board, holes=45):
    puzzle = copy.deepcopy(board)
    removed = 0
    while removed < holes:
        r = random.randint(0, 8)
        c = random.randint(0, 8)
        if puzzle[r][c] != 0:
            puzzle[r][c] = 0
            removed += 1
    return puzzle


def play():
    solution = generate()
    puzzle = make_puzzle(solution)

    while True:
        print_board(puzzle)

        if not find_empty(puzzle):
            print("���� Hotovo! Vy��e��il jsi Sudoku.")
            break

        try:
            r = int(input("����dek (0-8): "))
            c = int(input("Sloupec (0-8): "))
            n = int(input("����slo (1-9): "))
        except:
            print("Neplatn�� vstup.")
            continue

        if r not in range(9) or c not in range(9) or n not in range(1, 10):
            print("Mimo rozsah.")
            continue

        if solution[r][c] == n:
            puzzle[r][c] = n
            print("Spr��vn��!")
        else:
            print("��patn��!")


if __name__ == "__main__":
    play()

# data[].attributes.attachment_link.readable_text
import tkinter as tk
from tkinter import messagebox
import random
import json

# ================== NASTAVEN�� ==================

BACKGROUND = "#ffeaf4"
BUTTON_COLOR = "#ff4da6"
TEXT_COLOR = "#000000"
FONT_MAIN = ("Helvetica", 14)
FONT_TITLE = ("Helvetica", 20, "bold")

TIME_LIMIT = 15
TOTAL_QUESTIONS = 20
LEADERBOARD_FILE = "leaderboard.json"

# ================== OT��ZKY (20) ==================

QUESTIONS = [
    {
        "question": "Kdo napsal Harryho Pottera?",
        "options": ["J. R. R. Tolkien", "J. K. Rowling", "Lewis Carroll", "Stephen King"],
        "answer": "J. K. Rowling"
    },
    {
        "question": "Autor knihy Mal�� princ je:",
        "options": ["Jules Verne", "Antoine de Saint-Exup��ry", "Victor Hugo", "Moli��re"],
        "answer": "Antoine de Saint-Exup��ry"
    },
    {
        "question": "Kniha 1984 pat���� do ����nru:",
        "options": ["Fantasy", "Rom��n", "Dystopie", "Poh��dka"],
        "answer": "Dystopie"
    },
    {
        "question": "Kdo napsal P��chu a p��edsudek?",
        "options": ["Jane Austen", "Emily Bront��", "Virginia Woolf", "Mary Shelley"],
        "answer": "Jane Austen"
    },
    {
        "question": "Kdo je autor Hobita?",
        "options": ["Tolkien", "Rowlingov��", "Lewis", "Martin"],
        "answer": "Tolkien"
    },
    {
        "question": "Jak�� ����nr je detektivka?",
        "options": ["Romantick��", "Nap��nav��", "Poh��dkov��", "Sci-fi"],
        "answer": "Nap��nav��"
    },
    {
        "question": "Kdo napsal Zlo��in a trest?",
        "options": ["Tolstoj", "Dostojevskij", "��echov", "Gogol"],
        "answer": "Dostojevskij"
    },
    {
        "question": "Autor knihy Proces:",
        "options": ["Kafka", "Camus", "Sartre", "Hesse"],
        "answer": "Kafka"
    },
    {
        "question": "Jak�� ����nr m�� kniha P��n prsten��?",
        "options": ["Sci-fi", "Fantasy", "Rom��n", "Horor"],
        "answer": "Fantasy"
    },
    {
        "question": "Kdo napsal Alenku v ������i div��?",
        "options": ["Lewis Carroll", "Rowling", "Tolkien", "Verne"],
        "answer": "Lewis Carroll"
    },
    {
        "question": "Kdo napsal knihu Romeo a Julie?",
        "options": ["Shakespeare", "Dickens", "Hemingway", "Tolstoj"],
        "answer": "Shakespeare"
    },
    {
        "question": "Kdo je autorem knihy Ostrov poklad��?",
        "options": ["Robert Louis Stevenson", "Mark Twain", "Jules Verne", "H. G. Wells"],
        "answer": "Robert Louis Stevenson"
    },
    {
        "question": "Kniha Mal�� princ je:",
        "options": ["Rom��n", "Poh��dka", "Bajka", "Sci-fi"],
          "answer": "Poh��dka"
    },
    {
        "question": "Autor knihy Frankenstein je:",
        "options": ["Mary Shelley", "Bram Stoker", "Jane Austen", "Emily Bront��"],
        "answer": "Mary Shelley"
    },
    {
        "question": "Kdo napsal knihu Anna Karenina?",
        "options": ["Tolstoj", "Dostojevskij", "Gogol", "��echov"],
        "answer": "Tolstoj"
    },
    {
        "question": "Autor knihy Moby Dick je:",
        "options": ["Herman Melville", "Jack London", "Steinbeck", "Orwell"],
        "answer": "Herman Melville"
    },
    {
        "question": "Kdo napsal knihu Oliver Twist?",
        "options": ["Charles Dickens", "Mark Twain", "Jules Verne", "Lewis Carroll"],
        "answer": "Charles Dickens"
    },
    {
        "question": "Jak�� ����nr m�� kniha Hobbit?",
        "options": ["Fantasy", "Sci-fi", "Rom��n", "Detektivka"],
        "answer": "Fantasy"
    },
    {
        "question": "Kdo napsal knihu Dr��kula?",
        "options": ["Bram Stoker", "Mary Shelley", "Tolstoj", "Shakespeare"],
        "answer": "Bram Stoker"
    },
    {
        "question": "Autor knihy P��n much je:",
        "options": ["William Golding", "George Orwell", "H. G. Wells", "Mark Twain"],
        "answer": "William Golding"
    # dal����ch 10 jednoduch��ch, ale platn��ch
    }
    ]
# ================== LEADERBOARD ==================

def load_leaderboard():
    try:
        with open(LEADERBOARD_FILE, "r", encoding="utf-8") as f:
            return json.load(f)
    except:
        return []

def save_leaderboard(data):
    with open(LEADERBOARD_FILE, "w", encoding="utf-8") as f:
        json.dump(data, f, indent=4, ensure_ascii=False)

# ================== HLAVN�� T����DA ==================

class QuizGame:
    def __init__(self, root):
        self.root = root
        self.root.title("���� R����ov�� kv��z pro dva hr����e ����")
        self.root.geometry("800x650")
        self.root.configure(bg=BACKGROUND)

        self.players = []
        self.scores = [0, 0]
        self.current_player = 0

        max_questions = min(TOTAL_QUESTIONS, len(QUESTIONS))
        self.questions = random.sample(QUESTIONS, max_questions)
        self.current_question = 0
        self.time_left_total = [0, 0]  # sou��et zb��vaj��c��ho ��asu pro ka��d��ho hr����e
        self.timer_id=None
        self.timer = TIME_LIMIT
        self.timer_running = False

        self.create_start_screen()
    def clear_screen(self):
            for w in self.root.winfo_children():
                w.destroy()
    # ================== START ==================

    def create_start_screen(self):
        self.current_question = 0  # reset indexu
        self.scores = [0, 0]       # reset sk��re
        self.time_left_total = [0, 0]  # reset ��as��
        self.clear_screen()
        self.title_label = tk.Label(self.root,
                            text="���� Kni��n�� kv��z pro 2 hr����e ����",
                            font=FONT_TITLE,
                            bg=BACKGROUND,
                            fg=TEXT_COLOR)
        self.title_label.pack(pady=20)

        self.animate_title()

        self.p1 = tk.Entry(self.root, font=FONT_MAIN)
        self.p2 = tk.Entry(self.root, font=FONT_MAIN)

        tk.Label(self.root, text="Hr���� 1").pack()
        self.p1.pack()
        tk.Label(self.root, text="Hr���� 2").pack()
        self.p2.pack()

        tk.Button(self.root, text="Za����t hru ����",
                  bg=BUTTON_COLOR, font=FONT_MAIN,
                  command=self.start_game).pack(pady=20)
    def animate_title(self):
    # zkontrolujeme, ��e widget existuje
        if not hasattr(self, "title_label"):
            return
        try:
            current_color = self.title_label.cget("fg")
            if current_color == "#5a0033":
                self.title_label.config(fg="#ff4da6")
            else:
                self.title_label.config(fg="#5a0033")
            self.root.after(700, self.animate_title)
        except tk.TclError:
        # widget u�� byl smaz��n
            return     


    def start_game(self):
        if not self.p1.get() or not self.p2.get():
            messagebox.showerror("Chyba", "Zadejte ob�� jm��na!")
            return

        self.players = [self.p1.get(), self.p2.get()]
        self.current_question = 0  # reset indexu p��i startu hry
        if not self.questions:
            messagebox.showerror("Chyba", "����dn�� ot��zky k dispozici!")
            return

        self.show_question()

    # ================== OT��ZKY ==================

    def show_question(self):
        if self.current_question >= len(self.questions):
            self.end_game()
            return
        self.clear_screen()
        self.timer = TIME_LIMIT
        self.timer_running = True

        self.draw_book()

        q = self.questions[self.current_question]

        self.timer_label = tk.Label(self.root, text=f"��� {self.timer}",
                                    font=FONT_MAIN, bg=BACKGROUND, fg=TEXT_COLOR)
        self.timer_label.pack()

        tk.Label(self.root,
                 text=f"{self.players[self.current_player]} odpov��d��:",
                 font=FONT_MAIN, bg=BACKGROUND, fg=TEXT_COLOR).pack(pady=5)

        tk.Label(self.root, text=q["question"],
                 font=FONT_MAIN, bg=BACKGROUND,fg=TEXT_COLOR,
                 wraplength=600).pack(pady=10)

        self.answer_var = tk.StringVar()

        for opt in q["options"]:
            tk.Radiobutton(self.root,
                   text=opt,
                   variable=self.answer_var,
                   value=opt,
                   bg=BACKGROUND,
                   fg=TEXT_COLOR,
                   selectcolor="#ffd6ec",
                   activebackground=BACKGROUND,
                   font=FONT_MAIN).pack(anchor="w", padx=200)

        tk.Button(self.root, text="Odpov��d��t",
                  bg=BUTTON_COLOR,
                  command=self.check_answer).pack(pady=10)

        self.countdown()

    def countdown(self):
        if self.timer_running and self.timer > 0:
            self.timer_label.config(text=f"��� {self.timer}")
            self.timer -= 1
            self.timer_id = self.root.after(1000, self.countdown)
        elif self.timer == 0:
            self.next_question()

    def check_answer(self):
        if self.timer_running:
            self.timer_running = False
            if self.timer_id:
                self.root.after_cancel(self.timer_id)
        # P��i��teme zb��vaj��c�� ��as k celkov��mu ��asu hr����e
            self.time_left_total[self.current_player] += self.timer

            correct = self.answer_var.get() == self.questions[self.current_question]["answer"]
            if correct:
                self.scores[self.current_player] += 1

            self.show_result_icon(correct)

        # deaktivace odpov��d��
            for widget in self.root.winfo_children():
                if isinstance(widget, tk.Radiobutton) or isinstance(widget, tk.Button):
                    widget.config(state="disabled")

        # tla����tko pokra��ovat
            self.continue_button = tk.Button(
                self.root,
                text="Pokra��ovat ���",
                bg="#ff4da6",
                fg="black",
                activebackground="#e60073",
                activeforeground="black",
                relief="flat",
                bd=0,
                font=("Helvetica", 14, "bold"),
                command=self.go_to_next_question
            )
            self.continue_button.pack(pady=15)
        
    def go_to_next_question(self):
        self.next_question()
        
    def next_question(self):
        self.timer_running = False
        if self.timer_id:
            self.root.after_cancel(self.timer_id)

        self.current_player = 1 - self.current_player
        self.current_question += 1

        if self.current_question < len(self.questions):
            self.show_question()
        else:
            self.end_game()

    # ================== Kniha ���� ==================
    def draw_book(self):
        self.canvas = tk.Canvas(self.root, width=800, height=450,
                            bg=BACKGROUND, highlightthickness=0)
        self.canvas.pack(pady=20)

    # ===== ST��N =====
        self.canvas.create_oval(240, 340, 560, 380,
                            fill="#e5c6d6", outline="")

    # ===== LEV�� STR��NKA (statick��) =====
        self.canvas.create_polygon(
            250, 150,
            400, 130,
            400, 330,
            250, 350,
            fill="#fff6fb",
            outline="#5a0033",
            width=2
        )

    # ===== PRAV�� STR��NKA (pozad��) =====
        self.canvas.create_polygon(
            400, 130,
            550, 150,
            550, 350,
            400, 330,
            fill="#fff6fb",
            outline="#5a0033",
            width=2
        )

    # ===== H��BET =====
        self.canvas.create_rectangle(395, 130, 405, 330,
                                 fill="#ffb6d9", outline="")

    # ===== LISTUJ��C�� STR��NKA =====
        self.page = self.canvas.create_polygon(
            400, 130,
            550, 150,
            550, 350,
            400, 330,
            fill="#ffeaf4",
            outline="#ff9acb",
            width=2
        )

        self.flip_step = 0
        self.flip_page()
        self.left_page_center_x = 325
        self.left_page_center_y = 240
    def flip_page(self):
        if not hasattr(self, "canvas"):
            return

        progress = self.flip_step
        total_steps = 25

    # pom��r pohybu 0 ��� 1
        t = progress / total_steps

    # po����te��n�� prav�� str��nka
        right_start = 400
        right_end = 550

    # c��lov�� lev�� str��nka
        left_start = 250
        left_end = 400

    # interpolace mezi pravou a levou stranou
        new_left = right_start + (left_start - right_start) * t
        new_right = right_end + (left_end - right_end) * t

    # efekt lehk��ho ohybu
        bend = 30 * (1 - abs(0.5 - t) * 2)

        new_coords = [
            new_left, 130,
            new_right, 150 + bend,
            new_right, 350 - bend,
            new_left, 330
        ]

        self.canvas.coords(self.page, *new_coords)

        self.flip_step += 1

        if self.flip_step <= total_steps:
            self.root.after(25, self.flip_page)
        else:
        # Str��nka z��stane vlevo
            self.canvas.coords(
                self.page,
                250, 150,
                400, 130,
                400, 330,
                250, 350
            )
    def show_result_icon(self, correct):
        if not hasattr(self, "canvas"):
            print("Canvas neexistuje")
            return
        print("Kresl��m ikonu")


        symbol = "���" if correct else "���"
        color = "green" if correct else "red"

        self.result_icon = self.canvas.create_text(
            self.left_page_center_x,
            self.left_page_center_y,
            text=symbol,
            font=("Helvetica", 120, "bold"),
            fill=color
        )

        self.canvas.tag_raise(self.result_icon)
    def end_game(self):
        self.clear_screen()

    # Nadpis
        tk.Label(self.root, text="���� Konec hry ����",
             font=FONT_TITLE, bg=BACKGROUND, fg=TEXT_COLOR).pack(pady=20)

    # Zobraz��me sk��re aktu��ln��ch hr������
        for i in range(2):
            tk.Label(self.root,
                 text=f"{self.players[i]}: {self.scores[i]} bod��, zb��vaj��c�� ��as {self.time_left_total[i]} s",
                 font=FONT_MAIN,
                 bg=BACKGROUND,
                 fg=TEXT_COLOR).pack()

    # --------- Na��ten�� leaderboardu ---------
        leaderboard = load_leaderboard()

    # P��id��me oba hr����e aktu��ln�� hry
        for i in range(2):
            leaderboard.append({
                "name": self.players[i],
                "score": self.scores[i],
                "time_left": self.time_left_total[i]
            })

    # Se��ad��me: nejd����ve podle sk��re sestupn��, pak podle zb��vaj��c��ho ��asu sestupn��
        leaderboard = sorted(
            leaderboard,
            key=lambda x: (x["score"], x.get("time_left", 0)),  # pou��it�� get pro ��as, pokud chyb��, vrac�� 0
            reverse=True
        )

    # Ulo����me pouze top 10
        leaderboard = leaderboard[:10]
        save_leaderboard(leaderboard)

    # --------- Zobrazen�� leaderboardu ---------
        tk.Label(self.root, text="���� Top 10 hr������ ����",
             font=FONT_TITLE, bg=BACKGROUND, fg=TEXT_COLOR).pack(pady=20)

    # Hlavi��ka tabulky
        header = tk.Frame(self.root, bg=BACKGROUND)
        header.pack()
        tk.Label(header, text="Jm��no", font=("Helvetica", 14, "bold"), width=20, bg=BACKGROUND, fg=TEXT_COLOR).grid(row=0, column=0)
        tk.Label(header, text="Body", font=("Helvetica", 14, "bold"), width=10, bg=BACKGROUND, fg=TEXT_COLOR).grid(row=0, column=1)
        tk.Label(header, text="Zb��vaj��c�� ��as", font=("Helvetica", 14, "bold"), width=15, bg=BACKGROUND, fg=TEXT_COLOR).grid(row=0, column=2)

    # ����dky hr������
        for entry in leaderboard:
            row = tk.Frame(self.root, bg=BACKGROUND)
            row.pack()
            tk.Label(row, text=entry["name"], font=FONT_MAIN, width=20, anchor="w", bg=BACKGROUND, fg=TEXT_COLOR).grid(row=0, column=0)
            tk.Label(row, text=entry["score"], font=FONT_MAIN, width=10, bg=BACKGROUND, fg=TEXT_COLOR).grid(row=0, column=1)
            tk.Label(row, text=entry.get("time_left", 0), font=FONT_MAIN, width=15, bg=BACKGROUND, fg=TEXT_COLOR).grid(row=0, column=2)

    # --------- Tla����tko hr��t znovu ---------
        tk.Button(self.root, text="Hr��t znovu",
              bg=BUTTON_COLOR, fg="black",
              font=FONT_MAIN,
              command=self.create_start_screen).pack(pady=20)
    

# ================== SPU��T��N�� ==================

root = tk.Tk()
QuizGame(root)
root.mainloop()

# data[].attributes.attachment_link.readable_text
from tkinter import *
from tkinter.font import Font
from tkinter import filedialog
import pickle
from tkinter import ttk
from datetime import datetime
from tkinter import messagebox

root = Tk()
root.title('��koln����ek')
root.geometry("500x500")

# font
my_font = Font()     
size=30,
weight="bold",

my_frame = Frame(root)
my_frame.pack(pady=10)


#listbox
my_list = Listbox(my_frame,
    font=my_font,
    width=25,
    height=5,
    bg="SystemButtonFace",
    bd=0,
    fg="#464646",


    )

my_list.pack(side=LEFT, fill=BOTH)

#list
stuff = ["J��t Se Psem", "J��t Na N��kup","D��t Si ��lof����ek","Nau��it Se Python","Vl��dnout Sv��tu"]
#add list to listbox
for item in stuff:
    my_list.insert(END,item)

# create scrollbar
my_scrollbar = Scrollbar(my_frame)
my_scrollbar.pack(side=RIGHT, fill=BOTH)

# add scrollbar
my_list.config(yscrollcommand=my_scrollbar.set)
my_scrollbar.config(command=my_list.yview)

# DATA - ��koly jako (text, kategorie, priorita)
tasks = []
alerted_tasks = []
categories = ["��kola", "Dom��cnost", "Pr��ce", "Osobn��", "Ostatn��"]
category_var = StringVar(value="��kola")
filter_category_var = StringVar(value="V��e")
priorities = ['N', 'S', 'V']
priority_var = StringVar(value='N')
filter_priority_var = StringVar(value="V��e")

# v��choz�� ��koly
default_tasks = [
    ("J��t Se Psem", "Dom��cnost", 'S', None),
    ("J��t Na N��kup", "Dom��cnost", 'S', None),
    ("D��t Si ��lof����ek", "Osobn��", 'N', None),
    ("Nau��it Se Python", "��kola", 'V', None),
    ("Vl��dnout Sv��tu", "Osobn��", 'V', None)
]
tasks.extend(default_tasks)
def refresh_listbox(filter_category=None):
    my_list.delete(0, END)

    for task in tasks:
        if len(task) == 3:
            text, cat, priority = task
            due_date = None
        else:
            text, cat, priority, due_date = task

        if filter_category is None or filter_category == "V��e" or cat == filter_category:
            my_list.insert(END, f"{text}")
            index = my_list.size() - 1

            if priority == "V":
                my_list.itemconfig(index, fg="#d62828")
            elif priority == "S":
                my_list.itemconfig(index, fg="#f77f00")
            elif priority == "N":
                my_list.itemconfig(index, fg="#2a9d8f")

Label(root, text="Term��n (RRRR-MM-DD HH:MM):").pack()
due_entry = Entry(root)
due_entry.pack(pady=5)

def check_deadlines():
    now = datetime.now()

    for text, cat, priority, due_date in tasks:
        if due_date and text not in alerted_tasks:
            try:
                deadline = datetime.strptime(due_date, "%Y-%m-%d %H:%M")
                if now >= deadline:
                    messagebox.showwarning("Upozorn��n��!", f"��kol '{text}' m�� term��n pr��v�� te��!")
                    alerted_tasks.append(text)  # zapamatujeme si ho
            except:
                pass

    root.after(60000, check_deadlines)


# combobox kategorie pro nov�� ��kol
category_box = ttk.Combobox(root, textvariable=category_var, values=categories, state="readonly")
category_box.pack(pady=5)
priority_box = ttk.Combobox(root, textvariable=priority_var, values=priorities, state='readonly')
priority_box.pack(pady=5)

# combobox filtr
filter_categories = ["V��e"] + categories
filter_box = ttk.Combobox(root, textvariable=filter_category_var, values=filter_categories, state="readonly")
filter_box.pack(pady=5)
filter_box.bind("<<ComboboxSelected>>", lambda e: refresh_listbox(filter_category_var.get()))

# prvn�� zobrazen��
refresh_listbox()

# create entry box to add items to the list
my_entry = Entry(root, font=("Helvetica", 24),width=24)
my_entry.pack(pady=20)

# create a button frame
button_frame = Frame (root)
button_frame.pack(pady=20)


# FUNCTIONS
def delete_item():
    my_list.delete(ANCHOR)

def add_item():
    text = my_entry.get().strip()    
    if text:
        cat = category_var.get()
        priority = priority_var.get()
        due_date = due_entry.get().strip()

        tasks.append((text, cat, priority, due_date if due_date else None))

        my_entry.delete(0, END)
        due_entry.delete(0, END)

        refresh_listbox(filter_category_var.get())

def cross_off_item():
    #cross off item
    my_list.itemconfig(
    my_list.curselection(),
    fg="#dedede")
    my_list.selection_clear(0,END)
    
def uncross_item():
    #cross off item
    my_list.itemconfig(
    my_list.curselection(),
    fg="#464646")
    my_list.selection_clear(0,END)    

def delete_crossed():
    count = 0
    while count < my_list.size():
        if my_list.itemcget(count, "fg") == "#dedede":
            my_list.delete(my_list.index(count))

        else:
           count += 1

def save_list():
    file_name = filedialog.asksaveasfilename(
        initialdir="wm",
        title="Save File",
        filetypes=(
            ("Dat Files","*.dat"),
            ("All Files", "*.*"))
        )
    if file_name:
        if file_name.endswith(".dat"):
            pass
        else:
           file_name = f'{file_name}.dat'

        count = 0
        while count < my_list.size():
            if my_list.itemcget(count, "fg") == "#dedede":
                my_list.delete(my_list.index(count))

            else:
                count += 1
        #grab all the stuff from the list
        stuff = my_list.get(0,END)

        #open the file
        output_file = open(file_name,'wb')

        #actually add the stuff to the file
        pickle.dump(stuff,output_file)

        
        

def open_list():
    file_name = filedialog.askopenfilename(
        initialdir="wm",
        title="Open File",
        filetypes=(
            ("Dat Files","*.dat"),
            ("All Files", "*.*"))
        )
    if file_name:
        # delete currently open list
        my_list.delete(0,END)

        #open the file
        input_file = open(file_name, 'rb')

        #load the data from the file
        stuff = pickle.load(input_file)

        #output stuff to the screen
        for item in stuff:
            my_list.insert(END,item)

def delete_list():
    my_list.delete(0,END)


#createmenu
my_menu = Menu(root)
root.config(menu=my_menu)

#add items to the menu
file_menu = Menu(my_menu, tearoff=False)
my_menu.add_cascade(label="File", menu=file_menu)
#add dropdown items
file_menu.add_command(label="Ulo��it", command=save_list)
file_menu.add_command(label="Otev����t", command=open_list)
file_menu.add_separator()
file_menu.add_command(label="Odstranit", command=delete_list)


# add some buttons
delete_button = Button(button_frame, text="Smazat", command=delete_item)
add_button = Button(button_frame, text="P��idat", command=add_item)
cross_off_button = Button(button_frame, text="Hotovo", command=cross_off_item)
uncross_button = Button(button_frame, text="Vr��tit zp��t", command=uncross_item)
delete_crossed_button = Button(button_frame, text="Vymazat hotov��", command=delete_crossed)


delete_button.grid(row=0, column=0)
add_button.grid(row=0, column=1, padx=20)
cross_off_button.grid(row=0, column=2)
uncross_button.grid(row=0, column=3, padx=20)
delete_crossed_button.grid(row=0, column=4)


check_deadlines()
root.mainloop()

# data[].attributes.attachment_link.readable_text
import tkinter as tk
import winsound

# =========================
# CESTA KE ZVUK��M (MUS�� B��T .WAV)
# =========================

BASE_PATH = r"C:\Users\necasa22\OneDrive - Gymn��zium Vincence Makovsk��ho Nov�� M��sto na Morav��\Projekt"

CORRECT_SOUND = BASE_PATH + r"\Correct.wav"
WRONG_SOUND = BASE_PATH + r"\Fail.wav"
MUSIC_FILE = BASE_PATH + r"\Music.wav"


# =========================
# HLAVN�� T����DA
# =========================

class RiskujGame:

    def __init__(self, root):
        self.root = root
        self.root.title("RISKuj")
        self.root.geometry("1200x750")
        self.root.configure(bg="#1e1e1e")

        self.players = []
        self.scores = []
        self.current_player = 0
        self.time_left = 30
        self.timer_id = None

        self.start_screen()

        # Spu��t��n�� hudby
        try:
            winsound.PlaySound(MUSIC_FILE,
                               winsound.SND_FILENAME |
                               winsound.SND_ASYNC |
                               winsound.SND_LOOP)
        except:
            pass

    # =========================
    # START OBRAZOVKA
    # =========================

    def start_screen(self):
        self.clear()

        tk.Label(self.root, text="RISKuj",
                 font=("Arial", 45, "bold"),
                 bg="#1e1e1e", fg="gold").pack(pady=40)

        tk.Label(self.root, text="Po��et hr������ (1���4)",
                 font=("Arial", 20),
                 bg="#1e1e1e", fg="white").pack(pady=10)

        self.player_count = tk.IntVar(value=1)

        for i in range(1, 5):
            tk.Radiobutton(self.root, text=str(i),
                           variable=self.player_count,
                           value=i,
                           font=("Arial", 18),
                           bg="#1e1e1e",
                           fg="white",
                           selectcolor="#333").pack()

        tk.Button(self.root, text="Pokra��ovat",
                  font=("Arial", 18),
                  bg="gold",
                  command=self.enter_names).pack(pady=20)

    # =========================
    # ZAD��N�� JM��N
    # =========================

    def enter_names(self):
        self.clear()

        count = self.player_count.get()
        self.name_entries = []

        tk.Label(self.root, text="Zadej jm��na hr������",
                 font=("Arial", 28),
                 bg="#1e1e1e", fg="white").pack(pady=30)

        for i in range(count):
            entry = tk.Entry(self.root, font=("Arial", 18))
            entry.insert(0, f"Hr���� {i+1}")
            entry.pack(pady=10)
            self.name_entries.append(entry)

        tk.Button(self.root, text="Start hry",
                  font=("Arial", 18),
                  bg="gold",
                  command=self.start_game).pack(pady=20)

    # =========================
    # OT��ZKY
    # =========================

    def load_questions(self):
        return {

            "Skaut": {
                100: {"type": "text",
                      "question": "Kdo zalo��il ��esk�� skauting?",
                      "answer": "Anton��n Benjamin Svojs��k"},

                200: {"type": "text",
                      "question": "Jak se jmenuje zakladatel sv��tov��ho skautingu?",
                      "answer": "Robert Baden-Powell"},

                300: {"type": "choice",
                      "question": "Jak se jmenuje ��esk�� skautsk�� organizace?",
                      "options": ["Sokol", "Jun��k ��� ��esk�� skaut",
                                  "Orel", "Pion��r"],
                      "answer": "Jun��k ��� ��esk�� skaut"},

                400: {"type": "choice",
                      "question": "Co znamenaj�� lipov�� l��stky na kroji?",
                      "options": ["hodnost ve skautu",
                                  "po��et t��bor��",
                                  "po��et let ve skautu",
                                  "ocen��n�� vedouc��ch"],
                      "answer": "po��et let ve skautu"},

                500: {"type": "text",
                      "question": "Kdy a kde byl prvn�� t��bor?",
                      "answer": "1907 na ostrov�� Brownsea"}
            },

            "Historie": {
                100: {"type": "text",
                      "question": "Ve kter�� zemi vznikly olympijsk�� hry?",
                      "answer": "��ecko"},

                200: {"type": "text",
                      "question": "Jak se jmenoval prvn�� ��eskoslovensk�� prezident?",
                      "answer": "Tom���� Garrigue Masaryk"},

                300: {"type": "text",
                      "question": "Kdy vzniklo ��eskoslovensko?",
                      "answer": "28. ����jna 1918"},

                400: {"type": "text",
                      "question": "Kdy vznikla samostatn�� ��esk�� republika?",
                      "answer": "1. ledna 1993"},

                500: {"type": "text",
                      "question": "Jak se jmenoval st��t p��ed rokem 1918?",
                      "answer": "Rakousko-Uhersko"}
            },

            "Sporty": {
                100: {"type": "text",
                      "question": "Kolik hr������ m�� fotbalov�� t��m na h��i��ti?",
                      "answer": "11"},

                200: {"type": "text",
                      "question": "Jak�� sport hraje Jarom��r J��gr?",
                      "answer": "Ledn�� hokej"},

                300: {"type": "choice",
                      "question": "Kolik kruh�� je na olympijsk��m symbolu?",
                      "options": ["4", "5", "6", "7"],
                      "answer": "5"},

                400: {"type": "text",
                      "question": "Kter�� sport je h��zen�� m����e do ko��e?",
                      "answer": "Basketbal"},

                500: {"type": "choice",
                      "question": "Jak�� sport kombinuje b��h, plav��n�� a kolo?",
                      "options": ["Triatlon", "Modern�� p��tiboj",
                                  "Biatlon", "Duatlon"],
                      "answer": "Triatlon"}
            },

            "Film a poh��dky": {
                100: {"type": "text",
                      "question": "Jak se jmenuje ��kola z Harryho Pottera?",
                      "answer": "Bradavice"},

                200: {"type": "text",
                      "question": "Jak se jmenuje sn��hul��k z Ledov��ho kr��lovstv��?",
                      "answer": "Olaf"},

                300: {"type": "text",
                      "question": "Jak se jmenuje t��m Marvel hrdin��?",
                      "answer": "Avengers"},

                400: {"type": "choice",
                      "question": "Kdo je v��dce Autobot��?",
                      "options": ["Bumblebee", "Megatron",
                                  "Optimus Prime", "Starscream"],
                      "answer": "Optimus Prime"},

                500: {"type": "choice",
                      "question": "Kdo nen�� Ninja Turtle?",
                      "options": ["Leonardo", "Michelangelo",
                                  "Donatello", "Raphael",
                                  "Caravaggio"],
                      "answer": "Caravaggio"}
            }
        }

    # =========================
    # START HRY
    # =========================

    def start_game(self):
        self.players = [e.get() for e in self.name_entries]
        self.scores = [0] * len(self.players)
        self.questions = self.load_questions()
        self.board()

    # =========================
    # TABULE
    # =========================

    def board(self):
        self.clear()

        score_text = " | ".join(
            [f"{self.players[i]}: {self.scores[i]}"
             for i in range(len(self.players))]
        )

        tk.Label(self.root, text=score_text,
                 font=("Arial", 18),
                 bg="#1e1e1e", fg="white").pack(pady=10)

        frame = tk.Frame(self.root, bg="#1e1e1e")
        frame.pack()

        for col, category in enumerate(self.questions):
            tk.Label(frame, text=category,
                     font=("Arial", 16, "bold"),
                     bg="#1e1e1e", fg="gold").grid(row=0, column=col, padx=20)

            for row, value in enumerate(self.questions[category]):
                tk.Button(frame, text=str(value),
                          font=("Arial", 14),
                          width=10,
                          command=lambda c=category, v=value:
                          self.show_question(c, v)
                          ).grid(row=row+1, column=col, pady=5)

    # =========================
    # OT��ZKA
    # =========================

    def show_question(self, category, value):
        self.clear()

        self.current = self.questions[category][value]
        self.current_value = value

        tk.Label(self.root,
                 text=f"Hraje: {self.players[self.current_player]}",
                 font=("Arial", 16),
                 bg="#1e1e1e", fg="white").pack()

        self.timer_label = tk.Label(self.root,
                                    text="30",
                                    font=("Arial", 20),
                                    bg="#1e1e1e",
                                    fg="red")
        self.timer_label.pack()

        tk.Label(self.root,
                 text=self.current["question"],
                 font=("Arial", 22),
                 wraplength=900,
                 bg="#1e1e1e",
                 fg="white").pack(pady=20)

        self.feedback = tk.Label(self.root,
                                 text="",
                                 font=("Arial", 18),
                                 bg="#1e1e1e")
        self.feedback.pack()

        if self.current["type"] == "choice":
            self.buttons = []
            for option in self.current["options"]:
                btn = tk.Button(self.root,
                                text=option,
                                font=("Arial", 14),
                                width=40,
                                command=lambda o=option:
                                self.check_answer(o))
                btn.pack(pady=5)
                self.buttons.append(btn)
        else:
            self.entry = tk.Entry(self.root, font=("Arial", 16))
            self.entry.pack(pady=10)

            tk.Button(self.root, text="Odpov��d��t",
                      command=lambda:
                      self.check_answer(self.entry.get())
                      ).pack()

        tk.Button(self.root, text="Zp��t na v��b��r",
                  command=self.board).pack(pady=15)

        self.time_left = 30
        self.update_timer()

    # =========================
    # TIMER
    # =========================

    def update_timer(self):
        if self.time_left > 0:
            self.timer_label.config(text=str(self.time_left))
            self.time_left -= 1
            self.timer_id = self.root.after(1000, self.update_timer)
        else:
            self.feedback.config(text="��as vypr��el!", fg="red")
            self.next_player()

    # =========================
    # KONTROLA
    # =========================

    def check_answer(self, answer):
        correct = self.current["answer"]

        if answer.strip().lower() == correct.lower():
            self.scores[self.current_player] += self.current_value
            self.feedback.config(text="Spr��vn��!", fg="lime")
            winsound.PlaySound(CORRECT_SOUND,
                               winsound.SND_FILENAME |
                               winsound.SND_ASYNC)
        else:
            self.scores[self.current_player] -= self.current_value
            self.feedback.config(text="��patn��!", fg="red")
            winsound.PlaySound(WRONG_SOUND,
                               winsound.SND_FILENAME |
                               winsound.SND_ASYNC)

        self.root.after(2000, self.next_player)

    # =========================
    # DAL���� HR����
    # =========================

    def next_player(self):
        self.current_player = (self.current_player + 1) % len(self.players)
        self.board()

    # =========================
    # CLEAR
    # =========================

    def clear(self):
        for widget in self.root.winfo_children():
            widget.destroy()


# =========================
# SPU��T��N��
# =========================

root = tk.Tk()
game = RiskujGame(root)
root.mainloop()

# data[].attributes.attachment_link.readable_text
import tkinter as tk
from tkinter import messagebox
import random
import time
import json
import sys

# Pokus o import winsound (funguje na Windows)
try:
    import winsound
    SOUND_AVAILABLE = True
except ImportError:
    SOUND_AVAILABLE = False


QUESTIONS = [
    {"question": "Jak�� je hlavn�� jazyk pro datovou anal��zu?", "options": ["Python", "HTML", "CSS", "XML"], "answer": "Python"},
    {"question": "Hlavn�� m��sto ��R?", "options": ["Brno", "Praha", "Ostrava", "Plze��"], "answer": "Praha"},
    {"question": "Kolik je 2 + 2?", "options": ["3", "4", "5", "6"], "answer": "4"},
    {"question": "Kdo vytvo��il Python?", "options": ["Guido van Rossum", "Elon Musk", "Bill Gates", "Linus Torvalds"], "answer": "Guido van Rossum"},
    {"question": "Nejv��t���� oce��n?", "options": ["Atlantsk��", "Indick��", "Tich��", "Arktick��"], "answer": "Tich��"},
    {"question": "Co je OOP?", "options": ["Programov��n�� s objekty", "Typ datab��ze", "Opera��n�� syst��m", "Hra"], "answer": "Programov��n�� s objekty"},
    {"question": "Kter�� je nejslavn��j���� libanonsk�� here��ka?", "options": ["Lady Dee", "Bonie Blue", "Burj Khalifa", "Mia Khalifa"], "answer": "Mia Khalifa"},
    {"question": "Do jak�� moto skupiny pat���� Dan?", "options": ["Retard riders", "Whilee bastards", "Vesnick�� tuning", "Crypliez Crew"], "answer": "Programov��n�� s objekty"},
    {"question": "Jak�� je Filip��v obl��ben�� fotbalista?", "options": ["Trent Alexander-Arnold", "Dominik Szoboszlai", "Mohamed Salah", "Hugo Ekitike"], "answer": "Dominik Szoboszlai"},
    {"question": "Co chce d��lat David za povol��n��?", "options": ["Oprav����", "Pornohv��zda", "U��itel", "Chemik"], "answer": "U��itel"},
    {"question": "Kter�� AI n��stroj je z ����ny?", "options": ["Deep seek", "Chat GPT", "Microsoft", "Gemini"], "answer": "Deep seek"},
    {"question": "Jak�� je Lucky obl��ben�� hokejista?", "options": ["Connor McDavid", "Dalibor Dvorsk��", "Jarda J��gr", "Macklin Celebrini"], "answer": "Macklin Celebrini"},
    {"question": "Co d��l�� sestra Vendy?", "options": ["Soudkyn��", "U��itelka", "Vrchn�� sestra", "Techni��ka"], "answer": "Soudkyn��"},
    {"question": "Kter�� plemeno chov�� Adam?", "options": ["Jork����rsk�� teri��r", "Hladkosrst�� retrivr", "Dalmatin", "Sheltie"], "answer": "Hladkosrst�� retrivr"},
    {"question": "Jakou m�� Terka zaj��mavou z��libu?", "options": ["Sledov��n�� vlak��", "Matematika", "Malov��n��", "2. sv��tovou v��lku"], "answer": "Sledov��n�� vlak��"},
    {"question": "Kter�� sal��m je podle K��ti nejlep����?", "options": ["Vyso��ina", "Poli��an", "Ko��sk��", "Kosteleck��"], "answer": "Ko��sk��"},
    {"question": "V jak�� vesnici bydl�� Kuba Miko?", "options": ["Rade����nsk�� Svratka", "Rovn��", "Divi��ov", "Ku��im"], "answer": "Rovn��"},
    {"question": "Jak�� zv����e chov�� Kuba Homola?", "options": ["Ka��ena", "Skot dom��c��", "Kur dom��c��", "Vep��"], "answer": "Kur dom��c��"},
    {"question": "Jak�� rasy chce D����a sv��ho p����tele?", "options": ["Mongoloidn��", "Negroidn��", "Europoidn��", "Mulat"], "answer": "Negroidn��"},
    {"question": "Jak sse jmenuje pes Terky Novotn��?", "options": ["Baily", "F��nix", "Hugo", "Lujza"], "answer": "Baily"},
    {"question": "Jak�� sport d��l�� Sab��i sestra?", "options": ["Atletika", "Ly��ov��n��", "Fotbal", "Biatlon"], "answer": "Biatlon"},
    {"question": "Jak�� je K��ji obl��ben�� seri��l?", "options": ["Bratrstvo neohro��en��ch", "The Pacific", "Vl��dcov�� nebes", "Ma��inka Tom����"], "answer": "Bratrstvo neohro��en��ch"},
    {"question": "Jak�� je obl��ben�� st��t Jol��i?", "options": ["Palestina", "Velk�� Brit��nie", "Izrael", "Tuvalu"], "answer": "Izrael"},
    {"question": "Obl��ben�� n��poj Elis?", "options": ["Matcha", "Vodka", "Protein shake", "Milk shake"], "answer": "Matcha"},
]


TIME_LIMIT = 10
SCORE_FILE = "scores.json"


class QuizGame:
    def __init__(self, root):
        self.root = root
        self.root.title("���� Kv��zov�� hra")
        self.root.geometry("500x500")
        self.root.configure(bg="#1e1e2f")

        self.score = 0
        self.question_index = 0
        self.start_time = 0
        self.player_name = ""
        self.questions = random.sample(QUESTIONS, len(QUESTIONS))
        self.buttons = []

        self.create_start_screen()

    # ---------------- ZVUKY ---------------- #

    def play_correct_sound(self):
        if SOUND_AVAILABLE and sys.platform.startswith("win"):
            winsound.Beep(1000, 300)  # vysok�� t��n
        else:
            self.root.bell()

    def play_wrong_sound(self):
        if SOUND_AVAILABLE and sys.platform.startswith("win"):
            winsound.Beep(400, 400)  # n��zk�� t��n
        else:
            self.root.bell()

    # --------------------------------------- #

    def create_start_screen(self):
        self.clear_window()

        title = tk.Label(self.root, text="���� KV��ZOV�� HRA ����",
                         font=("Arial", 20, "bold"),
                         bg="#1e1e2f", fg="white")
        title.pack(pady=20)

        name_label = tk.Label(self.root, text="Zadej sv�� jm��no:",
                              font=("Arial", 14),
                              bg="#1e1e2f", fg="white")
        name_label.pack()

        self.name_entry = tk.Entry(self.root, font=("Arial", 14))
        self.name_entry.pack(pady=10)

        start_button = tk.Button(self.root, text="Start",
                                 font=("Arial", 14),
                                 bg="#4CAF50", fg="white",
                                 command=self.start_game)
        start_button.pack(pady=15)

    def start_game(self):
        self.player_name = self.name_entry.get()
        if not self.player_name:
            messagebox.showwarning("Chyba", "Zadej jm��no!")
            return

        self.score = 0
        self.question_index = 0
        self.questions = random.sample(QUESTIONS, len(QUESTIONS))
        self.show_question()

    def show_question(self):
        self.clear_window()

        if self.question_index >= len(self.questions):
            self.end_game()
            return

        self.buttons = []
        question_data = self.questions[self.question_index]
        self.start_time = time.time()

        question_label = tk.Label(self.root,
                                  text=question_data["question"],
                                  font=("Arial", 14, "bold"),
                                  wraplength=450,
                                  bg="#1e1e2f", fg="white")
        question_label.pack(pady=20)

        for option in question_data["options"]:
            btn = tk.Button(self.root,
                            text=option,
                            font=("Arial", 12),
                            bg="#2e2e48",
                            fg="white",
                            activebackground="#3e3e60",
                            command=lambda opt=option: self.check_answer(opt))
            btn.pack(fill="x", padx=60, pady=5)
            self.buttons.append(btn)

        self.timer_label = tk.Label(self.root,
                                    text="��as: 10",
                                    font=("Arial", 12),
                                    bg="#1e1e2f", fg="yellow")
        self.timer_label.pack(pady=10)

        self.update_timer()

    def update_timer(self):
        elapsed = int(time.time() - self.start_time)
        remaining = TIME_LIMIT - elapsed

        if remaining <= 0:
            self.question_index += 1
            self.show_question()
        else:
            self.timer_label.config(text=f"��as: {remaining}")
            self.root.after(1000, self.update_timer)

    def check_answer(self, selected):
        correct = self.questions[self.question_index]["answer"]

        for btn in self.buttons:
            btn.config(state="disabled")

            if btn["text"] == correct:
                btn.config(bg="green")
            elif btn["text"] == selected:
                btn.config(bg="red")

        if selected == correct:
            self.score += 1
            self.play_correct_sound()
        else:
            self.play_wrong_sound()

        self.root.after(1500, self.next_question)

    def next_question(self):
        self.question_index += 1
        self.show_question()

    def end_game(self):
        self.save_score()
        self.clear_window()

        result = tk.Label(self.root,
                          text=f"Konec hry!\nBody: {self.score}",
                          font=("Arial", 18, "bold"),
                          bg="#1e1e2f", fg="white")
        result.pack(pady=30)

        restart_button = tk.Button(self.root,
                                   text="Hr��t znovu",
                                   font=("Arial", 14),
                                   bg="#2196F3",
                                   fg="white",
                                   command=self.create_start_screen)
        restart_button.pack(pady=10)

        leaderboard_button = tk.Button(self.root,
                                        text="Tabulka hr������",
                                        font=("Arial", 14),
                                        bg="#9C27B0",
                                        fg="white",
                                        command=self.show_leaderboard)
        leaderboard_button.pack(pady=10)

    def save_score(self):
        try:
            with open(SCORE_FILE, "r", encoding="utf-8") as f:
                data = json.load(f)
        except:
            data = []

        data.append({"name": self.player_name, "score": self.score})
        data = sorted(data, key=lambda x: x["score"], reverse=True)[:10]

        with open(SCORE_FILE, "w", encoding="utf-8") as f:
            json.dump(data, f, ensure_ascii=False, indent=2)

    def show_leaderboard(self):
        self.clear_window()

        title = tk.Label(self.root,
                         text="���� Nejlep���� hr����i",
                         font=("Arial", 18, "bold"),
                         bg="#1e1e2f", fg="white")
        title.pack(pady=20)

        try:
            with open(SCORE_FILE, "r", encoding="utf-8") as f:
                data = json.load(f)
        except:
            data = []

        for item in data:
            line = tk.Label(self.root,
                            text=f"{item['name']} - {item['score']} bod��",
                            font=("Arial", 12),
                            bg="#1e1e2f", fg="white")
            line.pack()

        back_button = tk.Button(self.root,
                                text="Zp��t",
                                font=("Arial", 14),
                                bg="#f44336",
                                fg="white",
                                command=self.create_start_screen)
        back_button.pack(pady=20)

    def clear_window(self):
        for widget in self.root.winfo_children():
            widget.destroy()


def main():
    root = tk.Tk()
    app = QuizGame(root)
    root.mainloop()


if __name__ == "__main__":
    main()

# data[].attributes.attachment_link.readable_text
import tkinter as tk
from tkinter import ttk

class PrevodnikJednotek:
    def __init__(self, root):
        self.root = root
        self.root.title("Modern�� P��evodn��k")
        self.root.geometry("450x400")
        self.root.resizable(False, False) # Zamezen�� zm��ny velikosti pro zachov��n�� vzhledu
        self.root.configure(bg="#1e1e1e")

        # Definice dat a koeficient��
        self.data = {
            "D��lka": {
                "jednotky": ["metry", "kilometry", "m��le", "stopy"],
                "koef": {"metry": 1, "kilometry": 1000, "m��le": 1609.34, "stopy": 0.3048}
            },
            "Hmotnost": {
                "jednotky": ["kilogramy", "gramy", "libry"],
                "koef": {"kilogramy": 1, "gramy": 0.001, "libry": 0.453592}
            },
            "Teplota": {
                "jednotky": ["Celsius", "Fahrenheit", "Kelvin"]
            }
        }

        self.nastav_styl()
        self.vytvor_rozhrani()

    def nastav_styl(self):
        """Nastaven�� vzhledu pro ttk komponenty."""
        style = ttk.Style()
        style.theme_use('clam')
        # ��prava vzhledu Comboboxu (v��b��rov��ho menu)
        style.configure("TCombobox", 
                        fieldbackground="#333333", 
                        background="#555555", 
                        foreground="white",
                        arrowcolor="white")

    def vytvor_rozhrani(self):
        # Hlavn�� kontejner
        main_frame = tk.Frame(self.root, bg="#1e1e1e", padx=25, pady=20)
        main_frame.pack(expand=True, fill="both")

        # --- V��b��r kategorie ---
        tk.Label(main_frame, text="KATEGORIE", bg="#1e1e1e", fg="#56b6c2", font=("Arial", 9, "bold")).pack(anchor="w")
        self.kat_var = tk.StringVar(value="D��lka")
        self.kat_menu = ttk.Combobox(main_frame, textvariable=self.kat_var, values=list(self.data.keys()), state="readonly")
        self.kat_menu.pack(fill="x", pady=(5, 15))
        self.kat_menu.bind("<<ComboboxSelected>>", self.aktualizuj_jednotky)

        # --- Vstupn�� hodnota ---
        tk.Label(main_frame, text="HODNOTA", bg="#1e1e1e", fg="#56b6c2", font=("Arial", 9, "bold")).pack(anchor="w")
        self.vstup_var = tk.StringVar()
        # Sledujeme zm��ny v poli (p��i psan�� se hned po����t��)
        self.vstup_var.trace_add("write", lambda *args: self.prepocitej())
        self.vstup_entry = tk.Entry(main_frame, textvariable=self.vstup_var, bg="#333333", fg="white", 
                                    insertbackground="white", font=("Arial", 14), bd=0, highlightthickness=1, highlightbackground="#444")
        self.vstup_entry.pack(fill="x", ipady=8, pady=(5, 15))
        self.vstup_entry.focus_set() # Automaticky aktivuje pole pro psan��

        # --- V��b��r jednotek (Z -> DO) ---
        jednotky_frame = tk.Frame(main_frame, bg="#1e1e1e")
        jednotky_frame.pack(fill="x")

        # Sloupec "Z"
        z_frame = tk.Frame(jednotky_frame, bg="#1e1e1e")
        z_frame.pack(side="left", expand=True, fill="x", padx=(0, 5))
        tk.Label(z_frame, text="Z JEDNOTKY", bg="#1e1e1e", fg="#abb2bf", font=("Arial", 8)).pack(anchor="w")
        self.z_var = tk.StringVar()
        self.z_menu = ttk.Combobox(z_frame, textvariable=self.z_var, state="readonly")
        self.z_menu.pack(fill="x")
        self.z_menu.bind("<<ComboboxSelected>>", lambda e: self.prepocitej())

        # Sloupec "DO"
        do_frame = tk.Frame(jednotky_frame, bg="#1e1e1e")
        do_frame.pack(side="left", expand=True, fill="x", padx=(5, 0))
        tk.Label(do_frame, text="C��LOV�� JEDNOTKA", bg="#1e1e1e", fg="#abb2bf", font=("Arial", 8)).pack(anchor="w")
        self.do_var = tk.StringVar()
        self.do_menu = ttk.Combobox(do_frame, textvariable=self.do_var, state="readonly")
        self.do_menu.pack(fill="x")
        self.do_menu.bind("<<ComboboxSelected>>", lambda e: self.prepocitej())

        # --- V��sledek ---
        self.vysledek_var = tk.StringVar(value="Zadejte ����slo")
        tk.Label(main_frame, text="V��SLEDEK", bg="#1e1e1e", fg="#e06c75", font=("Arial", 10, "bold")).pack(pady=(35, 5))
        self.label_vysledek = tk.Label(main_frame, textvariable=self.vysledek_var, bg="#1e1e1e", fg="#98c379", font=("Arial", 24, "bold"))
        self.label_vysledek.pack()

        self.aktualizuj_jednotky()

    def aktualizuj_jednotky(self, event=None):
        """Zm��n�� seznam jednotek v menu podle vybran�� kategorie."""
        kat = self.kat_var.get()
        jednotky = self.data[kat]["jednotky"]
        
        self.z_menu['values'] = jednotky
        self.do_menu['values'] = jednotky
        
        # Nastaven�� v��choz��ch jednotek (nap��. m -> km)
        self.z_var.set(jednotky[0])
        self.do_var.set(jednotky[1] if len(jednotky) > 1 else jednotky[0])
        self.prepocitej()

    def prepocitej(self):
        """Hlavn�� logika v��po��tu."""
        vstup = self.vstup_var.get().replace(",", ".") # O��et��en�� ��esk�� ����rky
        
        if not vstup:
            self.vysledek_var.set("...")
            return

        try:
            hodnota = float(vstup)
            kat = self.kat_var.get()
            z = self.z_var.get()
            do = self.do_var.get()

            if kat == "Teplota":
                vysledek = self.vypocet_teploty(hodnota, z, do)
            else:
                # P��evod p��es koeficienty
                k = self.data[kat]["koef"]
                v_zakladu = hodnota * k[z]
                vysledek = v_zakladu / k[do]

            # Form��tov��n�� v��sledku: max 6 desatinn��ch m��st, odstran��n�� zbyte��n��ch nul
            text_vysledek = f"{vysledek:.6f}".rstrip('0').rstrip('.')
            if text_vysledek == "": text_vysledek = "0"
            self.vysledek_var.set(text_vysledek)
            
        except ValueError:
            self.vysledek_var.set("Chyba")

    def vypocet_teploty(self, v, z, do):
        """Specifick�� vzorce pro teplotu."""
        # 1. P��evod na Celsius
        if z == "Celsius": c = v
        elif z == "Fahrenheit": c = (v - 32) * 5/9
        elif z == "Kelvin": c = v - 273.15

        # 2. P��evod z Celsius na c��lovou
        if do == "Celsius": return c
        elif do == "Fahrenheit": return (c * 9/5) + 32
        elif do == "Kelvin": return c + 273.15
        return c

if __name__ == "__main__":
    root = tk.Tk()
    app = PrevodnikJednotek(root)
    root.mainloop()

# data[].attributes.attachment_link.readable_text
import tkinter as tk
from tkinter import messagebox
import random

# ---------------- Funkce hry ----------------

def start_game():
    """Inicializuje novou hru."""
    global target_number, attempts
    target_number = random.randint(1, 100)  # n��hodn�� ����slo 1���100
    attempts = 0
    attempts_label.config(text=f"Pokusy: {attempts}")
    feedback_label.config(text="", fg="white")
    entry_guess.config(state="normal")
    entry_guess.delete(0, tk.END)
    button_guess.config(state="normal")
    button_restart.pack_forget()  # skryje tla����tko restart

def check_guess():
    """Zkontroluje hr������v tip."""
    global attempts
    guess = entry_guess.get()
    if not guess.isdigit():
        feedback_label.config(text="Zadej ����slo!", fg="red")
        return

    guess = int(guess)
    attempts += 1
    attempts_label.config(text=f"Pokusy: {attempts}")

    if guess < target_number:
        feedback_label.config(text="P����li�� n��zk��!", fg="blue")
    elif guess > target_number:
        feedback_label.config(text="P����li�� vysok��!", fg="red")
    else:
        feedback_label.config(text=f"Spr��vn��! Uhodl jsi za {attempts} pokus��.", fg="green")
        entry_guess.config(state="disabled")
        button_guess.config(state="disabled")
        button_restart.pack(pady=20)  # zobraz�� tla����tko restart

# ---------------- GUI ----------------

# hlavn�� okno
root = tk.Tk()
root.title("H��d��n�� ����sla")
root.geometry("400x500")
root.configure(bg="#1e1e1e")  # tmav�� pozad��

# nadpis
title_label = tk.Label(root, text="H��dej ����slo 1���100", font=("Arial", 24, "bold"), fg="white", bg="#1e1e1e")
title_label.pack(pady=30)

# textov�� pole pro tip
entry_guess = tk.Entry(root, font=("Arial", 18), justify="center")
entry_guess.pack(pady=20)

# tla����tko pro kontrolu tipu
button_guess = tk.Button(root, text="Tipni", font=("Arial", 16), bg="#4CAF50", fg="white", command=check_guess)
button_guess.pack(pady=10)

# label pro zp��tnou vazbu
feedback_label = tk.Label(root, text="", font=("Arial", 18), bg="#1e1e1e")
feedback_label.pack(pady=20)

# label pro po����tadlo pokus��
attempts_label = tk.Label(root, text="Pokusy: 0", font=("Arial", 16), fg="white", bg="#1e1e1e")
attempts_label.pack(pady=10)

# tla����tko pro restart hry
button_restart = tk.Button(root, text="Hr��t znovu", font=("Arial", 16), bg="#2196F3", fg="white", command=start_game)

# start hry p��i spu��t��n�� programu
start_game()

# spust�� hlavn�� smy��ku Tkinteru
root.mainloop()

# data[].attributes.attachment_link.readable_text
import tkinter as tk
from tkinter import messagebox

# -----------------------------
# HLAVN�� OKNO
# -----------------------------
root = tk.Tk()
root.title("Kalkula��ka")
root.geometry("400x600")
root.configure(bg="#1e1e1e")  # tmav�� pozad��

# -----------------------------
# PROM��NN��
# -----------------------------
current_input = ""
history = []

# -----------------------------
# FUNKCE
# -----------------------------

def update_display(value):
    display_var.set(value)

def add_to_input(char):
    global current_input
    current_input += str(char)
    update_display(current_input)

def clear():
    global current_input
    current_input = ""
    update_display("")

def calculate():
    global current_input, history
    try:
        if "/0" in current_input:
            raise ZeroDivisionError
        result = eval(current_input)
        # Ulo��en�� do historie
        history.append(f"{current_input} = {result}")
        if len(history) > 5:
            history.pop(0)
        update_history()
        current_input = str(result)
        update_display(current_input)
    except ZeroDivisionError:
        messagebox.showerror("Chyba", "Nelze d��lit nulou!")
        clear()
    except:
        messagebox.showerror("Chyba", "Neplatn�� v��raz!")
        clear()

def update_history():
    history_text.config(state="normal")
    history_text.delete("1.0", tk.END)
    for item in history:
        history_text.insert(tk.END, item + "\n")
    history_text.config(state="disabled")  # aby u��ivatel nemohl upravovat historii

# -----------------------------
# DISPLEJ
# -----------------------------
display_var = tk.StringVar()
display = tk.Entry(root, textvariable=display_var, font=("Arial", 24), bd=0,
                   bg="#2d2d2d", fg="white", justify="right")
display.pack(fill="both", ipadx=8, ipady=20, padx=10, pady=10)

# -----------------------------
# R��M PRO TLA����TKA
# -----------------------------
buttons_frame = tk.Frame(root, bg="#1e1e1e")
buttons_frame.pack(expand=True, fill="both")

# Funkce pro tla����tka
def make_button(text, row, col, command=None, colspan=1):
    btn = tk.Button(buttons_frame, text=text, font=("Arial", 16),
                    bg="#3a3a3a", fg="white", activebackground="#505050",
                    activeforeground="white", bd=0, command=command)
    btn.grid(row=row, column=col, columnspan=colspan, sticky="nsew", padx=5, pady=5)
    return btn

# Tla����tka
button_texts = [
    ["7","8","9","/"],
    ["4","5","6","*"],
    ["1","2","3","-"],
    ["0","C","=","+"]
]

for r, row in enumerate(button_texts):
    for c, char in enumerate(row):
        if char == "C":
            make_button(char, r, c, command=clear)
        elif char == "=":
            make_button(char, r, c, command=calculate)
        else:
            # vytvo����me lok��ln�� prom��nnou pro lambda, aby fungovala spr��vn��
            make_button(char, r, c, command=lambda ch=char: add_to_input(ch))

# Nastaven�� gridu tak, aby tla����tka vyplnila cel�� prostor
for i in range(4):
    buttons_frame.columnconfigure(i, weight=1)
for i in range(4):
    buttons_frame.rowconfigure(i, weight=1)

# -----------------------------
# HISTORIE
# -----------------------------
history_label = tk.Label(root, text="Historie (posledn��ch 5):",
                         bg="#1e1e1e", fg="white", font=("Arial", 12))
history_label.pack(pady=(10,0))

history_text = tk.Text(root, height=5, bg="#2d2d2d", fg="white",
                       font=("Arial", 12), bd=0, state="disabled")
history_text.pack(fill="both", padx=10, pady=10)

# -----------------------------
# SPU��T��N�� APLIKACE
# -----------------------------
root.mainloop()

# data[].attributes.attachment_link.description
Shared via Claude, an AI assistant from Anthropic

# data[].attributes.headline
Zadání teamového projektu - programování s pomocí AI pro studenty

# data[].attributes.subject
Zadání teamového projektu - programování s pomocí AI pro studenty

# data[].attributes.attachment_link.description
This content is created by the owner of the form. The data you submit will be sent to the form owner. Microsoft is not responsible for the privacy or security practices of its customers, including those of this form owner. Never give out your password.Report abuse