Changing widget on tab2 refreshes and takes to Tab1

Hi, I am building app where i have multiple tabs. Each of the tab contains few widgets. Within a tab, there is a base widget and there are other widgets whose value are function of the base widget.
So while working in Tab 2 (lets say), if i change the value of base widget I expect to see the dependent widgets getting changed accordingly. But as soon as i change the base widget, I am taken to Tab 1, although the widgets of Tab 2 are changed. I am getting the desired output in Tab 2 widgets but I don’t want to be taken to Tab 1 when I change something in Tab2

So is there a way that changing something in Tab 2 to trigger a function call in Tab 2 doesn’t take me to Tab 1?

Following is the code for easy understanding (also attaching image of the same):

widget_a = pn.widgets.TextInput(name=“a”, width=60, value=‘4’)
widget_b = pn.widgets.TextInput(name=“b”, width=60, value=‘7’)

def b_operation(b):
my_dict={}
x2=float(b)*6
y2=float(b)+7
my_dict.update({‘x2’:x2, ‘y2’:y2})
return my_dict

def get_sheet(variable):
sheet_widgets = pn.Column(widget_b,
pn.widgets.TextInput(name= “var3”, width = 60, value = str(variable[“x2”])),
pn.widgets.TextInput(name= “var4”, width = 60, value = str(variable[“y2”])))
return sheet_widgets

@pn.depends(widget_a.param.value, widget_b.param.value)
def show_tabs(widget_a_value, widget_b_value):
result = b_operation(widget_b_value)
sheet = get_sheet(result)
show = pn.Tabs((“Tab 1”, widget_a), (“Tab 2”, sheet))
return show

disp = pn.Column(show_tabs)
pn.serve(disp)

import panel as pn
pn.extension()
widget_a = pn.widgets.TextInput(name='a', width=60, value='4')
widget_b = pn.widgets.TextInput(name='b', width=60, value='7')

def b_operation(b):
    my_dict={}
    x2=float(b)*6
    y2=float(b)+7
    my_dict.update({'x2':x2, 'y2':y2})
    return my_dict

def get_sheet(variable):
    sheet_widgets = pn.Column(widget_b,
    pn.widgets.TextInput(name= 'var3', width = 60, value = str(variable['x2'])),
    pn.widgets.TextInput(name= 'var4', width = 60, value = str(variable['y2'])))
    return sheet_widgets

def show_tabs(event):
    result = b_operation(widget_b.value)
    sheet = get_sheet(result)
    tabs[1] = ("Tab 2", sheet)

tabs = pn.Tabs(('Tab 1', widget_a), ('Tab 2', get_sheet(b_operation(widget_b.value))))
widget_a.param.watch(show_tabs, "value")
widget_b.param.watch(show_tabs, "value")
disp = pn.Column(tabs)

disp

Probably can be more fine grained too

Thanks for the reply.
I would like to do it within a function. Any idea why the following doesn’t work out?

import panel as pn
pn.extension()
widget_a = pn.widgets.TextInput(name=‘a’, width=60, value=‘4’)
widget_b = pn.widgets.TextInput(name=‘b’, width=60, value=‘7’)

def b_operation(b):
my_dict={}
x2=float(b)*6
y2=float(b)+7
my_dict.update({‘x2’:x2, ‘y2’:y2})
return my_dict

def get_sheet(variable):
sheet_widgets = pn.Column(widget_b,
pn.widgets.TextInput(name= ‘var3’, width = 60, value = str(variable[‘x2’])),
pn.widgets.TextInput(name= ‘var4’, width = 60, value = str(variable[‘y2’])))
return sheet_widgets

def show_tabs(event):
result = b_operation(widget_b.value)
sheet = get_sheet(result)
tabs[1] = (“Tab 2”, sheet)

@pn.depends(widget_a.param.value, widget_b.param.value)
def run_app(widget_a_value, widget_b_value):
tabs = pn.Tabs((‘Tab 1’, widget_a), (‘Tab 2’, get_sheet(b_operation(widget_b_value))))
widget_b.param.watch(show_tabs, “value”)
disp = pn.Column(tabs)
app = pn.Column(disp)
pn.serve(app)


run_app(widget_a.value, widget_b.value)