Skip to content

Commit

Permalink
Add support for embedding Player widget
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Aug 9, 2019
1 parent a49a9b7 commit 7331b61
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions panel/widgets/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class Player(PlayerBase):

value = param.Integer(default=0, doc="Current player value")

_supports_embed = True

def __init__(self, **params):
if 'length' in params:
if 'start' in params or 'end' in params:
Expand All @@ -55,6 +57,11 @@ def __init__(self, **params):
params['value'] = params['start']
super(Player, self).__init__(**params)

def _get_embed_state(self, root, max_opts=3):
return (self, self._models[root.ref['id']][0], range(self.start, self.end, self.step),
lambda x: x.value, 'value', 'cb_obj.value')



class DiscretePlayer(PlayerBase, SelectBase):
"""
Expand All @@ -69,6 +76,8 @@ class DiscretePlayer(PlayerBase, SelectBase):

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

_supports_embed = True

def _process_param_change(self, msg):
values = self.values
if 'options' in msg:
Expand Down

0 comments on commit 7331b61

Please sign in to comment.