How to access the timer object from Python #154
-
Hi. Would like to activate and deactivate one or more timers based on UI actions. Any idea how to access the timer object from code (assuming "Active" is the correct parameters controlling the execution of the timer)? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, in Streamsync you don't access components directly from Python but rather set application state, which is then propagated to the frontend. To achieve what you need you'll need to define a state element: import streamsync as ss
initial_state = ss.init_state({
"is_timer_active": "yes",
})
def activate_timer(state):
state["is_timer_active"] = "yes"
def deactivate_timer(state):
state["is_timer_active"] = "no" Then, in the Active property of the Timer, use that state element with |
Beta Was this translation helpful? Give feedback.
Hi, in Streamsync you don't access components directly from Python but rather set application state, which is then propagated to the frontend.
To achieve what you need you'll need to define a state element:
Then, in the Active property of the Timer, use that state element with
@{is_timer_active}
, rather than hardcoding "yes" or "no".