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

Do not override widget class if already specified by user #1301

Merged
merged 1 commit into from
Apr 26, 2020
Merged
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
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