Skip to content

Commit

Permalink
Add support for param.Event (#1600)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Oct 5, 2020
1 parent b151ae6 commit 186b16b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion panel/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class Param(PaneBase):
param.String: TextInput,
}

if hasattr(param, 'Event'):
_mapping[param.Event] = Button

_rerender_params = []

def __init__(self, object=None, **params):
Expand Down Expand Up @@ -404,7 +407,11 @@ def link_widget(change):
finally:
self._updating.remove(p_name)

if isinstance(p_obj, param.Action):
if hasattr(param, 'Event') and isinstance(p_obj, param.Event):
def event(change):
self.object.param.trigger(p_name)
watcher = widget.param.watch(event, 'clicks')
elif isinstance(p_obj, param.Action):
def action(change):
value(self.object)
watcher = widget.param.watch(action, 'clicks')
Expand Down Expand Up @@ -443,6 +450,8 @@ def link(change, watchers=[watcher]):
updates['name'] = p_obj.label
elif p_name in self._updating:
return
elif hasattr(param, 'Event') and isinstance(p_obj, param.Event):
return
elif isinstance(p_obj, param.Action):
prev_watcher = watchers[0]
widget.param.unwatch(prev_watcher)
Expand Down

0 comments on commit 186b16b

Please sign in to comment.