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


import customtkinter as ctk
from PIL import Image
import os

ctk.set_appearance_mode("System")
ctk.set_default_color_theme("blue")

class BrawlBotMenu(ctk.CTk):
    def __init__(self):
        super().__init__()

        self.title("Brawl Stars Bot Menu v0.1")
        self.geometry("500x655")
        self.resizable(False, False)

        # Путь к картинкам
        self.assets_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "assets")

        # Главный контейнер (размеры width и height перенесены внутрь конструктора)
        self.main_frame = ctk.CTkFrame(self, width=460, height=620, fg_color="#1e1e24") 
        self.main_frame.place(relx=0.5, rely=0.5, anchor="center")

        # Заголовок
        self.title_label = ctk.CTkLabel(self.main_frame, text="BRAWL BOT CONTROLLER", font=ctk.CTkFont(size=20, weight="bold"), text_color="#ffcc00")
        self.title_label.pack(pady=15)

        self.selected_brawler = None

        # Раздел выбора бойцов
        self.brawler_label = ctk.CTkLabel(self.main_frame, text="Выберите бойца:", font=ctk.CTkFont(size=14, weight="bold"))
        self.brawler_label.pack(pady=5)

        self.brawlers_frame = ctk.CTkFrame(self.main_frame, fg_color="transparent")
        self.brawlers_frame.pack(pady=10)

        self.brawlers = ["Shelly", "Colt", "Spike"]
        self.brawler_buttons = {}

        # Создание кнопок для бойцов
        for index, name in enumerate(self.brawlers):
            img_path = os.path.join(self.assets_path, "brawlers", f"{name.lower()}.png")
            if os.path.exists(img_path):
                icon_img = ctk.CTkImage(light_image=Image.open(img_path), size=(90, 90))
            else:
                icon_img = None

            btn = ctk.CTkButton(
                self.brawlers_frame, 
                text=name if not icon_img else "", 
                image=icon_img,
                width=100, 
                height=100,
                fg_color="#2b2b36",
                hover_color="#3e3e4f",
                command=lambda b_name=name: self.select_brawler(b_name)
            )
            btn.grid(row=0, column=index, padx=15, pady=5)
            self.brawler_buttons[name] = btn

        # Статус выбора бойца
        self.status_label = ctk.CTkLabel(self.main_frame, text="Боец не выбран", text_color="#ff4500", font=ctk.CTkFont(slant="italic"))
        self.status_label.pack(pady=5)

        # Поля ввода кубков
        self.cups_frame = ctk.CTkFrame(self.main_frame, fg_color="transparent")
        self.cups_frame.pack(pady=15)

        self.current_cups = ctk.CTkEntry(self.cups_frame, width=130, placeholder_text="Текущие кубки")
        self.current_cups.grid(row=0, column=0, padx=15)

        self.target_cups = ctk.CTkEntry(self.cups_frame, width=130, placeholder_text="Цель кубков")
        self.target_cups.grid(row=0, column=1, padx=15)

        # Кнопка СТАРТ
        self.start_button = ctk.CTkButton(self.main_frame, text="ПОДТВЕРДИТЬ ВЫБОР", fg_color="#00cc66", hover_color="#00994d", font=ctk.CTkFont(size=15, weight="bold"), command=self.click_start)
        self.start_button.pack(pady=15, ipadx=10, ipady=5)

        # Информационное окно (логи)
        self.log_textbox = ctk.CTkTextbox(self.main_frame, width=400, height=180, fg_color="#121214", text_color="#ffffff")
        self.log_textbox.pack(pady=10)
        self.log("Интерфейс успешно настроен. Выберите параметры.")

    def log(self, text):
        self.log_textbox.insert("end", f"[Панель]: {text}\n")
        self.log_textbox.see("end")

    def select_brawler(self, name):
        for b_name, btn in self.brawler_buttons.items():
            btn.configure(fg_color="#2b2b36", border_width=0)
        self.selected_brawler = name
        self.brawler_buttons[name].configure(fg_color="#1f538d", border_width=3, border_color="#ffcc00")
        self.status_label.configure(text=f"Выбран: {name}", text_color="#00ff88")
        self.log(f"Выбран персонаж: {name}")

    def click_start(self):
        if not self.selected_brawler:
            self.log("Ошибка: Сначала выберите бойца!")
            return
        curr = self.current_cups.get()
        targ = self.target_cups.get()
        if not curr.isdigit() or not targ.isdigit():
            self.log("Ошибка: Укажите кубки числами!")
            return
        
        self.log(f"Параметры сохранены! Боец: {self.selected_brawler}, Апаем с {curr} до {targ} кубков.")

if __name__ == "__main__":
    app = BrawlBotMenu()
    app.mainloop()