Display a Panel component's param keys and options

Hi @ahuang11. Very interesting point. I stumbled across the .param list the other day, when trying to figure out what .Param and .controls do to display all the options of an object. I find .controls to be very useful for this.

Have you read this Discord thread with discussion I had with @jbednar regarding display of a components params / options?

So there is widget.param, which shows your (static) list, but there is also pn.Param(widget), which shows a nice column of editable fields with widget attributes and params.

And then there is widget.controls , which also shows editable fields. But the field lists of . controls are not the all the same as in the .Param field column.

See short code example below that shows a row with the button widget, the Param field column and .control. field columns, called Layout and Control.

The strange thing is: changing field values in the .controls updates the button widget in the row straightaway (changes colour, height, etc.).

But in contrast, changing values in the .param fields has no effect on the widget. Not in the row, and not when (re)-executing the widget in the next cell in a Notebook.

Do you know why changing the param fields has not effect on the widget ? In your other post on best practices, you make a remark about using pn.Param vs. _param. Could that be the cause of the above behavior?

you can use pn.Param to convert the class’ params to widgets, but sometimes working with nested dicts is a pain so I use from_param classmethod instead which allows syncing up widget values with param values

So does that mean that it isexpected behavior that using pn. Param as I described does not update the widget?

Would really like to hear your thoughts on this. Am curious if you observe the same behavior as I described, when using the small code snippet below.

Code example:

import panel as pn
pn.extension()
w1 = pn.widgets.Button(name='Click me 01')
pn.Param(w1)
w1column=pn.Column(w1.controls)
pn.Row(w1, pn.Param(w1), pn.Column(w1.param), w1column, w1column.controls(['visible']))

The code displays a row with with columns that will show the widget and its params and controls . There is a lot of overlap between the 2, but the .params column shows fields that .controls does not (like

Changes in .controls fields are immediately updated in the component.

However, changes in the .param fields do not change the widget, even when re-executing the widget in a next cell in a Notebook. Very counter-intuitive.

PS You can even also do widget.param, which produces a static list of all parameters (including empty ones. This list include the name = argument of the button, and its value, even though this does NOT show up in the field lists of .Param or .controls.

Param doc reference here .