Dynamically update the name/title of a layout

I’m wondering if it is possible to dynamically update the name of a Layout like pn.layout.Column.

Take the following example where I may want to rename the tab:

import panel as pn
import param

widget = pn.widgets.TextInput(name="Name of tab", value="Hello")

a = pn.layout.Column(widget, name=widget.param.value)
b = pn.layout.Column(name='Other')

t = pn.Tabs(a, b)

Screenshot 2024-03-07 at 3.33.11 PM

It seems the only way to rename the component is to recreate it or remove and re-add the tab. I’m curious if its possible to set the name of a component/layout based on a param value?

My end goal here is to be able to rename the tab title without removing and re-adding the tab so also curious about other workarounds for this

Not at the moment

I think that this is a side effect of a bigger issue that I raised here: Widget name should not really be used for label/title - #3 by pjsulin

Might want to raise that in Panel issues and solicit feedback from others.

I think you should raise it as as Panel issue.

I’ve inspected the implementation of Tabs and the way its implemented tabs.param.trigger("object") would not update anything. I believe that is a bug.


Currently I would do as below

import panel as pn

widget = pn.widgets.TextInput(name="Name of tab", value="Hello")

a = pn.layout.Column(widget, name=widget.value)
b = pn.layout.Column(name='Other')

tabs=pn.Tabs(a, b)

@pn.depends(widget, watch=True)
def a_view(value):
    new_a =pn.Column(*a, name=widget.value)
    tabs[:]=[new_a, b]