Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use widget_type for Param widget override #1614

Merged
merged 2 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/user_guide/Param.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Also, it's possible to pass arguments to the widget in order to customize it. Instead of passing the widget, pass a dictionary with the desired options. Use the ``type`` keyword to map the widget. \n",
"Also, it's possible to pass arguments to the widget in order to customize it. Instead of passing the widget, pass a dictionary with the desired options. Use the ``widget_type`` keyword to map the widget. \n",
"\n",
"Taking up the previous example."
]
Expand All @@ -217,7 +217,7 @@
"outputs": [],
"source": [
"pn.Param(CustomExample.param, widgets={\n",
" 'select_string': {'type': pn.widgets.RadioButtonGroup, 'button_type': 'success'},\n",
" 'select_string': {'widget_type': pn.widgets.RadioButtonGroup, 'button_type': 'success'},\n",
" 'select_number': pn.widgets.DiscretePlayer}\n",
")"
]
Expand Down
8 changes: 5 additions & 3 deletions panel/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,14 @@ def widget(self, p_name):
widget_class_overridden = False
widget_class = self.widget_type(p_obj)
elif isinstance(self.widgets[p_name], dict):
if 'type' in self.widgets[p_name]:
widget_class = self.widgets[p_name].pop('type')
kw_widget = dict(self.widgets[p_name])
if 'widget_type' in self.widgets[p_name]:
widget_class = kw_widget.pop('widget_type')
elif 'type' in self.widgets[p_name]:
widget_class = kw_widget.pop('type')
else:
widget_class_overridden = False
widget_class = self.widget_type(p_obj)
kw_widget = self.widgets[p_name]
else:
widget_class = self.widgets[p_name]

Expand Down