Skip to content

Commit fc32f61

Browse files
committed
Lazily work-around interact docs
1 parent 911c044 commit fc32f61

File tree

7 files changed

+18
-19
lines changed

7 files changed

+18
-19
lines changed

doc/how_to/interact/interact_abbreviations.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ To use `interact`, you need to define a function that you want to explore. Here
1414

1515
```{pyodide}
1616
import panel as pn
17-
from panel.interact import interact
1817
from panel import widgets
1918
2019
pn.extension() # for notebook
@@ -26,7 +25,7 @@ def f(x):
2625
When you pass this function to `interact` along with `x=10`, a slider is generated and bound to the function parameter, such that when you interact with the widget, the function is called.
2726

2827
```{pyodide}
29-
interact(f, x=10)
28+
pn.interact(f, x=10)
3029
```
3130

3231
When you pass an integer-valued keyword argument of `10` (`x=10`) to `interact`, it generates an integer-valued slider control with a range of `[-10,+3*10]`. In this case, `10` is an *abbreviation* for an actual slider widget:
@@ -38,7 +37,7 @@ slider_widget = widgets.IntSlider(start=-10,end=30,step=1,value=10)
3837
In fact, we can get the same result if we pass this `IntSlider` as the keyword argument for `x`:
3938

4039
```{pyodide}
41-
interact(f, x=slider_widget)
40+
pn.interact(f, x=slider_widget)
4241
```
4342

4443
This examples clarifies how `interact` processes its keyword arguments:
@@ -64,35 +63,35 @@ If a 2-tuple of integers is passed `(min,max)`, an integer-valued slider is prod
6463

6564

6665
```{pyodide}
67-
interact(f, x=(0, 4))
66+
pn.interact(f, x=(0, 4))
6867
```
6968

7069
If a 3-tuple of integers is passed `(min,max,step)`, the step size can also be set.
7170

7271

7372
```{pyodide}
74-
interact(f, x=(0, 8, 2))
73+
pn.interact(f, x=(0, 8, 2))
7574
```
7675

7776
A float-valued slider is produced if the elements of the tuples are floats. Here the minimum is `0.0`, the maximum is `10.0` and step size is `0.1` (the default).
7877

7978

8079
```{pyodide}
81-
interact(f, x=(0.0, 10.0))
80+
pn.interact(f, x=(0.0, 10.0))
8281
```
8382

8483
The step size can be changed by passing a third element in the tuple.
8584

8685

8786
```{pyodide}
88-
interact(f, x=(0.0, 10.0, 0.01))
87+
pn.interact(f, x=(0.0, 10.0, 0.01))
8988
```
9089

9190
For both integer and float-valued sliders, you can pick the initial value of the widget by supplying a default keyword argument when you define the underlying Python function. Here we set the initial value of a float slider to `5.5`.
9291

9392

9493
```{pyodide}
95-
@interact(x=(0.0, 20.0, 0.5))
94+
@pn.interact(x=(0.0, 20.0, 0.5))
9695
def h(x=5.5):
9796
return x
9897
@@ -103,28 +102,28 @@ You can also set the initial value by passing a fourth element in the tuple.
103102

104103

105104
```{pyodide}
106-
interact(f, x=(0.0, 20.0, 0.5, 5.5))
105+
pn.interact(f, x=(0.0, 20.0, 0.5, 5.5))
107106
```
108107

109108
Use `None` as the third element to just set min, max, and value.
110109

111110

112111
```{pyodide}
113-
interact(f, x=(0.0, 20.0, None, 5.5))
112+
pn.interact(f, x=(0.0, 20.0, None, 5.5))
114113
```
115114

116115
Dropdown menus are constructed by passing a list of strings. In this case, the strings are both used as the names in the dropdown menu UI and passed to the underlying Python function.
117116

118117

119118
```{pyodide}
120-
interact(f, x=['apples', 'oranges'])
119+
pn.interact(f, x=['apples', 'oranges'])
121120
```
122121

123122
When working with numeric data ``interact`` will automatically add a discrete slider:
124123

125124

126125
```{pyodide}
127-
interact(f, x=dict([('one', 10), ('two', 20)]))
126+
pn.interact(f, x=dict([('one', 10), ('two', 20)]))
128127
```
129128

130129
## Related Resources

doc/how_to/interact/interact_fix_values.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ First, let's declare a simple function.
1212

1313
```{pyodide}
1414
import panel as pn
15-
from panel.interact import fixed
15+
from panel._interact import fixed
1616
pn.extension() # for notebook
1717
1818
def f(x, y):
1919
return x, y
2020
```
2121

22-
Now, call `interact` using the `panel.interact.fixed` function to fix one of the values:
22+
Now, call `interact` using the `panel._interact.fixed` function to fix one of the values:
2323

2424
```{pyodide}
2525
pn.interact(f, x=1, y=fixed(10))

panel/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
from . import (
5959
layout, links, pane, param, pipeline, template, viewable, widgets,
6060
)
61-
from .interact import interact
61+
from ._interact import interact
6262
from .io import serve, state
6363
from .io.cache import cache
6464
from .io.notebook import ( # noqa: F401
@@ -102,7 +102,7 @@
102102
"config": "panel.config:config",
103103
"custom": "panel.custom",
104104
"indicators": "panel.widgets:indicators",
105-
"interact": "panel.interact:interact",
105+
"interact": "panel._interact:interact",
106106
"ipywidget": "panel.io.notebook:ipywidget",
107107
"layout": "panel.layout",
108108
"links": "panel.links",
File renamed without changes.

panel/tests/pane/test_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
import panel as pn
55

6+
from panel._interact import interactive
67
from panel.chat import ChatMessage
78
from panel.config import config
8-
from panel.interact import interactive
99
from panel.io.loading import LOADING_INDICATOR_CSS_CLASS
1010
from panel.layout import Row
1111
from panel.links import CallbackGenerator

panel/tests/test_interact.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from bokeh.models import Column as BkColumn, Div as BkDiv
44

55
from panel import widgets
6-
from panel.interact import interactive
6+
from panel._interact import interactive
77
from panel.models import HTML as BkHTML
88
from panel.pane import HTML
99

panel/tests/test_viewable.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import panel.custom # To get the custom Viewable
55

66
from panel import config
7-
from panel.interact import interactive
7+
from panel._interact import interactive
88
from panel.pane import Markdown, Str, panel
99
from panel.param import ParamMethod
1010
from panel.viewable import Viewable, Viewer

0 commit comments

Comments
 (0)