Untitled

 avatar
unknown
plain_text
5 months ago
3.0 kB
4
Indexable
def reload_ui(self):
    root = self.winfo_toplevel()
    current_dark_mode = root.DARK_MODE
    current_language = root.LANGUAGE
    
    # Store these values before destroying widgets
    sayings = load_sayings()
    current_language_sayings = sayings[current_language]
    random_saying = random.choice(current_language_sayings)
    
    # Recreate all UI elements
    for widget in root.winfo_children():
        widget.destroy()
        
    # Recreate main frame and elements
    main_frame = ctk.CTkFrame(root, fg_color='#1c1c1e' if current_dark_mode else '#f5f5f7')
    main_frame.pack(fill='both', expand=True)
    
    # Create saying label first
    saying_label = create_saying_label(main_frame, current_dark_mode)
    saying_label.configure(text=random_saying)
    
    # Recreate settings menu
    settings_menu = SettingsMenu(main_frame, current_dark_mode)
    
    # Recreate close button
    close_button = CloseButton(main_frame, command=root.destroy)
    close_button.place(relx=0.05, rely=0.95, anchor='center')
    
    # Recreate circles frame and elements
    circles_frame = ctk.CTkFrame(main_frame, fg_color='#1c1c1e' if current_dark_mode else '#f5f5f7')
    circles_frame.place(relx=0.5, rely=0.5, anchor='center')
    
    # Add padding frame
    padding_frame = ctk.CTkFrame(circles_frame, fg_color='#1c1c1e' if current_dark_mode else '#f5f5f7')
    padding_frame.pack(padx=50)
    
    # Recreate waste type circles
    waste_types = [
        {
            "name": TRANSLATIONS[current_language]['Biomüll'],
            "circle_color": "#e8d5c4",
            "circle_color_dark": "#8a6849"
        },
        {
            "name": TRANSLATIONS[current_language]['Gelber Sack'],
            "circle_color": "#fff3d6",
            "circle_color_dark": "#fec20c"
        },
        {
            "name": TRANSLATIONS[current_language]['Papier'],
            "circle_color": "#e6f3ff",
            "circle_color_dark": "#0d7dd4"
        },
        {
            "name": TRANSLATIONS[current_language]['Restmüll'],
            "circle_color": "#cececf",
            "circle_color_dark": "#3a3a3c"
        }
    ]
    
    for waste_type in waste_types:
        container = ctk.CTkFrame(padding_frame, fg_color='#1c1c1e' if current_dark_mode else '#f5f5f7')
        container.pack(side='left', padx=15)
        
        progress = CircularProgress(
            container,
            size=220,
            label=waste_type["name"],
            circle_color=waste_type["circle_color"],
            circle_color_dark=waste_type["circle_color_dark"]
        )
        progress.pack()
        progress.set_dark_mode(current_dark_mode)
        
        slider = ctk.CTkSlider(
            container,
            from_=0,
            to=100,
            command=progress.set_fill_level,
            width=140,
            height=16,
            border_width=0,
        )
        slider.set(0)
        slider.pack(pady=(5, 0))
Editor is loading...
Leave a Comment