Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 | 2 |
from __future__ import absolute_import, division, unicode_literals |
2 |
|
|
3 | 2 |
import param |
4 |
|
|
5 | 2 |
from .widgets import Widget |
6 |
|
|
7 | 2 |
ipywidget_classes = {} |
8 |
|
|
9 |
|
|
10 | 2 |
def param_value_if_widget(arg): |
11 | 2 |
if isinstance(arg, Widget): |
12 | 2 |
return arg.param.value |
13 |
|
|
14 |
from .pane.ipywidget import IPyWidget |
|
15 |
if IPyWidget.applies(arg) and hasattr(arg, 'value'): |
|
16 |
name = type(arg).__name__ |
|
17 |
if name in ipywidget_classes: |
|
18 |
ipy_param = ipywidget_classes[name] |
|
19 |
else: |
|
20 |
ipy_param = param.parameterized_class(name, {'value': param.Parameter()}) |
|
21 |
ipywidget_classes[name] = ipy_param |
|
22 |
ipy_inst = ipy_param(value=arg.value) |
|
23 |
arg.observe(lambda event: ipy_inst.param.set_param(value=event['new']), 'value') |
|
24 |
return ipy_inst.param.value |
|
25 |
return arg |
|
26 |
|
|
27 |
|
|
28 | 2 |
def depends(*args, **kwargs): |
29 | 2 |
updated_args = [param_value_if_widget(a) for a in args] |
30 | 2 |
updated_kwargs = {k: param_value_if_widget(v) for k, v in kwargs.items()} |
31 |
|
|
32 | 2 |
return param.depends(*updated_args, **updated_kwargs) |
Read our documentation on viewing source code .