Show More
This diff has been collapsed as it changes many lines, (585 lines changed) Show them Hide them | |||||
@@ -0,0 +1,585 b'' | |||||
|
1 | { | |||
|
2 | "metadata": { | |||
|
3 | "name": "", | |||
|
4 | "signature": "sha256:6c84353e4cf4ba713ae4744419206f2fc8beb7bb3a709f21e1bc70e70c2c49cd" | |||
|
5 | }, | |||
|
6 | "nbformat": 3, | |||
|
7 | "nbformat_minor": 0, | |||
|
8 | "worksheets": [ | |||
|
9 | { | |||
|
10 | "cells": [ | |||
|
11 | { | |||
|
12 | "cell_type": "markdown", | |||
|
13 | "metadata": {}, | |||
|
14 | "source": [ | |||
|
15 | "# Widget List\n", | |||
|
16 | "\n", | |||
|
17 | "## Complete list\n", | |||
|
18 | "For a complete list of the widgets available to you, you can list the classes in the widget namespace (as seen below). Classes with the suffix `Widget` are widgets. `Widget` and `DOMWidget` are base classes." | |||
|
19 | ] | |||
|
20 | }, | |||
|
21 | { | |||
|
22 | "cell_type": "code", | |||
|
23 | "collapsed": false, | |||
|
24 | "input": [ | |||
|
25 | "from IPython.html import widgets\n", | |||
|
26 | "[w for w in dir(widgets) if w.endswith('Widget')]" | |||
|
27 | ], | |||
|
28 | "language": "python", | |||
|
29 | "metadata": {}, | |||
|
30 | "outputs": [ | |||
|
31 | { | |||
|
32 | "metadata": {}, | |||
|
33 | "output_type": "pyout", | |||
|
34 | "prompt_number": 2, | |||
|
35 | "text": [ | |||
|
36 | "['AccordionWidget',\n", | |||
|
37 | " 'BoundedFloatTextWidget',\n", | |||
|
38 | " 'BoundedIntTextWidget',\n", | |||
|
39 | " 'ButtonWidget',\n", | |||
|
40 | " 'CheckboxWidget',\n", | |||
|
41 | " 'ContainerWidget',\n", | |||
|
42 | " 'DOMWidget',\n", | |||
|
43 | " 'DropdownWidget',\n", | |||
|
44 | " 'FloatProgressWidget',\n", | |||
|
45 | " 'FloatSliderWidget',\n", | |||
|
46 | " 'FloatTextWidget',\n", | |||
|
47 | " 'HTMLWidget',\n", | |||
|
48 | " 'ImageWidget',\n", | |||
|
49 | " 'IntProgressWidget',\n", | |||
|
50 | " 'IntSliderWidget',\n", | |||
|
51 | " 'IntTextWidget',\n", | |||
|
52 | " 'LatexWidget',\n", | |||
|
53 | " 'PopupWidget',\n", | |||
|
54 | " 'RadioButtonsWidget',\n", | |||
|
55 | " 'SelectWidget',\n", | |||
|
56 | " 'TabWidget',\n", | |||
|
57 | " 'TextWidget',\n", | |||
|
58 | " 'TextareaWidget',\n", | |||
|
59 | " 'ToggleButtonWidget',\n", | |||
|
60 | " 'ToggleButtonsWidget',\n", | |||
|
61 | " 'Widget']" | |||
|
62 | ] | |||
|
63 | } | |||
|
64 | ], | |||
|
65 | "prompt_number": 2 | |||
|
66 | }, | |||
|
67 | { | |||
|
68 | "cell_type": "heading", | |||
|
69 | "level": 2, | |||
|
70 | "metadata": {}, | |||
|
71 | "source": [ | |||
|
72 | "Numeric widgets" | |||
|
73 | ] | |||
|
74 | }, | |||
|
75 | { | |||
|
76 | "cell_type": "markdown", | |||
|
77 | "metadata": {}, | |||
|
78 | "source": [ | |||
|
79 | "There are 8 widgets distrubted with IPython that are designed to display numeric values. Widgets exist for displaying integers and floats, both bounded and unbounded. The integer widgets share a similar naming scheme to their floating point counterparts. By replacing `Float` with `Int` in the widget name, you can find the Integer equivalent." | |||
|
80 | ] | |||
|
81 | }, | |||
|
82 | { | |||
|
83 | "cell_type": "heading", | |||
|
84 | "level": 3, | |||
|
85 | "metadata": {}, | |||
|
86 | "source": [ | |||
|
87 | "FloatSliderWidget" | |||
|
88 | ] | |||
|
89 | }, | |||
|
90 | { | |||
|
91 | "cell_type": "code", | |||
|
92 | "collapsed": false, | |||
|
93 | "input": [ | |||
|
94 | "widgets.FloatSliderWidget(\n", | |||
|
95 | " value=7.5,\n", | |||
|
96 | " min=5.0,\n", | |||
|
97 | " max=10.0,\n", | |||
|
98 | " step=0.1,\n", | |||
|
99 | " description='Test:',\n", | |||
|
100 | ")" | |||
|
101 | ], | |||
|
102 | "language": "python", | |||
|
103 | "metadata": {}, | |||
|
104 | "outputs": [], | |||
|
105 | "prompt_number": 3 | |||
|
106 | }, | |||
|
107 | { | |||
|
108 | "cell_type": "markdown", | |||
|
109 | "metadata": {}, | |||
|
110 | "source": [ | |||
|
111 | "Sliders can also be displayed vertically." | |||
|
112 | ] | |||
|
113 | }, | |||
|
114 | { | |||
|
115 | "cell_type": "code", | |||
|
116 | "collapsed": false, | |||
|
117 | "input": [ | |||
|
118 | "widgets.FloatSliderWidget(\n", | |||
|
119 | " value=7.5,\n", | |||
|
120 | " min=5.0,\n", | |||
|
121 | " max=10.0,\n", | |||
|
122 | " step=0.1,\n", | |||
|
123 | " description='Test',\n", | |||
|
124 | " orientation='vertical',\n", | |||
|
125 | ")" | |||
|
126 | ], | |||
|
127 | "language": "python", | |||
|
128 | "metadata": {}, | |||
|
129 | "outputs": [], | |||
|
130 | "prompt_number": 5 | |||
|
131 | }, | |||
|
132 | { | |||
|
133 | "cell_type": "heading", | |||
|
134 | "level": 3, | |||
|
135 | "metadata": {}, | |||
|
136 | "source": [ | |||
|
137 | "FloatProgressWidget" | |||
|
138 | ] | |||
|
139 | }, | |||
|
140 | { | |||
|
141 | "cell_type": "code", | |||
|
142 | "collapsed": false, | |||
|
143 | "input": [ | |||
|
144 | "widgets.FloatProgressWidget(\n", | |||
|
145 | " value=7.5,\n", | |||
|
146 | " min=5.0,\n", | |||
|
147 | " max=10.0,\n", | |||
|
148 | " step=0.1,\n", | |||
|
149 | " description='Loading:',\n", | |||
|
150 | ")" | |||
|
151 | ], | |||
|
152 | "language": "python", | |||
|
153 | "metadata": {}, | |||
|
154 | "outputs": [], | |||
|
155 | "prompt_number": 6 | |||
|
156 | }, | |||
|
157 | { | |||
|
158 | "cell_type": "heading", | |||
|
159 | "level": 3, | |||
|
160 | "metadata": {}, | |||
|
161 | "source": [ | |||
|
162 | "BoundedFloatTextWidget" | |||
|
163 | ] | |||
|
164 | }, | |||
|
165 | { | |||
|
166 | "cell_type": "code", | |||
|
167 | "collapsed": false, | |||
|
168 | "input": [ | |||
|
169 | "widgets.BoundedFloatTextWidget(\n", | |||
|
170 | " value=7.5,\n", | |||
|
171 | " min=5.0,\n", | |||
|
172 | " max=10.0,\n", | |||
|
173 | " description='Text:',\n", | |||
|
174 | ")" | |||
|
175 | ], | |||
|
176 | "language": "python", | |||
|
177 | "metadata": {}, | |||
|
178 | "outputs": [], | |||
|
179 | "prompt_number": 10 | |||
|
180 | }, | |||
|
181 | { | |||
|
182 | "cell_type": "heading", | |||
|
183 | "level": 3, | |||
|
184 | "metadata": {}, | |||
|
185 | "source": [ | |||
|
186 | "FloatTextWidget" | |||
|
187 | ] | |||
|
188 | }, | |||
|
189 | { | |||
|
190 | "cell_type": "code", | |||
|
191 | "collapsed": false, | |||
|
192 | "input": [ | |||
|
193 | "widgets.FloatTextWidget(\n", | |||
|
194 | " value=7.5,\n", | |||
|
195 | " description='Any:',\n", | |||
|
196 | ")" | |||
|
197 | ], | |||
|
198 | "language": "python", | |||
|
199 | "metadata": {}, | |||
|
200 | "outputs": [], | |||
|
201 | "prompt_number": 11 | |||
|
202 | }, | |||
|
203 | { | |||
|
204 | "cell_type": "heading", | |||
|
205 | "level": 2, | |||
|
206 | "metadata": {}, | |||
|
207 | "source": [ | |||
|
208 | "Boolean widgets" | |||
|
209 | ] | |||
|
210 | }, | |||
|
211 | { | |||
|
212 | "cell_type": "markdown", | |||
|
213 | "metadata": {}, | |||
|
214 | "source": [ | |||
|
215 | "There are two widgets that are designed to display a boolean value." | |||
|
216 | ] | |||
|
217 | }, | |||
|
218 | { | |||
|
219 | "cell_type": "heading", | |||
|
220 | "level": 3, | |||
|
221 | "metadata": {}, | |||
|
222 | "source": [ | |||
|
223 | "ToggleButtonWidget" | |||
|
224 | ] | |||
|
225 | }, | |||
|
226 | { | |||
|
227 | "cell_type": "code", | |||
|
228 | "collapsed": false, | |||
|
229 | "input": [ | |||
|
230 | "widgets.ToggleButtonWidget(\n", | |||
|
231 | " description='Click me',\n", | |||
|
232 | " value=False,\n", | |||
|
233 | ")" | |||
|
234 | ], | |||
|
235 | "language": "python", | |||
|
236 | "metadata": {}, | |||
|
237 | "outputs": [], | |||
|
238 | "prompt_number": 14 | |||
|
239 | }, | |||
|
240 | { | |||
|
241 | "cell_type": "heading", | |||
|
242 | "level": 3, | |||
|
243 | "metadata": {}, | |||
|
244 | "source": [ | |||
|
245 | "CheckboxWidget" | |||
|
246 | ] | |||
|
247 | }, | |||
|
248 | { | |||
|
249 | "cell_type": "code", | |||
|
250 | "collapsed": false, | |||
|
251 | "input": [ | |||
|
252 | "widgets.CheckboxWidget(\n", | |||
|
253 | " description='Check me',\n", | |||
|
254 | " value=True,\n", | |||
|
255 | ")" | |||
|
256 | ], | |||
|
257 | "language": "python", | |||
|
258 | "metadata": {}, | |||
|
259 | "outputs": [], | |||
|
260 | "prompt_number": 17 | |||
|
261 | }, | |||
|
262 | { | |||
|
263 | "cell_type": "heading", | |||
|
264 | "level": 2, | |||
|
265 | "metadata": {}, | |||
|
266 | "source": [ | |||
|
267 | "Selection widgets" | |||
|
268 | ] | |||
|
269 | }, | |||
|
270 | { | |||
|
271 | "cell_type": "markdown", | |||
|
272 | "metadata": {}, | |||
|
273 | "source": [ | |||
|
274 | "There are four widgets that can be used to display single selection lists. All four inherit from the same base class. You can specify the enumeration of selectables by passing a list. You can also specify the enumeration as a dictionary, in which case the keys will be used as the item displayed in the list and the corropsondong value will be returned when an item is selected." | |||
|
275 | ] | |||
|
276 | }, | |||
|
277 | { | |||
|
278 | "cell_type": "heading", | |||
|
279 | "level": 3, | |||
|
280 | "metadata": {}, | |||
|
281 | "source": [ | |||
|
282 | "DropdownWidget" | |||
|
283 | ] | |||
|
284 | }, | |||
|
285 | { | |||
|
286 | "cell_type": "code", | |||
|
287 | "collapsed": false, | |||
|
288 | "input": [ | |||
|
289 | "from IPython.display import display\n", | |||
|
290 | "w = widgets.DropdownWidget(\n", | |||
|
291 | " values=[1, 2, 3],\n", | |||
|
292 | " value=2,\n", | |||
|
293 | " description='Number:',\n", | |||
|
294 | ")\n", | |||
|
295 | "display(w)" | |||
|
296 | ], | |||
|
297 | "language": "python", | |||
|
298 | "metadata": {}, | |||
|
299 | "outputs": [], | |||
|
300 | "prompt_number": 28 | |||
|
301 | }, | |||
|
302 | { | |||
|
303 | "cell_type": "code", | |||
|
304 | "collapsed": false, | |||
|
305 | "input": [ | |||
|
306 | "w.value" | |||
|
307 | ], | |||
|
308 | "language": "python", | |||
|
309 | "metadata": {}, | |||
|
310 | "outputs": [ | |||
|
311 | { | |||
|
312 | "metadata": {}, | |||
|
313 | "output_type": "pyout", | |||
|
314 | "prompt_number": 29, | |||
|
315 | "text": [ | |||
|
316 | "2" | |||
|
317 | ] | |||
|
318 | } | |||
|
319 | ], | |||
|
320 | "prompt_number": 29 | |||
|
321 | }, | |||
|
322 | { | |||
|
323 | "cell_type": "markdown", | |||
|
324 | "metadata": {}, | |||
|
325 | "source": [ | |||
|
326 | "The following is also valid:" | |||
|
327 | ] | |||
|
328 | }, | |||
|
329 | { | |||
|
330 | "cell_type": "code", | |||
|
331 | "collapsed": false, | |||
|
332 | "input": [ | |||
|
333 | "w = widgets.DropdownWidget(\n", | |||
|
334 | " values={'One': 1, 'Two': 2, 'Three': 3},\n", | |||
|
335 | " value=2,\n", | |||
|
336 | " description='Number:',\n", | |||
|
337 | ")\n", | |||
|
338 | "display(w)" | |||
|
339 | ], | |||
|
340 | "language": "python", | |||
|
341 | "metadata": {}, | |||
|
342 | "outputs": [], | |||
|
343 | "prompt_number": 30 | |||
|
344 | }, | |||
|
345 | { | |||
|
346 | "cell_type": "code", | |||
|
347 | "collapsed": false, | |||
|
348 | "input": [ | |||
|
349 | "w.value" | |||
|
350 | ], | |||
|
351 | "language": "python", | |||
|
352 | "metadata": {}, | |||
|
353 | "outputs": [ | |||
|
354 | { | |||
|
355 | "metadata": {}, | |||
|
356 | "output_type": "pyout", | |||
|
357 | "prompt_number": 31, | |||
|
358 | "text": [ | |||
|
359 | "2" | |||
|
360 | ] | |||
|
361 | } | |||
|
362 | ], | |||
|
363 | "prompt_number": 31 | |||
|
364 | }, | |||
|
365 | { | |||
|
366 | "cell_type": "heading", | |||
|
367 | "level": 3, | |||
|
368 | "metadata": {}, | |||
|
369 | "source": [ | |||
|
370 | "RadioButtonsWidget" | |||
|
371 | ] | |||
|
372 | }, | |||
|
373 | { | |||
|
374 | "cell_type": "code", | |||
|
375 | "collapsed": false, | |||
|
376 | "input": [ | |||
|
377 | "widgets.RadioButtonsWidget(\n", | |||
|
378 | " description='Pizza topping:',\n", | |||
|
379 | " values=['pepperoni', 'pineapple', 'anchovies'],\n", | |||
|
380 | ")" | |||
|
381 | ], | |||
|
382 | "language": "python", | |||
|
383 | "metadata": {}, | |||
|
384 | "outputs": [], | |||
|
385 | "prompt_number": 32 | |||
|
386 | }, | |||
|
387 | { | |||
|
388 | "cell_type": "heading", | |||
|
389 | "level": 3, | |||
|
390 | "metadata": {}, | |||
|
391 | "source": [ | |||
|
392 | "SelectWidget" | |||
|
393 | ] | |||
|
394 | }, | |||
|
395 | { | |||
|
396 | "cell_type": "code", | |||
|
397 | "collapsed": false, | |||
|
398 | "input": [ | |||
|
399 | "widgets.SelectWidget(\n", | |||
|
400 | " description='OS:',\n", | |||
|
401 | " values=['Linux', 'Windows', 'OSX'],\n", | |||
|
402 | ")" | |||
|
403 | ], | |||
|
404 | "language": "python", | |||
|
405 | "metadata": {}, | |||
|
406 | "outputs": [], | |||
|
407 | "prompt_number": 33 | |||
|
408 | }, | |||
|
409 | { | |||
|
410 | "cell_type": "heading", | |||
|
411 | "level": 3, | |||
|
412 | "metadata": {}, | |||
|
413 | "source": [ | |||
|
414 | "ToggleButtonsWidget" | |||
|
415 | ] | |||
|
416 | }, | |||
|
417 | { | |||
|
418 | "cell_type": "code", | |||
|
419 | "collapsed": false, | |||
|
420 | "input": [ | |||
|
421 | "widgets.ToggleButtonsWidget(\n", | |||
|
422 | " description='Speed:',\n", | |||
|
423 | " values=['Slow', 'Regular', 'Fast'],\n", | |||
|
424 | ")" | |||
|
425 | ], | |||
|
426 | "language": "python", | |||
|
427 | "metadata": {}, | |||
|
428 | "outputs": [], | |||
|
429 | "prompt_number": 34 | |||
|
430 | }, | |||
|
431 | { | |||
|
432 | "cell_type": "heading", | |||
|
433 | "level": 2, | |||
|
434 | "metadata": {}, | |||
|
435 | "source": [ | |||
|
436 | "String widgets" | |||
|
437 | ] | |||
|
438 | }, | |||
|
439 | { | |||
|
440 | "cell_type": "markdown", | |||
|
441 | "metadata": {}, | |||
|
442 | "source": [ | |||
|
443 | "There are 4 widgets that can be used to display a string value. Of those, the `TextWidget` and `TextareaWidget` accept input. The `LatexWidget` and `HTMLWidget` display the string as either Latex or HTML respecively, but do not accept input." | |||
|
444 | ] | |||
|
445 | }, | |||
|
446 | { | |||
|
447 | "cell_type": "heading", | |||
|
448 | "level": 3, | |||
|
449 | "metadata": {}, | |||
|
450 | "source": [ | |||
|
451 | "TextWidget" | |||
|
452 | ] | |||
|
453 | }, | |||
|
454 | { | |||
|
455 | "cell_type": "code", | |||
|
456 | "collapsed": false, | |||
|
457 | "input": [ | |||
|
458 | "widgets.TextWidget(\n", | |||
|
459 | " description='String:',\n", | |||
|
460 | " value='Hello PyData',\n", | |||
|
461 | ")" | |||
|
462 | ], | |||
|
463 | "language": "python", | |||
|
464 | "metadata": {}, | |||
|
465 | "outputs": [], | |||
|
466 | "prompt_number": 39 | |||
|
467 | }, | |||
|
468 | { | |||
|
469 | "cell_type": "heading", | |||
|
470 | "level": 3, | |||
|
471 | "metadata": {}, | |||
|
472 | "source": [ | |||
|
473 | "TextareaWidget" | |||
|
474 | ] | |||
|
475 | }, | |||
|
476 | { | |||
|
477 | "cell_type": "code", | |||
|
478 | "collapsed": false, | |||
|
479 | "input": [ | |||
|
480 | "widgets.TextareaWidget(\n", | |||
|
481 | " description='String:',\n", | |||
|
482 | " value='Hello PyData',\n", | |||
|
483 | ")" | |||
|
484 | ], | |||
|
485 | "language": "python", | |||
|
486 | "metadata": {}, | |||
|
487 | "outputs": [], | |||
|
488 | "prompt_number": 40 | |||
|
489 | }, | |||
|
490 | { | |||
|
491 | "cell_type": "heading", | |||
|
492 | "level": 3, | |||
|
493 | "metadata": {}, | |||
|
494 | "source": [ | |||
|
495 | "LatexWidget" | |||
|
496 | ] | |||
|
497 | }, | |||
|
498 | { | |||
|
499 | "cell_type": "code", | |||
|
500 | "collapsed": false, | |||
|
501 | "input": [ | |||
|
502 | "widgets.LatexWidget(\n", | |||
|
503 | " value=\"$$\\\\frac{n!}{k!(n-k)!} = \\\\binom{n}{k}$$\",\n", | |||
|
504 | ")" | |||
|
505 | ], | |||
|
506 | "language": "python", | |||
|
507 | "metadata": {}, | |||
|
508 | "outputs": [], | |||
|
509 | "prompt_number": 52 | |||
|
510 | }, | |||
|
511 | { | |||
|
512 | "cell_type": "heading", | |||
|
513 | "level": 3, | |||
|
514 | "metadata": {}, | |||
|
515 | "source": [ | |||
|
516 | "HTMLWidget" | |||
|
517 | ] | |||
|
518 | }, | |||
|
519 | { | |||
|
520 | "cell_type": "code", | |||
|
521 | "collapsed": false, | |||
|
522 | "input": [ | |||
|
523 | "widgets.HTMLWidget(\n", | |||
|
524 | " value=\"Hello <b>PyData</b>\"\n", | |||
|
525 | ")" | |||
|
526 | ], | |||
|
527 | "language": "python", | |||
|
528 | "metadata": {}, | |||
|
529 | "outputs": [], | |||
|
530 | "prompt_number": 53 | |||
|
531 | }, | |||
|
532 | { | |||
|
533 | "cell_type": "heading", | |||
|
534 | "level": 3, | |||
|
535 | "metadata": {}, | |||
|
536 | "source": [ | |||
|
537 | "Using link to make a simple Latex editor" | |||
|
538 | ] | |||
|
539 | }, | |||
|
540 | { | |||
|
541 | "cell_type": "code", | |||
|
542 | "collapsed": false, | |||
|
543 | "input": [ | |||
|
544 | "from IPython.utils.traitlets import link\n", | |||
|
545 | "w1 = widgets.TextareaWidget()\n", | |||
|
546 | "w2 = widgets.LatexWidget()\n", | |||
|
547 | "display(w1, w2)\n", | |||
|
548 | "mylink = link((w1, 'value'), (w2, 'value'))" | |||
|
549 | ], | |||
|
550 | "language": "python", | |||
|
551 | "metadata": {}, | |||
|
552 | "outputs": [], | |||
|
553 | "prompt_number": 58 | |||
|
554 | }, | |||
|
555 | { | |||
|
556 | "cell_type": "heading", | |||
|
557 | "level": 2, | |||
|
558 | "metadata": {}, | |||
|
559 | "source": [ | |||
|
560 | "ButtonWidget" | |||
|
561 | ] | |||
|
562 | }, | |||
|
563 | { | |||
|
564 | "cell_type": "code", | |||
|
565 | "collapsed": false, | |||
|
566 | "input": [ | |||
|
567 | "widgets.ButtonWidget(description='Click me')" | |||
|
568 | ], | |||
|
569 | "language": "python", | |||
|
570 | "metadata": {}, | |||
|
571 | "outputs": [], | |||
|
572 | "prompt_number": 60 | |||
|
573 | }, | |||
|
574 | { | |||
|
575 | "cell_type": "markdown", | |||
|
576 | "metadata": {}, | |||
|
577 | "source": [ | |||
|
578 | "[Next](Widget Events.ipynb)" | |||
|
579 | ] | |||
|
580 | } | |||
|
581 | ], | |||
|
582 | "metadata": {} | |||
|
583 | } | |||
|
584 | ] | |||
|
585 | } No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now