Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document removing and adjusting a periodic callback period #574

Closed
ahuang11 opened this issue Aug 6, 2019 · 2 comments
Closed

Document removing and adjusting a periodic callback period #574

ahuang11 opened this issue Aug 6, 2019 · 2 comments
Labels
good first issue Good for newcomers type: docs Related to the Panel documentation and examples

Comments

@ahuang11
Copy link
Contributor

ahuang11 commented Aug 6, 2019

While I was creating #573, I thought it'd be nice to modify the periodic callback period or remove it completely.

import panel as pn
import numpy as np
pn.extension()

def generate_random_number(event=None):
    static_text.value = np.random.randint(low=100000, high=200000)

static_text = pn.widgets.StaticText(name='Periodic Random Number Generator',
                                    value='000000')
static_text.add_periodic_callback(generate_random_number,
                                  period=5000)  # period in milliseconds

request_button = pn.widgets.Button(name='Request New Number')
request_button.on_click(generate_random_number)

col = pn.Column(request_button, static_text)
col.servable()

Add something like

static_text.remove_periodic_callback()

Similar to static_text.param.unwatch

Also,

static_text.periodic_callback.period = 1000

Similar to static_text.value = 'something else'

@ahuang11 ahuang11 added the TRIAGE Default label for untriaged issues label Aug 6, 2019
@philippjfr philippjfr changed the title Removing a periodic callback / adjusting a periodic callback period Document removing and adjusting a periodic callback period Aug 6, 2019
@philippjfr
Copy link
Member

This is already possible, just needs to be documented:

callback = static_text.add_periodic_callback(generate_random_number,
                                  period=5000)  # period in milliseconds
callback.stop()

@philippjfr philippjfr added good first issue Good for newcomers type: docs Related to the Panel documentation and examples and removed TRIAGE Default label for untriaged issues labels Aug 6, 2019
@ahuang11
Copy link
Contributor Author

#573

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: docs Related to the Panel documentation and examples
Projects
None yet
Development

No branches or pull requests

2 participants