Skip to content

Commit

Permalink
Bug fix for player example pause button (#6212)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirage007 authored Apr 29, 2024
1 parent eb7ae9d commit 1dbea2c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions examples/reference/apps/bokeh/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ def slider_update(attrname, old, new):
slider = Slider(start=start, end=end, value=0, step=1, title="Year")
slider.on_change('value', slider_update)

callback_tasks = {}

def animate():
if button.label == '► Play':
button.label = '❚❚ Pause'
curdoc().add_periodic_callback(animate_update, 200)
if button.label == "► Play":
button.label = "❚❚ Pause"
callback_tasks["animate"] = curdoc().add_periodic_callback(animate_update, 400)
else:
button.label = '► Play'
curdoc().remove_periodic_callback(animate_update)
button.label = "► Play"
curdoc().remove_periodic_callback(callback_tasks["animate"])


button = Button(label='► Play', width=60)
button.on_click(animate)
Expand Down

0 comments on commit 1dbea2c

Please sign in to comment.