checkbox func
This commit is contained in:
parent
80c6ed7573
commit
42a440a47b
1 changed files with 26 additions and 5 deletions
|
@ -80,7 +80,25 @@ def run_installer(download_folder_tmp, col_isDark):
|
|||
widget_args.pop('text', None)
|
||||
return CTkComboBox(master=master, **widget_args)
|
||||
elif widget_class == CTkCheckBox:
|
||||
return CTkCheckBox(master=master, **widget_args)
|
||||
# Extract command_on and command_off, defaulting to None if not present
|
||||
command_on = widget_args.pop('command_on', None)
|
||||
command_off = widget_args.pop('command_off', None)
|
||||
|
||||
# Define the single command function
|
||||
def single_command():
|
||||
if widget_var.get() == 1 and command_on:
|
||||
command_on()
|
||||
elif widget_var.get() == 0 and command_off:
|
||||
command_off()
|
||||
|
||||
# Create IntVar for CTkCheckBox
|
||||
widget_var = IntVar()
|
||||
|
||||
# Create CTkCheckBox with remaining arguments
|
||||
checkbox = CTkCheckBox(master=master, variable=widget_var, **widget_args)
|
||||
checkbox.bind("<Button-1>", lambda event: single_command())
|
||||
|
||||
return checkbox
|
||||
else:
|
||||
return spec(master=master)
|
||||
|
||||
|
@ -115,15 +133,18 @@ 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")
|
||||
def func1():
|
||||
print("ON")
|
||||
|
||||
def func2():
|
||||
print("OFF")
|
||||
|
||||
tabs = {
|
||||
"Tab1": [
|
||||
(CTkComboBox, {"text": "Language", "values": ["London", "Britan", "New York"]}),
|
||||
(CTkComboBox, {"text": "Theme", "values": [f"System {'(Dark)' if col_isDark else '(Light)'}", "Light", "Dark"]}),
|
||||
(CTkCheckBox, {"text": f"Force {'dark' if col_isDark else 'light'} mode"}),
|
||||
(CTkButton, {"text": "Install", "command": switch_to_install_tab}),
|
||||
(CTkCheckBox, {"text": f"Force {'dark' if col_isDark else 'light'} mode", "command_on": func1, "command_off": func2}),
|
||||
(CTkButton, {"text": "Install", "command": start_install}),
|
||||
(CTkButton, {"text": "Customise", "command": switch_to_next_tab}),
|
||||
],
|
||||
"Tab2": [
|
||||
|
|
Reference in a new issue