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 Select widget for ObjectSelector #362

Merged
merged 2 commits into from
Apr 3, 2019
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
19 changes: 3 additions & 16 deletions panel/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,8 @@
from .viewable import Layoutable, Reactive
from .widgets import (
LiteralInput, Select, Checkbox, FloatSlider, IntSlider, RangeSlider,
MultiSelect, StaticText, Button, Toggle, TextInput, DiscreteSlider,
DatetimeInput, DateRangeSlider, ColorPicker, Widget)


def ObjectSelector(pobj):
"""
Determines param.ObjectSelector widget depending on whether all values
are numeric.
"""
options = list(pobj.objects.values()) if isinstance(pobj.objects, dict) else pobj.objects
if options and all(param._is_number(o) for o in options):
return DiscreteSlider
else:
return Select
MultiSelect, StaticText, Button, Toggle, TextInput, DatetimeInput,
DateRangeSlider, ColorPicker, Widget)


def FileSelector(pobj):
Expand All @@ -55,7 +43,6 @@ def FileSelector(pobj):
return TextInput



class Param(PaneBase):
"""
Param panes render a Parameterized class to a set of widgets which
Expand Down Expand Up @@ -120,7 +107,7 @@ class Param(PaneBase):
param.Color: ColorPicker,
param.Dict: LiteralInput,
param.Selector: Select,
param.ObjectSelector: ObjectSelector,
param.ObjectSelector: Select,
param.FileSelector: FileSelector,
param.Boolean: Checkbox,
param.Number: FloatSlider,
Expand Down