Is there a way to trigger the sidebar button?
you can call openNav() anc closeNav() from javascript. One way is to create an dummy html pane and change the object.
import panel as pn
html = pn.pane.HTML("")
button_open = pn.widgets.Button(name="openNav")
button_close = pn.widgets.Button(name="closeNav")
def open(event):
html.object = f""" <script> openNav(); </script>"""
button_open.on_click(open)
def close(event):
html.object = f""" <script> closeNav(); </script>"""
button_close.on_click(close)
vanilla = pn.template.VanillaTemplate(title='toogle_nav')
vanilla.sidebar.append(html)
vanilla.main.append(button_open)
vanilla.main.append(button_close)
pn.serve(vanilla)
closenav
2 Likes