Untitled
unknown
plain_text
2 months ago
4.8 kB
3
Indexable
def main(): ctk.deactivate_automatic_dpi_awareness() # Prevent DPI scaling issues settings = load_settings() DARK_MODE = settings.get('dark_mode', False) LANGUAGE = settings.get('language', 'DE') SHOW_WIFI_STATUS = settings.get('show_wifi_status', True) reboot_button = setup_reboot_button() # Initialize turntable (calibration will start in background) turntable = TurntableController() bin_config = BinConfiguration() observer = setup_file_monitoring(CircularProgress.update_all_instances) ctk.set_appearance_mode("dark" if DARK_MODE else "light") ctk.set_default_color_theme("dark-blue") root = ctk.CTk() root.title("SortiMate") root.LANGUAGE = LANGUAGE root.DARK_MODE = DARK_MODE root.overrideredirect(True) root.geometry("1024x600+0+0") root.focus_set() bg_color = '#1c1c1e' if DARK_MODE else '#f5f5f7' main_frame = ctk.CTkFrame(root, fg_color=bg_color) main_frame.pack(fill='both', expand=True) # Create a loading screen for initial calibration loading_screen = LoadingScreen( root, message=TRANSLATIONS[LANGUAGE]['calibrating'], dark_mode=DARK_MODE, language=LANGUAGE ) def check_calibration(): if turntable.is_calibrated: loading_screen.destroy() create_main_interface() else: root.after(100, check_calibration) def create_main_interface(): sayings = load_sayings() current_language_sayings = sayings[LANGUAGE] initial_saying = random.choice(current_language_sayings) saying_label = create_saying_label( main_frame, DARK_MODE, check_wifi=True, show_wifi_status=SHOW_WIFI_STATUS ) saying_label.configure(text=initial_saying) settings_menu = SettingsMenu(main_frame, DARK_MODE, LANGUAGE) # Create reset button try: is_light_bg = not DARK_MODE icon_suffix = "-b" if is_light_bg else "-w" reset_icon = ctk.CTkImage( light_image=Image.open(f"icons/reset{icon_suffix}.png"), dark_image=Image.open(f"icons/reset{icon_suffix}.png"), size=(30, 30) ) reset_button = ctk.CTkButton( main_frame, image=reset_icon, text="", width=30, height=30, fg_color="transparent", hover_color='#2c2c2e' if DARK_MODE else '#e5e5e7', command=lambda: ResetFillLevelsScreen(root, DARK_MODE, LANGUAGE) ) reset_button.place(relx=0.03, rely=0.05, anchor='center') except Exception as e: print(f"Error loading reset icon: {e}") reset_button = ctk.CTkButton( main_frame, text="?", width=30, height=30, fg_color="transparent", hover_color='#2c2c2e' if DARK_MODE else '#e5e5e7', command=lambda: ResetFillLevelsScreen(root, DARK_MODE, LANGUAGE) ) reset_button.place(relx=0.03, rely=0.05, anchor='center') close_button = CloseButton(main_frame, command=root.destroy) close_button.place(relx=0.05, rely=0.95, anchor='center') circles_frame = ctk.CTkFrame(main_frame, fg_color=bg_color) circles_frame.place(relx=0.5, rely=0.5, anchor='center') padding_frame = ctk.CTkFrame(circles_frame, fg_color=bg_color) padding_frame.pack(padx=50) # Create circles for each bin from configuration for bin_config_item in bin_config.bins: container = ctk.CTkFrame(padding_frame, fg_color=bg_color) container.pack(side='left', padx=15) progress = CircularProgress( container, bin_id=bin_config_item['id'], size=220 ) progress.pack() progress.set_dark_mode(root.DARK_MODE) classification_prompt = ClassificationPrompt( main_frame, DARK_MODE, LANGUAGE, turntable=turntable ) classification_prompt.place(relx=0.5, rely=0.8, anchor='center') # Start checking calibration status check_calibration() try: root.mainloop() finally: observer.stop() observer.join() if 'classification_prompt' in locals(): classification_prompt.cleanup() if __name__ == "__main__": main()
Editor is loading...
Leave a Comment