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

Misc, player and select docstrings #3366

Merged
merged 4 commits into from
Apr 12, 2022
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
40 changes: 40 additions & 0 deletions panel/widgets/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@


class VideoStream(Widget):
"""
The `VideoStream` displays a video from a local stream (for example from a webcam) and allows
accessing the streamed video data from Python.

Reference: https://panel.holoviz.org/reference/widgets/VideoStream.html

:Example:

>>> VideoStream(name='Video Stream', timeout=100)
"""

format = param.ObjectSelector(default='png', objects=['png', 'jpeg'],
doc="""
Expand Down Expand Up @@ -51,6 +61,18 @@ def snapshot(self):


class FileDownload(Widget):
"""
The `FileDownload` widget allows a user to download a file.

It works either by sending the file data to the browser on initialization
(`embed`=True), or when the button is clicked.

Reference: https://panel.holoviz.org/reference/widgets/FileDownload.html

:Example:

>>> FileDownload(file='IntroductionToPanel.ipynb', filename='intro.ipynb')
"""

auto = param.Boolean(default=True, doc="""
Whether to download on the initial click or allow for
Expand Down Expand Up @@ -204,6 +226,24 @@ def _transfer(self):


class JSONEditor(Widget):
"""
The `JSONEditor` provides a visual editor for JSON-serializable
datastructures, e.g. Python dictionaries and lists, with functionality for
different editing modes, inserting objects and validation using JSON
Schema.

Reference: https://panel.holoviz.org/reference/widgets/JSONEditor.html

:Example:

>>> JSONEditor(value={
... 'dict' : {'key': 'value'},
... 'float' : 3.14,
... 'int' : 1,
... 'list' : [1, 2, 3],
... 'string': 'A string',
... }, mode='code')
"""

menu = param.Boolean(default=True, doc="""
Adds main menu bar - Contains format, sort, transform, search
Expand Down
30 changes: 23 additions & 7 deletions panel/widgets/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ def reverse(self):

class Player(PlayerBase):
"""
The Player provides controls to play and skip through a number of
The `Player` provides controls to play and skip through a number of
frames defined by explicit start and end values. The speed at
which the widget plays is defined by the interval, but it is also
possible to skip frames using the step parameter.
which the widget plays is defined by the `interval`, but it is also
possible to skip frames using the `step` parameter.

Reference: https://panel.holoviz.org/reference/widgets/Player.html

:Example:

>>> Player(name='Player', start=0, end=100, value=32, loop_policy='loop')
"""

start = param.Integer(default=0, doc="Lower bound on the slider value")
Expand Down Expand Up @@ -84,15 +90,25 @@ def _get_embed_state(self, root, values=None, max_opts=3):

class DiscretePlayer(PlayerBase, SelectBase):
"""
The DiscretePlayer provides controls to iterate through a list of
The `DiscretePlayer` provides controls to iterate through a list of
discrete options. The speed at which the widget plays is defined
by the interval, but it is also possible to skip items using the
step parameter.
by the `interval`, but it is also possible to skip items using the
`step` parameter.

Reference: https://panel.holoviz.org/reference/widgets/DiscretePlayer.html

:Example:

>>> DiscretePlayer(
... name='Discrete Player',
... options=[2, 4, 8, 16, 32, 64, 128], value=32,
... loop_policy='loop'
... )
"""

interval = param.Integer(default=500, doc="Interval between updates")

value = param.Parameter()
value = param.Parameter(doc="Current player value")

_rename = {'name': None, 'options': None}

Expand Down
148 changes: 148 additions & 0 deletions panel/widgets/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ def _get_embed_state(self, root, values=None, max_opts=3):


class Select(SingleSelectBase):
"""
The `Select` widget allows selecting a value from a list or dictionary of
`options` by selecting it from a dropdown menu or selection area.

It falls into the broad category of single-value, option-selection widgets
that provide a compatible API and include the `RadioBoxGroup`,
`AutocompleteInput` and `DiscreteSlider` widgets.

Reference: https://panel.holoviz.org/reference/widgets/Select.html

:Example:

>>> Select(name='Study', options=['Biology', 'Chemistry', 'Physics'])
"""

disabled_options = param.List(default=[], doc="""
Optional list of ``options`` that are disabled, i.e. unusable and
Expand Down Expand Up @@ -303,6 +317,23 @@ def _process_property_change(self, msg):


class MultiSelect(_MultiSelectBase):
"""
The `MultiSelect` widget allows selecting multiple values from a list of
`options`.

It falls into the broad category of multi-value, option-selection widgets
that provide a compatible API and include the`CrossSelector`,
`CheckBoxGroup` and `CheckButtonGroup` widgets.

Reference: https://panel.holoviz.org/reference/widgets/MultiSelect.html

:Example:

>>> MultiSelect(
... name='Frameworks', value=['Bokeh', 'Panel'],
... options=['Bokeh', 'Dash', 'Panel', 'Streamlit', 'Voila'], size=8
... )
"""

size = param.Integer(default=4, doc="""
The number of items displayed at once (i.e. determines the
Expand All @@ -312,6 +343,27 @@ class MultiSelect(_MultiSelectBase):


class MultiChoice(_MultiSelectBase):
"""
The `MultiChoice` widget allows selecting multiple values from a list of
`options`.

It falls into the broad category of multi-value, option-selection widgets
that provide a compatible API and include the `MultiSelect`,
`CrossSelector`, `CheckBoxGroup` and `CheckButtonGroup` widgets.

The `MultiChoice` widget provides a much more compact UI than
`MultiSelect`.

Reference: https://panel.holoviz.org/reference/widgets/MultiChoice.html

:Example:

>>> MultiChoice(
... name='Favourites', value=['Panel', 'hvPlot'],
... options=['Panel', 'hvPlot', 'HoloViews', 'GeoViews', 'Datashader', 'Param', 'Colorcet'],
... max_items=2
... )
"""

delete_button = param.Boolean(default=True, doc="""
Whether to display a button to delete a selected option.""")
Expand All @@ -338,6 +390,26 @@ class MultiChoice(_MultiSelectBase):


class AutocompleteInput(Widget):
"""
The `MultiChoice` widget allows selecting multiple values from a list of
`options`.

It falls into the broad category of multi-value, option-selection widgets
that provide a compatible API and include the `MultiSelect`,
`CrossSelector`, `CheckBoxGroup` and `CheckButtonGroup` widgets.

The `MultiChoice` widget provides a much more compact UI than
`MultiSelect`.

Reference: https://panel.holoviz.org/reference/widgets/AutocompleteInput.html

:Example:

>>> AutocompleteInput(
... name='Study', options=['Biology', 'Chemistry', 'Physics'],
... placeholder='Write your study here ...'
... )
"""

case_sensitive = param.Boolean(default=True, doc="""
Enable or disable case sensitivity.""")
Expand Down Expand Up @@ -429,6 +501,23 @@ def _get_embed_state(self, root, values=None, max_opts=3):


class RadioButtonGroup(_RadioGroupBase, _ButtonBase):
"""
The `RadioButtonGroup` widget allows selecting from a list or dictionary
of values using a set of toggle buttons.

It falls into the broad category of single-value, option-selection widgets
that provide a compatible API and include the `RadioBoxGroup`, `Select`,
and `DiscreteSlider` widgets.

Reference: https://panel.holoviz.org/reference/widgets/RadioButtonGroup.html

:Example:

>>> RadioButtonGroup(
... name='Plotting library', options=['Matplotlib', 'Bokeh', 'Plotly'],
... button_type='success'
... )
"""

orientation = param.Selector(default='horizontal',
objects=['horizontal', 'vertical'], doc="""
Expand All @@ -441,6 +530,22 @@ class RadioButtonGroup(_RadioGroupBase, _ButtonBase):


class RadioBoxGroup(_RadioGroupBase):
"""
The `RadioBoxGroup` widget allows selecting from a list or dictionary of
values using a set of checkboxes.

It falls into the broad category of single-value, option-selection widgets
that provide a compatible API and include the `RadioButtonGroup`, `Select`
and `DiscreteSlider` widgets.

Reference: https://panel.holoviz.org/reference/widgets/RadioBoxGroup.html

:Example:

>>> RadioBoxGroup(
... name='Sponsor', options=['Anaconda', 'Blackstone'], inline=True
... )
"""

inline = param.Boolean(default=False, doc="""
Whether the items be arrange vertically (``False``) or
Expand Down Expand Up @@ -491,6 +596,23 @@ def _process_property_change(self, msg):


class CheckButtonGroup(_CheckGroupBase, _ButtonBase):
"""
The `CheckButtonGroup` widget allows selecting between a list of options
by toggling the corresponding buttons.

It falls into the broad category of multi-option selection widgets that
provide a compatible API and include the `MultiSelect`, `CrossSelector`
and `CheckBoxGroup` widgets.

Reference: https://panel.holoviz.org/reference/widgets/CheckButtonGroup.html

:Example:

>>> CheckButtonGroup(
... name='Regression Models', value=['Lasso', 'Ridge'],
... options=['Lasso', 'Linear', 'Ridge', 'Polynomial']
... )
"""

orientation = param.Selector(default='horizontal',
objects=['horizontal', 'vertical'], doc="""
Expand All @@ -500,6 +622,23 @@ class CheckButtonGroup(_CheckGroupBase, _ButtonBase):


class CheckBoxGroup(_CheckGroupBase):
"""
The `CheckBoxGroup` widget allows selecting between a list of options by
ticking the corresponding checkboxes.

It falls into the broad category of multi-option selection widgets that
provide a compatible API and include the `MultiSelect`, `CrossSelector`
and `CheckButtonGroup` widgets.

Reference: https://panel.holoviz.org/reference/widgets/CheckBoxGroup.html

:Example:

>>> CheckBoxGroup(
... name='Fruits', value=['Apple', 'Pear'], options=['Apple', 'Banana', 'Pear', 'Strawberry'],
... inline=True
... )
"""

inline = param.Boolean(default=False, doc="""
Whether the items be arrange vertically (``False``) or
Expand Down Expand Up @@ -560,6 +699,15 @@ class CrossSelector(CompositeWidget, MultiSelect):
A composite widget which allows selecting from a list of items
by moving them between two lists. Supports filtering values by
name to select them in bulk.

Reference: https://panel.holoviz.org/reference/widgets/CrossSelector.html

:Example:

>>> CrossSelector(
... name='Fruits', value=['Apple', 'Pear'],
... options=['Apple', 'Banana', 'Pear', 'Strawberry']
... )
"""

width = param.Integer(default=600, allow_None=True, doc="""
Expand Down