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

Add support for param.Event #1600

Merged
merged 1 commit into from
Oct 5, 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
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