2

I have defined a custom Parameterized class the folowing way:

class Myclass(param.Parameterized):

    var1 = param.ObjectSelector(
        objects=['A', 'B', 'C'],
        default='B',
        label='Param1',
    )

    seg3 = param.ObjectSelector(
        objects={
            'First group': 'ZK',
            'Second one': 'ZL',
        },
        default='ZL',
        label='Groups',
    )

Whenever I want to instanciate this class and generate a Pane with widgets to select parameters, as per the documentation I use the following:

instance = Myclass()
pn.panel(instance.param)

This gives me the following output:

Panel with widget and title

I would like to know how I could get to modify the title that appears to default to the class name? Ideally, it would be at the pn.panel(...) level as I would like to have control on specific title, should I split these widgets in several panes.

See:

pn.Row(
    pn.panel(
        instance.param, 
        parameters=['var1']
    ),
    pn.panel(
        instance.param, 
        parameters=['seg3']
    )
)

which yields (and I would like to specify custom titles for each pane):

Panel split in two

Sander van den Oord
  • 10,986
  • 5
  • 51
  • 96
Pierre Massé
  • 693
  • 1
  • 5
  • 23

1 Answers1

3

You can change the name as follows:

instance = Myclass(name='Different Name')

This results in your case in the following:

panel pyviz app name changed

Please note that can also get parameters without using pn.panel() as follows:

pn.Row(
    instance.param.var1,
    instance.param.seg3,
)

You can do this for example if you don't want to see the name and just use something like pn.pane.HTML() to add a different title.

Sander van den Oord
  • 10,986
  • 5
  • 51
  • 96
  • I had the feeling that you would be answering this one Sander! Thanks for the answer and the tags edit, it worked perfectly. – Pierre Massé Jan 08 '21 at 08:21