I have a multi-page app using the Bootstrap template. Two of these pages have tabs. Initial navigation works but subsequent switching between tabs does not refresh the content in the main area. Navigating to a non-tabbed page works fine. No error messages appear, so I have no idea how to fix this. Any help is appreciated.
Panel 1.2.3, python 3.9.16, browser is Chrome on Linux.
Minimum working example below:
import panel as pn
pn.extension()
###################################################################
class P1:
def __init__(self):
self.T1C = pn.pane.Markdown("## Content for Page 1, Tab1",name='Page 1, Tab1')
self.T2C = pn.pane.Markdown("## Content for Page 1, Tab2",name='Page 1, Tab2')
def GetLayout(self):
self.Tabs = pn.Tabs(dynamic=True)
self.Tabs.extend([self.T1C,self.T2C])
self.layout = pn.Column('Hello World from Page 1',self.Tabs)
return (self.layout)
###################################################################
class P2:
def __init__(self):
self.T1C = pn.pane.Markdown("## Content for Page 2, Tab1",name='Page 2, Tab1')
self.T2C = pn.pane.Markdown("## Content for Page 2, Tab2",name='Page 2, Tab2')
self.T3C = pn.pane.Markdown("## Content for Page 2, Tab3",name='Page 2, Tab3')
def GetLayout(self):
self.Tabs = pn.Tabs(dynamic=True)
self.Tabs.extend([self.T1C,self.T2C,self.T3C])
self.layout = pn.Column('Hello World from Page 2',self.Tabs)
return (self.layout)
###################################################################
pages = {
"Welcome": pn.Column('Welcome Page'),
"P1": P1().GetLayout(),
"P2": P2().GetLayout(),
}
NavGrouping = {'Start':['Welcome'],'Pages':['P1','P2']}
###################################################################
def show(page):
return pages[page]
def appmain():
starting_page = pn.state.session_args.get("page", [b"Welcome"])[0].decode()
PageSelector = pn.widgets.Select(
value=starting_page,
#options=['P1','P2'],
groups=NavGrouping,
name="Navigation",
width=200
)
ishow = pn.bind(show, page=PageSelector)
pn.state.location.sync(PageSelector,{"value": "page"}) # Shows up in URL as ?page=<SelectedPage>
TLayout = pn.template.BootstrapTemplate(
title="MWE Test",
sidebar=[PageSelector],
main=[ishow]
).servable()
return (TLayout)
###################################################################
appmain()