Skip to content

Commit

Permalink
do not change param.Number widget class if already overridden by user (
Browse files Browse the repository at this point in the history
…#1301)

Co-authored-by: poplarShift <poplarShift@users.noreply.github.com>
  • Loading branch information
poplarShift and poplarShift authored Apr 26, 2020
1 parent 1df70b5 commit 5282159
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions panel/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ def widget(self, p_name):
p_obj = self.object.param[p_name]
kw_widget = {}

widget_class_overridden = True
if self.widgets is None or p_name not in self.widgets:
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]:
Expand Down Expand Up @@ -347,12 +349,14 @@ def widget(self, p_name):
if bounds[1] is not None:
kw['end'] = bounds[1]
if ('start' not in kw or 'end' not in kw):
if isinstance(p_obj, param.Number):
widget_class = Spinner
if isinstance(p_obj, param.Integer):
kw['step'] = 1
elif not issubclass(widget_class, LiteralInput):
widget_class = LiteralInput
# Do not change widget class if _mapping was overridden
if not widget_class_overridden:
if isinstance(p_obj, param.Number):
widget_class = Spinner
if isinstance(p_obj, param.Integer):
kw['step'] = 1
elif not issubclass(widget_class, LiteralInput):
widget_class = LiteralInput
if hasattr(widget_class, 'step') and getattr(p_obj, 'step', None):
kw['step'] = p_obj.step

Expand Down

0 comments on commit 5282159

Please sign in to comment.