How to update default param for pn.Param widgets?

I want to do something like pn.widgets.TextInput.width = 200, but not globally…

Specifically, I want to do something like:

MAPPING = {
    key: value for key, value in pn.Param.mapping.items()
}
pn.Param(..., widgets=MAPPING)

with the mapped value widths to be 200.

Looping through each item works.

import param
import panel as pn
import holoviews as hv

class TestParam(param.Parameterized):

    a = param.Number(default=1, bounds=(0, 10))
    b = param.String(default="b")

col = pn.Param(TestParam, width=100)
for widget in col:
    widget.width = 100
col
1 Like

An alternative to the for loop after the creation is:

import param
import panel as pn
import holoviews as hv

pn.extension()

class TestParam(param.Parameterized):

    a = param.Number(default=1, bounds=(0, 10))
    b = param.String(default="b")


dd = {k: {"width": 100} for k in TestParam.param}
col = pn.Param(TestParam, width=100, widgets=dd)
col
2 Likes