Open ahuang11 opened 1 year ago
Would love to be able to both get
and set
the index programmatically.
The pn.state.location
component should already let you do this.
Nice, it does return "#/slide-2"
when calling pn.state.location.has
, but I don't know if this is the proper way of updating the hash to go to the next page (the URL changes, but it doesn't go to the next slide):
import panel as pn
pn.extension()
def get_slide(event):
# markdown.object = str({
# attr: str(getattr(pn.state.location, attr))
# for attr in dir(pn.state.location)
# })
markdown.object = str(pn.state.location.hash)
pn.state.location.hash = "#/slide-2"
button = pn.widgets.Button(name="Get slide")
button.on_click(get_slide)
markdown = pn.pane.Markdown(sizing_mode="stretch_both")
template = pn.template.SlidesTemplate(
title="Slide Template",
)
template.main.append("Hello")
template.main.append(pn.Column(button, markdown, scroll=True))
template.main.append("Next")
template.servable()
Sort of like
pn.Tabs
so users can click a button to go to a slide.A workaround is shown here https://discourse.holoviz.org/t/how-to-programmatically-jump-to-next-slide-using-button/5424