##// END OF EJS Templates
Make interact example compatible with Python 3...
Thomas Kluyver -
Show More
@@ -1,7 +1,16 b''
1 {
1 {
2 "metadata": {
2 "metadata": {
3 "kernelspec": {
4 "codemirror_mode": {
5 "name": "ipython",
6 "version": 3
7 },
8 "display_name": "IPython (Python 3)",
9 "language": "python",
10 "name": "python3"
11 },
3 "name": "",
12 "name": "",
4 "signature": "sha256:6d8c7c51322c4911e478068e8fa8e897bd72c614096f5df110ed86d01d66001c"
13 "signature": "sha256:1bbd16f32ec50ec64d4dd646cd6868aeace8091cac989107f2026fc688ca3701"
5 },
14 },
6 "nbformat": 3,
15 "nbformat": 3,
7 "nbformat_minor": 0,
16 "nbformat_minor": 0,
@@ -27,13 +36,13 b''
27 "cell_type": "code",
36 "cell_type": "code",
28 "collapsed": false,
37 "collapsed": false,
29 "input": [
38 "input": [
39 "from __future__ import print_function\n",
30 "from IPython.html.widgets import interact, interactive, fixed\n",
40 "from IPython.html.widgets import interact, interactive, fixed\n",
31 "from IPython.html import widgets"
41 "from IPython.html import widgets"
32 ],
42 ],
33 "language": "python",
43 "language": "python",
34 "metadata": {},
44 "metadata": {},
35 "outputs": [],
45 "outputs": []
36 "prompt_number": 1
37 },
46 },
38 {
47 {
39 "cell_type": "markdown",
48 "cell_type": "markdown",
@@ -64,12 +73,11 b''
64 "collapsed": false,
73 "collapsed": false,
65 "input": [
74 "input": [
66 "def f(x):\n",
75 "def f(x):\n",
67 " print x"
76 " print(x)"
68 ],
77 ],
69 "language": "python",
78 "language": "python",
70 "metadata": {},
79 "metadata": {},
71 "outputs": [],
80 "outputs": []
72 "prompt_number": 2
73 },
81 },
74 {
82 {
75 "cell_type": "markdown",
83 "cell_type": "markdown",
@@ -86,16 +94,7 b''
86 ],
94 ],
87 "language": "python",
95 "language": "python",
88 "metadata": {},
96 "metadata": {},
89 "outputs": [
97 "outputs": []
90 {
91 "output_type": "stream",
92 "stream": "stdout",
93 "text": [
94 "9\n"
95 ]
96 }
97 ],
98 "prompt_number": 3
99 },
98 },
100 {
99 {
101 "cell_type": "markdown",
100 "cell_type": "markdown",
@@ -114,16 +113,7 b''
114 ],
113 ],
115 "language": "python",
114 "language": "python",
116 "metadata": {},
115 "metadata": {},
117 "outputs": [
116 "outputs": []
118 {
119 "output_type": "stream",
120 "stream": "stdout",
121 "text": [
122 "True\n"
123 ]
124 }
125 ],
126 "prompt_number": 4
127 },
117 },
128 {
118 {
129 "cell_type": "markdown",
119 "cell_type": "markdown",
@@ -140,16 +130,7 b''
140 ],
130 ],
141 "language": "python",
131 "language": "python",
142 "metadata": {},
132 "metadata": {},
143 "outputs": [
133 "outputs": []
144 {
145 "output_type": "stream",
146 "stream": "stdout",
147 "text": [
148 "Hi there!\n"
149 ]
150 }
151 ],
152 "prompt_number": 5
153 },
134 },
154 {
135 {
155 "cell_type": "markdown",
136 "cell_type": "markdown",
@@ -164,20 +145,11 b''
164 "input": [
145 "input": [
165 "@interact(x=True, y=1.0)\n",
146 "@interact(x=True, y=1.0)\n",
166 "def g(x, y):\n",
147 "def g(x, y):\n",
167 " print x, y"
148 " print(x, y)"
168 ],
149 ],
169 "language": "python",
150 "language": "python",
170 "metadata": {},
151 "metadata": {},
171 "outputs": [
152 "outputs": []
172 {
173 "output_type": "stream",
174 "stream": "stdout",
175 "text": [
176 "True 1.0\n"
177 ]
178 }
179 ],
180 "prompt_number": 6
181 },
153 },
182 {
154 {
183 "cell_type": "heading",
155 "cell_type": "heading",
@@ -199,12 +171,11 b''
199 "collapsed": false,
171 "collapsed": false,
200 "input": [
172 "input": [
201 "def h(p, q):\n",
173 "def h(p, q):\n",
202 " print p, q"
174 " print(p, q)"
203 ],
175 ],
204 "language": "python",
176 "language": "python",
205 "metadata": {},
177 "metadata": {},
206 "outputs": [],
178 "outputs": []
207 "prompt_number": 7
208 },
179 },
209 {
180 {
210 "cell_type": "markdown",
181 "cell_type": "markdown",
@@ -221,16 +192,7 b''
221 ],
192 ],
222 "language": "python",
193 "language": "python",
223 "metadata": {},
194 "metadata": {},
224 "outputs": [
195 "outputs": []
225 {
226 "output_type": "stream",
227 "stream": "stdout",
228 "text": [
229 "5 20\n"
230 ]
231 }
232 ],
233 "prompt_number": 8
234 },
196 },
235 {
197 {
236 "cell_type": "markdown",
198 "cell_type": "markdown",
@@ -268,16 +230,7 b''
268 ],
230 ],
269 "language": "python",
231 "language": "python",
270 "metadata": {},
232 "metadata": {},
271 "outputs": [
233 "outputs": []
272 {
273 "output_type": "stream",
274 "stream": "stdout",
275 "text": [
276 "10\n"
277 ]
278 }
279 ],
280 "prompt_number": 9
281 },
234 },
282 {
235 {
283 "cell_type": "markdown",
236 "cell_type": "markdown",
@@ -317,16 +270,7 b''
317 ],
270 ],
318 "language": "python",
271 "language": "python",
319 "metadata": {},
272 "metadata": {},
320 "outputs": [
273 "outputs": []
321 {
322 "output_type": "stream",
323 "stream": "stdout",
324 "text": [
325 "2\n"
326 ]
327 }
328 ],
329 "prompt_number": 10
330 },
274 },
331 {
275 {
332 "cell_type": "markdown",
276 "cell_type": "markdown",
@@ -343,16 +287,7 b''
343 ],
287 ],
344 "language": "python",
288 "language": "python",
345 "metadata": {},
289 "metadata": {},
346 "outputs": [
290 "outputs": []
347 {
348 "output_type": "stream",
349 "stream": "stdout",
350 "text": [
351 "4\n"
352 ]
353 }
354 ],
355 "prompt_number": 11
356 },
291 },
357 {
292 {
358 "cell_type": "markdown",
293 "cell_type": "markdown",
@@ -369,16 +304,7 b''
369 ],
304 ],
370 "language": "python",
305 "language": "python",
371 "metadata": {},
306 "metadata": {},
372 "outputs": [
307 "outputs": []
373 {
374 "output_type": "stream",
375 "stream": "stdout",
376 "text": [
377 "5.0\n"
378 ]
379 }
380 ],
381 "prompt_number": 12
382 },
308 },
383 {
309 {
384 "cell_type": "markdown",
310 "cell_type": "markdown",
@@ -395,16 +321,7 b''
395 ],
321 ],
396 "language": "python",
322 "language": "python",
397 "metadata": {},
323 "metadata": {},
398 "outputs": [
324 "outputs": []
399 {
400 "output_type": "stream",
401 "stream": "stdout",
402 "text": [
403 "4.99\n"
404 ]
405 }
406 ],
407 "prompt_number": 13
408 },
325 },
409 {
326 {
410 "cell_type": "markdown",
327 "cell_type": "markdown",
@@ -419,20 +336,11 b''
419 "input": [
336 "input": [
420 "@interact(x=(0.0,20.0,0.5))\n",
337 "@interact(x=(0.0,20.0,0.5))\n",
421 "def h(x=5.5):\n",
338 "def h(x=5.5):\n",
422 " print x"
339 " print(x)"
423 ],
340 ],
424 "language": "python",
341 "language": "python",
425 "metadata": {},
342 "metadata": {},
426 "outputs": [
343 "outputs": []
427 {
428 "output_type": "stream",
429 "stream": "stdout",
430 "text": [
431 "5.5\n"
432 ]
433 }
434 ],
435 "prompt_number": 14
436 },
344 },
437 {
345 {
438 "cell_type": "markdown",
346 "cell_type": "markdown",
@@ -449,16 +357,7 b''
449 ],
357 ],
450 "language": "python",
358 "language": "python",
451 "metadata": {},
359 "metadata": {},
452 "outputs": [
360 "outputs": []
453 {
454 "output_type": "stream",
455 "stream": "stdout",
456 "text": [
457 "apples\n"
458 ]
459 }
460 ],
461 "prompt_number": 15
462 },
361 },
463 {
362 {
464 "cell_type": "markdown",
363 "cell_type": "markdown",
@@ -475,16 +374,7 b''
475 ],
374 ],
476 "language": "python",
375 "language": "python",
477 "metadata": {},
376 "metadata": {},
478 "outputs": [
377 "outputs": []
479 {
480 "output_type": "stream",
481 "stream": "stdout",
482 "text": [
483 "20\n"
484 ]
485 }
486 ],
487 "prompt_number": 16
488 },
378 },
489 {
379 {
490 "cell_type": "heading",
380 "cell_type": "heading",
@@ -508,7 +398,7 b''
508 "collapsed": false,
398 "collapsed": false,
509 "input": [
399 "input": [
510 "def f(x:True):\n",
400 "def f(x:True):\n",
511 " print x"
401 " print(x)"
512 ],
402 ],
513 "language": "python",
403 "language": "python",
514 "metadata": {},
404 "metadata": {},
@@ -546,8 +436,7 b''
546 ],
436 ],
547 "language": "python",
437 "language": "python",
548 "metadata": {},
438 "metadata": {},
549 "outputs": [],
439 "outputs": []
550 "prompt_number": 50
551 },
440 },
552 {
441 {
553 "cell_type": "code",
442 "cell_type": "code",
@@ -555,12 +444,11 b''
555 "input": [
444 "input": [
556 "@annotate(x=True)\n",
445 "@annotate(x=True)\n",
557 "def f(x):\n",
446 "def f(x):\n",
558 " print x"
447 " print(x)"
559 ],
448 ],
560 "language": "python",
449 "language": "python",
561 "metadata": {},
450 "metadata": {},
562 "outputs": [],
451 "outputs": []
563 "prompt_number": 51
564 },
452 },
565 {
453 {
566 "cell_type": "code",
454 "cell_type": "code",
@@ -570,16 +458,7 b''
570 ],
458 ],
571 "language": "python",
459 "language": "python",
572 "metadata": {},
460 "metadata": {},
573 "outputs": [
461 "outputs": []
574 {
575 "output_type": "stream",
576 "stream": "stdout",
577 "text": [
578 "True\n"
579 ]
580 }
581 ],
582 "prompt_number": 52
583 },
462 },
584 {
463 {
585 "cell_type": "heading",
464 "cell_type": "heading",
@@ -612,8 +491,7 b''
612 ],
491 ],
613 "language": "python",
492 "language": "python",
614 "metadata": {},
493 "metadata": {},
615 "outputs": [],
494 "outputs": []
616 "prompt_number": 18
617 },
495 },
618 {
496 {
619 "cell_type": "markdown",
497 "cell_type": "markdown",
@@ -630,14 +508,13 b''
630 ],
508 ],
631 "language": "python",
509 "language": "python",
632 "metadata": {},
510 "metadata": {},
633 "outputs": [],
511 "outputs": []
634 "prompt_number": 19
635 },
512 },
636 {
513 {
637 "cell_type": "markdown",
514 "cell_type": "markdown",
638 "metadata": {},
515 "metadata": {},
639 "source": [
516 "source": [
640 "The widget is a `ContainerWidget`, which is a container for other widgets."
517 "The widget is a `Box`, which is a container for other widgets."
641 ]
518 ]
642 },
519 },
643 {
520 {
@@ -648,23 +525,13 b''
648 ],
525 ],
649 "language": "python",
526 "language": "python",
650 "metadata": {},
527 "metadata": {},
651 "outputs": [
528 "outputs": []
652 {
653 "metadata": {},
654 "output_type": "pyout",
655 "prompt_number": 20,
656 "text": [
657 "IPython.html.widgets.widget_container.ContainerWidget"
658 ]
659 }
660 ],
661 "prompt_number": 20
662 },
529 },
663 {
530 {
664 "cell_type": "markdown",
531 "cell_type": "markdown",
665 "metadata": {},
532 "metadata": {},
666 "source": [
533 "source": [
667 "The children of the `ContainerWidget` are two integer valued sliders produced by the widget abbreviations above."
534 "The children of the `Box` are two integer valued sliders produced by the widget abbreviations above."
668 ]
535 ]
669 },
536 },
670 {
537 {
@@ -675,18 +542,7 b''
675 ],
542 ],
676 "language": "python",
543 "language": "python",
677 "metadata": {},
544 "metadata": {},
678 "outputs": [
545 "outputs": []
679 {
680 "metadata": {},
681 "output_type": "pyout",
682 "prompt_number": 21,
683 "text": [
684 "(<IPython.html.widgets.widget_int.IntSliderWidget at 0x10557ee90>,\n",
685 " <IPython.html.widgets.widget_int.IntSliderWidget at 0x10616ebd0>)"
686 ]
687 }
688 ],
689 "prompt_number": 21
690 },
546 },
691 {
547 {
692 "cell_type": "markdown",
548 "cell_type": "markdown",
@@ -704,8 +560,7 b''
704 ],
560 ],
705 "language": "python",
561 "language": "python",
706 "metadata": {},
562 "metadata": {},
707 "outputs": [],
563 "outputs": []
708 "prompt_number": 22
709 },
564 },
710 {
565 {
711 "cell_type": "markdown",
566 "cell_type": "markdown",
@@ -724,17 +579,7 b''
724 ],
579 ],
725 "language": "python",
580 "language": "python",
726 "metadata": {},
581 "metadata": {},
727 "outputs": [
582 "outputs": []
728 {
729 "metadata": {},
730 "output_type": "pyout",
731 "prompt_number": 23,
732 "text": [
733 "{u'a': 10, u'b': 20}"
734 ]
735 }
736 ],
737 "prompt_number": 23
738 },
583 },
739 {
584 {
740 "cell_type": "markdown",
585 "cell_type": "markdown",
@@ -751,17 +596,7 b''
751 ],
596 ],
752 "language": "python",
597 "language": "python",
753 "metadata": {},
598 "metadata": {},
754 "outputs": [
599 "outputs": []
755 {
756 "metadata": {},
757 "output_type": "pyout",
758 "prompt_number": 24,
759 "text": [
760 "30"
761 ]
762 }
763 ],
764 "prompt_number": 24
765 }
600 }
766 ],
601 ],
767 "metadata": {}
602 "metadata": {}
General Comments 0
You need to be logged in to leave comments. Login now