-
I wish to use a dict in order to hold and track my switches state. for doing so I create a dict of binaries and I want to use in the "on_change". I receive the following error during build: code: rio.Switch( |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Attribute bindings cannot be combined with any extra code. In other words, class Example(rio.Component):
led_status: dict = {
"red": False,
"green": False,
"blue": False,
"ir": False,
}
def on_led_change(self, event: rio.SwitchChangeEvent):
self.led_status['red'] = event.is_on
def build(self):
return rio.Switch(
is_on=self.led_status["red"],
on_change=self.on_led_change,
) |
Beta Was this translation helpful? Give feedback.
Attribute bindings cannot be combined with any extra code. In other words,
is_on=self.bind().led_status
is valid, butis_on=self.bind().led_status['red']
is not. You will need to update your dict in youron_change
event handler, like so: