From f30f9c840443ee7eb94bd00c8d257cde19e2ec2c Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 11 Feb 2024 01:01:03 +0100 Subject: [PATCH] combobox support --- build.sh | 4 ++-- src/gui_main.py | 36 ++++++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/build.sh b/build.sh index bae3388..584a5b7 100755 --- a/build.sh +++ b/build.sh @@ -1,2 +1,2 @@ -nuitka3 ./src/main.py --linux-onefile-icon=./data/icon.png --onefile --output-dir=./build --run -#--disable-console --linux-icon=./data/icon.png --output-dir=./build --clean-cache=all #--include-plugin-directory=./src/ --run --disable-console --linux-icon=./data/icon.png --output-dir=./build #--clean-cache=all --recompile-c-only #--windows-icon-from-ico=./data/icon.ico --disable-console --linux-icon=./data/icon.png --onefile --output-dir=./build \ No newline at end of file +nuitka3 ./src/main.py --onefile --output-dir=./build --run +#--disable-console --output-dir=./build --clean-cache=all #--include-plugin-directory=./src/ --run --disable-console --linux-icon=./data/icon.png --output-dir=./build #--clean-cache=all --recompile-c-only \ No newline at end of file diff --git a/src/gui_main.py b/src/gui_main.py index 358389a..fa0caea 100644 --- a/src/gui_main.py +++ b/src/gui_main.py @@ -47,18 +47,23 @@ def run_installer(download_folder_tmp, col_isDark): # Remove currently visible widgets for widget in visible_widgets: widget.pack_forget() - - # Create widgets for current tab + + # Create widgets for the current tab current_tab = tab_combobox.get() widget_specs = tabs.get(current_tab, []) - + widgets = [] - for spec in widget_specs: + spacing_top = 10 # Adjust the spacing as needed + + for index, spec in enumerate(widget_specs): widget = create_widget(spec, container) if widget: - widget.pack(pady=20, padx=20) + if index == 0: # Add spacing from the top only for the first widget + widget.pack(pady=spacing_top, padx=20) + else: + widget.pack(pady=spacing_top, padx=20) widgets.append(widget) - + return widgets @@ -71,6 +76,10 @@ def run_installer(download_folder_tmp, col_isDark): elif widget_class == CTkProgressBar: progress_bar = CTkProgressBar(master=master, **widget_args) return progress_bar + elif widget_class == CTkComboBox: + # Remove the 'text' argument if it exists + widget_args.pop('text', None) + return CTkComboBox(master=master, **widget_args) else: return spec(master=master) @@ -105,17 +114,16 @@ def run_installer(download_folder_tmp, col_isDark): tab_combobox.set(list(tabs.keys())[previous_tab_index]) visible_widgets = create_widgets_for_current_tab() + def switch_to_install_tab(): + switch_to_tab("Tab3") + tabs = { "Tab1": [ - (CTkButton, {"text": "Next Tab", "command": switch_to_next_tab}), - (CTkButton, {"text": "Previous Tab", "command": switch_to_previous_tab}), - (CTkButton, {"text": "Get Browser package", "command": get_default_packages}), + (CTkComboBox, {"text": "Language", "values": ["London", "Britan", "New York"]}), (CTkComboBox, {"text": "Theme", "values": ["System", "Light", "Dark"]}), - CTkEntry, - CTkProgressBar, - CTkRadioButton, - CTkSlider, - CTkSwitch + (CTkCheckBox, {"text": f"Force {'Dark' if col_isDark else 'Light'} on every website"}), + (CTkButton, {"text": "Install", "command": switch_to_install_tab}), + (CTkButton, {"text": "Customise", "command": switch_to_next_tab}), ], "Tab2": [ (CTkButton, {"text": "Next Tab", "command": switch_to_next_tab}),