I know how to call a function if a switch is on but not when it is off. There is not a lot of documentation about customtkinter so il be happy to get an answer!
Iv tried different booleans and stuff but it did not work.
Does this help?
def led_switch(self, event=None):
if self.is_on:
print("The LED is on")
self.is_on = False
else:
print("The LED off")
self.is_on = True
You can probably use custom Tkinter command
argument as stated in the docs .
Slight variation of the docs example code in the docs:
switch_var = customtkinter.StringVar(value="on")
def switch_event():
print("switch toggled, current value:", switch_var.get())
switch_1 = customtkinter.CTkSwitch(master=root_tk, command=switch_event,
variable=switch_var, onvalue="on", offvalue="off")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.