Open ahuang11 opened 7 months ago
Ok most minimal:
import param
import panel as pn
class TestParam(param.Parameterized):
a = param.Number(default=1, bounds=(0, 10))
b = param.String(default="b")
col = pn.Param(TestParam, width=100)
col
Solution is to loop through all the widgets and set width manually
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
An Alternative as posted in discourse, and re-posted below:
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
I think this is a bug I would expect the width in pn.Column
to be respected by the underlying widgets. A MRE:
import panel as pn
pn.extension()
pn.Column(
pn.widgets.IntSlider(value=1),
pn.widgets.TextInput(value="B"),
width=100,
)
What would you all think if Parameters would have a metadata
attribute (like attrs) in which you could stuff something like metadata={'panel': {'width': 100'}}
? A bit wordy but maybe less than having to pass kwargs to pn.Param
or to use Widget.from_param(param_insta, **kwargs)
.
Do you think there's other uses for metadata? If not, maybe just panel_kwargs
for explicitness?
panel_kwargs
as the key in the metadata dict?
I meant as the metadata dict itself (drop one layer of verbosity) panel_kwargs={'width': 100}
Param is agnostic to Panel or any other framework, I don't think a panel_kwargs
attribute is desirable.
Maybe gui_kwargs then?
I've already had the need for a metadata
attribute (not related to Panel or any GUI) and have abused precedence
instead, so I think I'd push more anyway for a generic metadata
attribute. But precedence
is a good example as is definitely has a GUI flavor. Let's get feedback from others!
I see. If you already have a need for metadata attribute, then go with metadata
> panel
.
I was just concerned of over-designing it and having it too verbose for anyone to actually use.
The widgets are cut off
More minimal:
Seems like slider respects width, but not TextInput