Skip to content

Commit b105496

Browse files
authored
Merge pull request #57 from martinRenou/pyparis_widgets
Pyparis widgets
2 parents f84b530 + 1e574d3 commit b105496

File tree

7 files changed

+177
-26
lines changed

7 files changed

+177
-26
lines changed

2018-11-14-PyParis-widgets/notebooks/1.ipywidgets.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
"outputs": [],
189189
"source": [
190190
"button = ToggleButton(description='Click me!', button_style='danger')\n",
191+
"\n",
191192
"def update_style(change):\n",
192193
" button.button_style = 'info' if change['new'] else 'danger'\n",
193194
"\n",

2018-11-14-PyParis-widgets/notebooks/2.bqplot.ipynb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@
103103
"fig.interaction = brushintsel"
104104
]
105105
},
106+
{
107+
"cell_type": "code",
108+
"execution_count": null,
109+
"metadata": {},
110+
"outputs": [],
111+
"source": [
112+
"brushintsel"
113+
]
114+
},
106115
{
107116
"cell_type": "code",
108117
"execution_count": null,

2018-11-14-PyParis-widgets/notebooks/3.ipyleaflet.ipynb

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"cell_type": "markdown",
2121
"metadata": {},
2222
"source": [
23-
"## Base map"
23+
"# Base map"
2424
]
2525
},
2626
{
@@ -41,7 +41,7 @@
4141
"center = (52.204793, 360.121558)\n",
4242
"\n",
4343
"m = Map(\n",
44-
" layers=(basemap_to_tiles(basemaps.NASAGIBS.ModisTerraTrueColorCR, \"2018-11-11\"), ),\n",
44+
" layers=(basemap_to_tiles(basemaps.NASAGIBS.ModisTerraTrueColorCR, \"2018-11-12\"), ),\n",
4545
" center=center,\n",
4646
" zoom=4\n",
4747
")\n",
@@ -53,6 +53,7 @@
5353
"cell_type": "markdown",
5454
"metadata": {},
5555
"source": [
56+
"# Layers\n",
5657
"## Marker"
5758
]
5859
},
@@ -265,6 +266,32 @@
265266
"m2.add_layer(wind)"
266267
]
267268
},
269+
{
270+
"cell_type": "markdown",
271+
"metadata": {},
272+
"source": [
273+
"# Controls"
274+
]
275+
},
276+
{
277+
"cell_type": "code",
278+
"execution_count": null,
279+
"metadata": {},
280+
"outputs": [],
281+
"source": [
282+
"from ipyleaflet import Map, basemaps, basemap_to_tiles, SplitMapControl\n",
283+
"\n",
284+
"m = Map(center=(42.6824, 365.581), zoom=5)\n",
285+
"\n",
286+
"right_layer = basemap_to_tiles(basemaps.NASAGIBS.ModisTerraTrueColorCR, \"2017-11-11\")\n",
287+
"left_layer = basemap_to_tiles(basemaps.NASAGIBS.ModisAquaBands721CR, \"2017-11-11\")\n",
288+
"\n",
289+
"control = SplitMapControl(left_layer=left_layer, right_layer=right_layer)\n",
290+
"m.add_control(control)\n",
291+
"\n",
292+
"m"
293+
]
294+
},
268295
{
269296
"cell_type": "markdown",
270297
"metadata": {},

2018-11-14-PyParis-widgets/notebooks/4.pythreejs.ipynb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616
"`conda install -c conda-forge pythreejs`"
1717
]
1818
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": null,
22+
"metadata": {},
23+
"outputs": [],
24+
"source": [
25+
"from pythreejs import *\n",
26+
"\n",
27+
"sphere = SphereGeometry(radius=12, _flat=True)\n",
28+
"sphere"
29+
]
30+
},
1931
{
2032
"cell_type": "code",
2133
"execution_count": null,

2018-11-14-PyParis-widgets/notebooks/5.ipyvolume.ipynb

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"cell_type": "markdown",
4848
"metadata": {},
4949
"source": [
50-
"## Animations"
50+
"## Animations\n",
51+
"Animations are made in the shaders"
5152
]
5253
},
5354
{
@@ -77,13 +78,13 @@
7778
"metadata": {},
7879
"outputs": [],
7980
"source": [
80-
"u = np.linspace(-10, 10, 25)\n",
81+
"u = np.linspace(-10, 10, 50)\n",
8182
"x, y = np.meshgrid(u, u)\n",
8283
"r = np.sqrt(x**2+y**2)\n",
8384
"x = x.flatten()\n",
8485
"y = y.flatten()\n",
8586
"r = r.flatten()\n",
86-
"time = np.linspace(0, np.pi*2, 15)\n",
87+
"time = np.linspace(0, np.pi*2, 50)\n",
8788
"z = np.array([(np.cos(r + t) * np.exp(-r/5)) for t in time])\n",
8889
"color = np.array([[np.cos(r + t), 1-np.abs(z[i]), 0.1+z[i]*0] for i, t in enumerate(time)])\n",
8990
"size = (z+1)\n",
@@ -103,6 +104,33 @@
103104
"ipyvolume.show()"
104105
]
105106
},
107+
{
108+
"cell_type": "code",
109+
"execution_count": null,
110+
"metadata": {},
111+
"outputs": [],
112+
"source": [
113+
"s.geo = \"diamond\""
114+
]
115+
},
116+
{
117+
"cell_type": "code",
118+
"execution_count": null,
119+
"metadata": {},
120+
"outputs": [],
121+
"source": [
122+
"s.size = 5"
123+
]
124+
},
125+
{
126+
"cell_type": "code",
127+
"execution_count": null,
128+
"metadata": {},
129+
"outputs": [],
130+
"source": [
131+
"s.color = 1 - s.color"
132+
]
133+
},
106134
{
107135
"cell_type": "markdown",
108136
"metadata": {},

2018-11-14-PyParis-widgets/notebooks/6.ipywebrtc.ipynb

Lines changed: 79 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,82 @@
7979
"metadata": {},
8080
"outputs": [],
8181
"source": [
82-
"image_recorder = ImageRecorder(stream=camera)\n",
82+
"ImageRecorder(stream=camera)"
83+
]
84+
},
85+
{
86+
"cell_type": "markdown",
87+
"metadata": {},
88+
"source": [
89+
"## Capture audio"
90+
]
91+
},
92+
{
93+
"cell_type": "code",
94+
"execution_count": null,
95+
"metadata": {},
96+
"outputs": [],
97+
"source": [
98+
"AudioRecorder(stream=camera)"
99+
]
100+
},
101+
{
102+
"cell_type": "markdown",
103+
"metadata": {},
104+
"source": [
105+
"## Capture video"
106+
]
107+
},
108+
{
109+
"cell_type": "code",
110+
"execution_count": null,
111+
"metadata": {},
112+
"outputs": [],
113+
"source": [
114+
"VideoRecorder(stream=camera)"
115+
]
116+
},
117+
{
118+
"cell_type": "markdown",
119+
"metadata": {},
120+
"source": [
121+
"## Chat"
122+
]
123+
},
124+
{
125+
"cell_type": "code",
126+
"execution_count": null,
127+
"metadata": {},
128+
"outputs": [],
129+
"source": [
130+
"from ipywebrtc import chat, VideoStream, Video"
131+
]
132+
},
133+
{
134+
"cell_type": "code",
135+
"execution_count": null,
136+
"metadata": {},
137+
"outputs": [],
138+
"source": [
139+
"room = chat(stream=VideoStream(video=Video.from_file('src/Big.Buck.Bunny.mp4')), room='QuantStack')"
140+
]
141+
},
142+
{
143+
"cell_type": "code",
144+
"execution_count": null,
145+
"metadata": {},
146+
"outputs": [],
147+
"source": [
148+
"# chat(room='QuantStack')"
149+
]
150+
},
151+
{
152+
"cell_type": "code",
153+
"execution_count": null,
154+
"metadata": {},
155+
"outputs": [],
156+
"source": [
157+
"image_recorder = ImageRecorder(stream=chatroom.streams[1])\n",
83158
"image_recorder"
84159
]
85160
},
@@ -139,24 +214,7 @@
139214
"cell_type": "markdown",
140215
"metadata": {},
141216
"source": [
142-
"## Capture audio"
143-
]
144-
},
145-
{
146-
"cell_type": "code",
147-
"execution_count": null,
148-
"metadata": {},
149-
"outputs": [],
150-
"source": [
151-
"audio_recorder = AudioRecorder(stream=camera)\n",
152-
"audio_recorder"
153-
]
154-
},
155-
{
156-
"cell_type": "markdown",
157-
"metadata": {},
158-
"source": [
159-
"## Capture video"
217+
"### Clean"
160218
]
161219
},
162220
{
@@ -165,8 +223,8 @@
165223
"metadata": {},
166224
"outputs": [],
167225
"source": [
168-
"video_recorder = VideoRecorder(stream=camera)\n",
169-
"video_recorder"
226+
"from ipywidgets import Widget\n",
227+
"Widget.close_all()"
170228
]
171229
},
172230
{

2018-11-14-PyParis-widgets/src/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ <h2>Resources:</h2>
246246
<li>ipywebrtc: github.com/MaartenBreddels/ipywebrtc/</li>
247247
<li>ipyvolume: github.com/MaartenBreddels/ipyvolume/</li>
248248
<li>voila: github.com/QuantStack/voila/</li>
249+
<li>xeus: github.com/QuantStack/xeus/</li>
250+
<li>xeus-cling: github.com/QuantStack/xeus-cling/</li>
251+
<li>xwidgets: github.com/QuantStack/xwidgets/</li>
252+
<li>xleaflet: github.com/QuantStack/xleaflet/</li>
249253
</ul>
250254
</section>
251255

@@ -262,6 +266,10 @@ <h2>Resources:</h2>
262266
<li>ipyleaflet.readthedocs.io</li>
263267
<li>ipywebrtc.readthedocs.io</li>
264268
<li>ipyvolume.readthedocs.io</li>
269+
<li>xeus.readthedocs.io</li>
270+
<li>xeus-cling.readthedocs.io</li>
271+
<li>xwidgets.readthedocs.io</li>
272+
<li>xleaflet.readthedocs.io</li>
265273
</ul>
266274
</section>
267275

@@ -293,5 +301,13 @@ <h2>The End</h2>
293301
]
294302
});
295303
</script>
304+
305+
<script>
306+
var link = document.createElement( 'link' );
307+
link.rel = 'stylesheet';
308+
link.type = 'text/css';
309+
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
310+
document.getElementsByTagName( 'head' )[0].appendChild( link );
311+
</script>
296312
</body>
297313
</html>

0 commit comments

Comments
 (0)