Skip to content

How to access the timer object from Python #154

Answered by ramedina86
sriver asked this question in Q&A
Discussion options

You must be logged in to vote

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 @{is_timer_active}, rather than hardcoding "yes" or "no".

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sriver
Comment options

Answer selected by sriver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants