from typing import Any
import customtkinter as ctk
class MainFrame(ctk.CTkFrame):
    
    def __init__(self, master: Any, **kwargs):
        super().__init__(master, **kwargs)
        self.controller = None
        # Konfiguriere das Hauptframe, um sich zu dehnen
        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)  # Linke Spalte soll sich dehnen
        self.grid_columnconfigure(1, weight=0)  # Mittlere Spalte (Button) soll sich nicht dehnen
        self.grid_columnconfigure(2, weight=1)  # Rechte Spalte soll sich dehnen
        
        # Linkes Frame
        self.frame1 = ctk.CTkFrame(self)
        self.frame1.grid(row=0, column=0, sticky="nsew", padx=10, pady=10)
        self.frame1.grid_rowconfigure(2, weight=1)  # Lasse die Output-Textbox wachsen
        self.frame1.grid_columnconfigure(0, weight=1)  # Lasse frame1 horizontal wachsen
        
        self.entry_url = ctk.CTkEntry(self.frame1, placeholder_text='Enter the article link', height=50)
        self.entry_url.grid(row=0, column=0, padx=10, pady=10, sticky="ew")
        
        self.input_textbox = ctk.CTkTextbox(self.frame1, height=200)
        self.input_textbox.grid(row=1, column=0, columnspan=2, padx=10, pady=10, sticky="nsew")
        
        self.output_textbox = ctk.CTkTextbox(self.frame1, height=150, state="disabled")
        self.output_textbox.grid(row=2, column=0, columnspan=2, padx=10, pady=10, sticky="nsew")
        
        # Mittlerer Button
        self.check_button = ctk.CTkButton(self.frame1, text="Check", width=60, height=50, command=self.check_button_event)
        self.check_button.grid(row=0, column=1, padx=10, pady=10, sticky="w")
        
        # Rechte scrollbare Ansicht
        self.scrollview = ctk.CTkScrollableFrame(self)
        self.scrollview.grid(row=0, column=2, padx=10, pady=10, sticky="nsew")
        
        # Überschrift hinzufügen
        self.header = ctk.CTkLabel(self.scrollview, text="Leaderboard", font=("Arial", 24, "bold"))
        self.header.pack(pady=10, padx=10, anchor="w")
        
    def set_controller(self, controller):
        self.controller = controller
        
    def check_button_event(self):
        if self.controller:
            self.controller.press_check_button()
