Generate active tab from a button click

I have a very simple gui interface for plotting, data viewing, etc. I am using tabs for different views of the data, i.e., plots, dataframe, image overlays, etc. I set up viewing conditions and then want to press a button to change the active tab with the selected parameter view. However, the on_click method does not accept a tab. How can I call the active tabs method from a button click?
Thanks, Moody

e = Exp(name=“Experiment”)
elist = [‘exp1’, ‘exp2’ ]
we = pn.widgets.Select(name=“Experiment”, options=elist, value=‘exp1’)
vars = e.vlist()
w = pn.widgets.Select(name=“X Variable”, options=vars, value=’’)
go = pn.widgets.Button(name=‘Do it’, button_type=‘primary’)

col = pn.Column(we, w, go, width=300)
t = pn.Tabs((‘Plot’, e.plot(we.value)))

t.extend([(‘PlotData’, e.plotd), (‘Desc’, e.desc), (‘Overlay’, e.overlay), (‘Variables’, e.vars), (‘Fixed Parms’, e.fixed)] )
row = pn.Row(col, t)

Welcome Moody. It may be easier to answer your question with a reproducible example. It is unclear how Exp is defined, and so its tough to know whats going wrong. That said, based on your narrative, you’re looking for something like this?

import panel as pn

tabs = pn.Tabs(('tab1', pn.pane.Markdown('### Tab 1 display')),
               ('tab2', pn.pane.Markdown('### Tab 2 display')),
               ('tab3', pn.pane.Markdown('### Tab 3 display')))

action1 = pn.widgets.Button(name='Tab 1')
def click1(click): = 0

action2 = pn.widgets.Button(name='Tab 2')
def click2(click): = 1

action3 = pn.widgets.Button(name='Tab 3')
def click3(click): = 2

pn.Row(pn.Column(action1, action2, action3), tabs).servable()
1 Like