From b648692fd15fa34aefa068cd79c1b4c2ac7557ea Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Tue, 6 Oct 2020 15:19:35 +0200 Subject: [PATCH] Use widget_type for Param widget override (#1614) * Use widget_type for Param widget override * Add docs --- examples/user_guide/Param.ipynb | 4 ++-- panel/param.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/user_guide/Param.ipynb b/examples/user_guide/Param.ipynb index fd0e803419a..9feaeda4dff 100644 --- a/examples/user_guide/Param.ipynb +++ b/examples/user_guide/Param.ipynb @@ -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." ] @@ -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", ")" ] diff --git a/panel/param.py b/panel/param.py index 63e3e4d2770..8f8742575c2 100644 --- a/panel/param.py +++ b/panel/param.py @@ -341,12 +341,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]