Show More
@@ -110,17 +110,7 b'' | |||
|
110 | 110 | ], |
|
111 | 111 | "language": "python", |
|
112 | 112 | "metadata": {}, |
|
113 | "outputs": [ | |
|
114 | { | |
|
115 | "output_type": "stream", | |
|
116 | "stream": "stdout", | |
|
117 | "text": [ | |
|
118 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'value', 'step', 'max', 'min', 'disabled', 'orientation', 'description']\n", | |
|
119 | "[]\n", | |
|
120 | "[]\n" | |
|
121 | ] | |
|
122 | } | |
|
123 | ], | |
|
113 | "outputs": [], | |
|
124 | 114 | "prompt_number": 3 |
|
125 | 115 | }, |
|
126 | 116 | { |
@@ -145,7 +135,7 b'' | |||
|
145 | 135 | "cell_type": "code", |
|
146 | 136 | "collapsed": false, |
|
147 | 137 | "input": [ |
|
148 | "mywidget.value" | |
|
138 | "mywidget.value\n" | |
|
149 | 139 | ], |
|
150 | 140 | "language": "python", |
|
151 | 141 | "metadata": {}, |
@@ -155,7 +145,7 b'' | |||
|
155 | 145 | "output_type": "pyout", |
|
156 | 146 | "prompt_number": 13, |
|
157 | 147 | "text": [ |
|
158 |
" |
|
|
148 | "42.7" | |
|
159 | 149 | ] |
|
160 | 150 | } |
|
161 | 151 | ], |
@@ -182,12 +172,10 b'' | |||
|
182 | 172 | { |
|
183 | 173 | "metadata": {}, |
|
184 | 174 | "output_type": "pyout", |
|
185 |
"prompt_number": 1 |
|
|
175 | "prompt_number": 14, | |
|
186 | 176 | "text": [ |
|
187 | 177 | "['visible',\n", |
|
188 | 178 | " '_css',\n", |
|
189 | " '_children_attr',\n", | |
|
190 | " '_children_lists_attr',\n", | |
|
191 | 179 | " 'default_view_name',\n", |
|
192 | 180 | " 'value',\n", |
|
193 | 181 | " 'step',\n", |
@@ -199,7 +187,7 b'' | |||
|
199 | 187 | ] |
|
200 | 188 | } |
|
201 | 189 | ], |
|
202 |
"prompt_number": 1 |
|
|
190 | "prompt_number": 14 | |
|
203 | 191 | }, |
|
204 | 192 | { |
|
205 | 193 | "cell_type": "markdown", |
@@ -217,7 +205,7 b'' | |||
|
217 | 205 | "language": "python", |
|
218 | 206 | "metadata": {}, |
|
219 | 207 | "outputs": [], |
|
220 |
"prompt_number": 1 |
|
|
208 | "prompt_number": 15 | |
|
221 | 209 | }, |
|
222 | 210 | { |
|
223 | 211 | "cell_type": "markdown", |
@@ -238,13 +226,13 b'' | |||
|
238 | 226 | { |
|
239 | 227 | "metadata": {}, |
|
240 | 228 | "output_type": "pyout", |
|
241 |
"prompt_number": |
|
|
229 | "prompt_number": 16, | |
|
242 | 230 | "text": [ |
|
243 | 231 | "25.0" |
|
244 | 232 | ] |
|
245 | 233 | } |
|
246 | 234 | ], |
|
247 |
"prompt_number": |
|
|
235 | "prompt_number": 16 | |
|
248 | 236 | }, |
|
249 | 237 | { |
|
250 | 238 | "cell_type": "markdown", |
@@ -262,18 +250,8 b'' | |||
|
262 | 250 | ], |
|
263 | 251 | "language": "python", |
|
264 | 252 | "metadata": {}, |
|
265 | "outputs": [ | |
|
266 | { | |
|
267 | "output_type": "stream", | |
|
268 | "stream": "stdout", | |
|
269 | "text": [ | |
|
270 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'value', 'values', 'disabled', 'description']\n", | |
|
271 | "[]\n", | |
|
272 | "[]\n" | |
|
273 | ] | |
|
274 | } | |
|
275 | ], | |
|
276 | "prompt_number": 14 | |
|
253 | "outputs": [], | |
|
254 | "prompt_number": 17 | |
|
277 | 255 | }, |
|
278 | 256 | { |
|
279 | 257 | "cell_type": "code", |
@@ -287,13 +265,13 b'' | |||
|
287 | 265 | { |
|
288 | 266 | "metadata": {}, |
|
289 | 267 | "output_type": "pyout", |
|
290 |
"prompt_number": 1 |
|
|
268 | "prompt_number": 18, | |
|
291 | 269 | "text": [ |
|
292 |
"u' |
|
|
270 | "u'Nothing Selected'" | |
|
293 | 271 | ] |
|
294 | 272 | } |
|
295 | 273 | ], |
|
296 |
"prompt_number": 1 |
|
|
274 | "prompt_number": 18 | |
|
297 | 275 | }, |
|
298 | 276 | { |
|
299 | 277 | "cell_type": "heading", |
@@ -322,13 +300,13 b'' | |||
|
322 | 300 | { |
|
323 | 301 | "metadata": {}, |
|
324 | 302 | "output_type": "pyout", |
|
325 |
"prompt_number": 1 |
|
|
303 | "prompt_number": 19, | |
|
326 | 304 | "text": [ |
|
327 | 305 | "u'FloatSliderView'" |
|
328 | 306 | ] |
|
329 | 307 | } |
|
330 | 308 | ], |
|
331 |
"prompt_number": 1 |
|
|
309 | "prompt_number": 19 | |
|
332 | 310 | }, |
|
333 | 311 | { |
|
334 | 312 | "cell_type": "markdown", |
@@ -347,7 +325,7 b'' | |||
|
347 | 325 | "language": "python", |
|
348 | 326 | "metadata": {}, |
|
349 | 327 | "outputs": [], |
|
350 |
"prompt_number": |
|
|
328 | "prompt_number": 20 | |
|
351 | 329 | }, |
|
352 | 330 | { |
|
353 | 331 | "cell_type": "markdown", |
This diff has been collapsed as it changes many lines, (555 lines changed) Show them Hide them | |||
@@ -25,7 +25,7 b'' | |||
|
25 | 25 | "language": "python", |
|
26 | 26 | "metadata": {}, |
|
27 | 27 | "outputs": [], |
|
28 |
"prompt_number": |
|
|
28 | "prompt_number": 2 | |
|
29 | 29 | }, |
|
30 | 30 | { |
|
31 | 31 | "cell_type": "heading", |
@@ -82,7 +82,7 b'' | |||
|
82 | 82 | ] |
|
83 | 83 | } |
|
84 | 84 | ], |
|
85 |
"prompt_number": |
|
|
85 | "prompt_number": 3 | |
|
86 | 86 | }, |
|
87 | 87 | { |
|
88 | 88 | "cell_type": "markdown", |
@@ -108,7 +108,7 b'' | |||
|
108 | 108 | "def on_value_change(name, value):\n", |
|
109 | 109 | " print(value)\n", |
|
110 | 110 | "\n", |
|
111 |
" |
|
|
111 | "intrange.on_trait_change(on_value_change, 'value')" | |
|
112 | 112 | ], |
|
113 | 113 | "language": "python", |
|
114 | 114 | "metadata": {}, |
@@ -117,13 +117,298 b'' | |||
|
117 | 117 | "output_type": "stream", |
|
118 | 118 | "stream": "stdout", |
|
119 | 119 | "text": [ |
|
120 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'value', 'step', 'max', 'min', 'disabled', 'orientation', 'description']\n", | |
|
121 |
|
|
|
122 | "[]\n" | |
|
120 | "1\n" | |
|
121 | ] | |
|
122 | }, | |
|
123 | { | |
|
124 | "output_type": "stream", | |
|
125 | "stream": "stdout", | |
|
126 | "text": [ | |
|
127 | "2\n" | |
|
128 | ] | |
|
129 | }, | |
|
130 | { | |
|
131 | "output_type": "stream", | |
|
132 | "stream": "stdout", | |
|
133 | "text": [ | |
|
134 | "3\n" | |
|
135 | ] | |
|
136 | }, | |
|
137 | { | |
|
138 | "output_type": "stream", | |
|
139 | "stream": "stdout", | |
|
140 | "text": [ | |
|
141 | "4\n" | |
|
142 | ] | |
|
143 | }, | |
|
144 | { | |
|
145 | "output_type": "stream", | |
|
146 | "stream": "stdout", | |
|
147 | "text": [ | |
|
148 | "5\n" | |
|
149 | ] | |
|
150 | }, | |
|
151 | { | |
|
152 | "output_type": "stream", | |
|
153 | "stream": "stdout", | |
|
154 | "text": [ | |
|
155 | "6\n" | |
|
156 | ] | |
|
157 | }, | |
|
158 | { | |
|
159 | "output_type": "stream", | |
|
160 | "stream": "stdout", | |
|
161 | "text": [ | |
|
162 | "7\n" | |
|
163 | ] | |
|
164 | }, | |
|
165 | { | |
|
166 | "output_type": "stream", | |
|
167 | "stream": "stdout", | |
|
168 | "text": [ | |
|
169 | "8\n" | |
|
170 | ] | |
|
171 | }, | |
|
172 | { | |
|
173 | "output_type": "stream", | |
|
174 | "stream": "stdout", | |
|
175 | "text": [ | |
|
176 | "9\n" | |
|
177 | ] | |
|
178 | }, | |
|
179 | { | |
|
180 | "output_type": "stream", | |
|
181 | "stream": "stdout", | |
|
182 | "text": [ | |
|
183 | "10\n" | |
|
184 | ] | |
|
185 | }, | |
|
186 | { | |
|
187 | "output_type": "stream", | |
|
188 | "stream": "stdout", | |
|
189 | "text": [ | |
|
190 | "11\n" | |
|
191 | ] | |
|
192 | }, | |
|
193 | { | |
|
194 | "output_type": "stream", | |
|
195 | "stream": "stdout", | |
|
196 | "text": [ | |
|
197 | "12\n" | |
|
198 | ] | |
|
199 | }, | |
|
200 | { | |
|
201 | "output_type": "stream", | |
|
202 | "stream": "stdout", | |
|
203 | "text": [ | |
|
204 | "13\n" | |
|
205 | ] | |
|
206 | }, | |
|
207 | { | |
|
208 | "output_type": "stream", | |
|
209 | "stream": "stdout", | |
|
210 | "text": [ | |
|
211 | "14\n" | |
|
212 | ] | |
|
213 | }, | |
|
214 | { | |
|
215 | "output_type": "stream", | |
|
216 | "stream": "stdout", | |
|
217 | "text": [ | |
|
218 | "15\n" | |
|
219 | ] | |
|
220 | }, | |
|
221 | { | |
|
222 | "output_type": "stream", | |
|
223 | "stream": "stdout", | |
|
224 | "text": [ | |
|
225 | "16\n" | |
|
226 | ] | |
|
227 | }, | |
|
228 | { | |
|
229 | "output_type": "stream", | |
|
230 | "stream": "stdout", | |
|
231 | "text": [ | |
|
232 | "17\n" | |
|
233 | ] | |
|
234 | }, | |
|
235 | { | |
|
236 | "output_type": "stream", | |
|
237 | "stream": "stdout", | |
|
238 | "text": [ | |
|
239 | "18\n" | |
|
240 | ] | |
|
241 | }, | |
|
242 | { | |
|
243 | "output_type": "stream", | |
|
244 | "stream": "stdout", | |
|
245 | "text": [ | |
|
246 | "20\n" | |
|
247 | ] | |
|
248 | }, | |
|
249 | { | |
|
250 | "output_type": "stream", | |
|
251 | "stream": "stdout", | |
|
252 | "text": [ | |
|
253 | "19\n" | |
|
254 | ] | |
|
255 | }, | |
|
256 | { | |
|
257 | "output_type": "stream", | |
|
258 | "stream": "stdout", | |
|
259 | "text": [ | |
|
260 | "18\n" | |
|
261 | ] | |
|
262 | }, | |
|
263 | { | |
|
264 | "output_type": "stream", | |
|
265 | "stream": "stdout", | |
|
266 | "text": [ | |
|
267 | "17\n" | |
|
268 | ] | |
|
269 | }, | |
|
270 | { | |
|
271 | "output_type": "stream", | |
|
272 | "stream": "stdout", | |
|
273 | "text": [ | |
|
274 | "16\n" | |
|
275 | ] | |
|
276 | }, | |
|
277 | { | |
|
278 | "output_type": "stream", | |
|
279 | "stream": "stdout", | |
|
280 | "text": [ | |
|
281 | "12\n" | |
|
282 | ] | |
|
283 | }, | |
|
284 | { | |
|
285 | "output_type": "stream", | |
|
286 | "stream": "stdout", | |
|
287 | "text": [ | |
|
288 | "10\n" | |
|
289 | ] | |
|
290 | }, | |
|
291 | { | |
|
292 | "output_type": "stream", | |
|
293 | "stream": "stdout", | |
|
294 | "text": [ | |
|
295 | "8\n" | |
|
296 | ] | |
|
297 | }, | |
|
298 | { | |
|
299 | "output_type": "stream", | |
|
300 | "stream": "stdout", | |
|
301 | "text": [ | |
|
302 | "6\n" | |
|
303 | ] | |
|
304 | }, | |
|
305 | { | |
|
306 | "output_type": "stream", | |
|
307 | "stream": "stdout", | |
|
308 | "text": [ | |
|
309 | "4\n" | |
|
310 | ] | |
|
311 | }, | |
|
312 | { | |
|
313 | "output_type": "stream", | |
|
314 | "stream": "stdout", | |
|
315 | "text": [ | |
|
316 | "3\n" | |
|
317 | ] | |
|
318 | }, | |
|
319 | { | |
|
320 | "output_type": "stream", | |
|
321 | "stream": "stdout", | |
|
322 | "text": [ | |
|
323 | "2\n" | |
|
324 | ] | |
|
325 | }, | |
|
326 | { | |
|
327 | "output_type": "stream", | |
|
328 | "stream": "stdout", | |
|
329 | "text": [ | |
|
330 | "1\n" | |
|
331 | ] | |
|
332 | }, | |
|
333 | { | |
|
334 | "output_type": "stream", | |
|
335 | "stream": "stdout", | |
|
336 | "text": [ | |
|
337 | "4\n" | |
|
338 | ] | |
|
339 | }, | |
|
340 | { | |
|
341 | "output_type": "stream", | |
|
342 | "stream": "stdout", | |
|
343 | "text": [ | |
|
344 | "10\n" | |
|
345 | ] | |
|
346 | }, | |
|
347 | { | |
|
348 | "output_type": "stream", | |
|
349 | "stream": "stdout", | |
|
350 | "text": [ | |
|
351 | "18\n" | |
|
352 | ] | |
|
353 | }, | |
|
354 | { | |
|
355 | "output_type": "stream", | |
|
356 | "stream": "stdout", | |
|
357 | "text": [ | |
|
358 | "39\n" | |
|
359 | ] | |
|
360 | }, | |
|
361 | { | |
|
362 | "output_type": "stream", | |
|
363 | "stream": "stdout", | |
|
364 | "text": [ | |
|
365 | "60\n" | |
|
366 | ] | |
|
367 | }, | |
|
368 | { | |
|
369 | "output_type": "stream", | |
|
370 | "stream": "stdout", | |
|
371 | "text": [ | |
|
372 | "68\n" | |
|
373 | ] | |
|
374 | }, | |
|
375 | { | |
|
376 | "output_type": "stream", | |
|
377 | "stream": "stdout", | |
|
378 | "text": [ | |
|
379 | "75\n" | |
|
380 | ] | |
|
381 | }, | |
|
382 | { | |
|
383 | "output_type": "stream", | |
|
384 | "stream": "stdout", | |
|
385 | "text": [ | |
|
386 | "79\n" | |
|
387 | ] | |
|
388 | }, | |
|
389 | { | |
|
390 | "output_type": "stream", | |
|
391 | "stream": "stdout", | |
|
392 | "text": [ | |
|
393 | "82\n" | |
|
394 | ] | |
|
395 | }, | |
|
396 | { | |
|
397 | "output_type": "stream", | |
|
398 | "stream": "stdout", | |
|
399 | "text": [ | |
|
400 | "85\n" | |
|
401 | ] | |
|
402 | }, | |
|
403 | { | |
|
404 | "output_type": "stream", | |
|
405 | "stream": "stdout", | |
|
406 | "text": [ | |
|
407 | "86\n" | |
|
123 | 408 | ] |
|
124 | 409 | } |
|
125 | 410 | ], |
|
126 |
"prompt_number": |
|
|
411 | "prompt_number": 5 | |
|
127 | 412 | }, |
|
128 | 413 | { |
|
129 | 414 | "cell_type": "heading", |
@@ -175,7 +460,7 b'' | |||
|
175 | 460 | ] |
|
176 | 461 | } |
|
177 | 462 | ], |
|
178 |
"prompt_number": |
|
|
463 | "prompt_number": 6 | |
|
179 | 464 | }, |
|
180 | 465 | { |
|
181 | 466 | "cell_type": "markdown", |
@@ -200,269 +485,255 b'' | |||
|
200 | 485 | "text": [ |
|
201 | 486 | "hi\n" |
|
202 | 487 | ] |
|
203 | } | |
|
204 | ], | |
|
205 | "prompt_number": 5 | |
|
206 | }, | |
|
207 | { | |
|
208 | "cell_type": "code", | |
|
209 | "collapsed": false, | |
|
210 | "input": [ | |
|
211 | "button = widgets.ButtonWidget(description=\"Click Me!\")\n", | |
|
212 | "display(button)\n", | |
|
213 | "\n", | |
|
214 | "def on_button_clicked(sender):\n", | |
|
215 | " print(\"Button clicked.\")\n", | |
|
216 | " intrange.value +=1\n", | |
|
217 | "\n", | |
|
218 | "button.on_click(on_button_clicked)" | |
|
219 | ], | |
|
220 | "language": "python", | |
|
221 | "metadata": {}, | |
|
222 | "outputs": [ | |
|
488 | }, | |
|
223 | 489 | { |
|
224 | 490 | "output_type": "stream", |
|
225 | 491 | "stream": "stdout", |
|
226 | 492 | "text": [ |
|
227 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
228 | "[]\n", | |
|
229 | "[]\n" | |
|
493 | "85\n" | |
|
230 | 494 | ] |
|
231 | 495 | }, |
|
232 | 496 | { |
|
233 | 497 | "output_type": "stream", |
|
234 | 498 | "stream": "stdout", |
|
235 | 499 | "text": [ |
|
236 | "Button clicked.\n" | |
|
500 | "84\n" | |
|
237 | 501 | ] |
|
238 | 502 | }, |
|
239 | 503 | { |
|
240 | 504 | "output_type": "stream", |
|
241 | 505 | "stream": "stdout", |
|
242 | 506 | "text": [ |
|
243 | "Button clicked.\n" | |
|
507 | "81\n" | |
|
244 | 508 | ] |
|
245 | 509 | }, |
|
246 | 510 | { |
|
247 | 511 | "output_type": "stream", |
|
248 | 512 | "stream": "stdout", |
|
249 | 513 | "text": [ |
|
250 | "Button clicked.\n" | |
|
514 | "79\n" | |
|
251 | 515 | ] |
|
252 | 516 | }, |
|
253 | 517 | { |
|
254 | 518 | "output_type": "stream", |
|
255 | 519 | "stream": "stdout", |
|
256 | 520 | "text": [ |
|
257 | "Button clicked.\n" | |
|
521 | "73\n" | |
|
258 | 522 | ] |
|
259 | } | |
|
260 | ], | |
|
261 | "prompt_number": 12 | |
|
262 | }, | |
|
263 | { | |
|
264 | "cell_type": "markdown", | |
|
265 | "metadata": {}, | |
|
266 | "source": [ | |
|
267 | "Event handlers can also be used to create widgets. In the example below, clicking a button spawns another button with a description equal to how many times the parent button had been clicked at the time." | |
|
268 | ] | |
|
269 | }, | |
|
270 | { | |
|
271 | "cell_type": "code", | |
|
272 | "collapsed": false, | |
|
273 | "input": [], | |
|
274 | "language": "python", | |
|
275 | "metadata": {}, | |
|
276 | "outputs": [ | |
|
523 | }, | |
|
277 | 524 | { |
|
278 | "metadata": {}, | |
|
279 |
" |
|
|
280 | "prompt_number": 11, | |
|
525 | "output_type": "stream", | |
|
526 | "stream": "stdout", | |
|
281 | 527 | "text": [ |
|
282 | "{'content': {'data': \"{'parent_header': {}, 'msg_type': u'comm_msg', 'msg_id': u'3DBB06AD83C942DD85DC6477B08F1FBF', 'content': {u'data': {u'method': u'custom', u'custom_content': {u'event': u'click'}}, u'comm_id': u'eea5f11ae7aa473993dd0c81d6016648'}, 'header': {u'username': u'username', u'msg_id': u'3DBB06AD83C942DD85DC6477B08F1FBF', u'msg_type': u'comm_msg', u'session': u'0F6D6BE728DA47A38CFC4BDEACF34FC4'}, 'buffers': [], 'metadata': {}}\\ncustom message {'parent_header': {}, 'msg_type': u'comm_msg', 'msg_id': u'3DBB06AD83C942DD85DC6477B08F1FBF', 'content': {u'data': {u'method': u'custom', u'custom_content': {u'event': u'click'}}, u'comm_id': u'eea5f11ae7aa473993dd0c81d6016648'}, 'header': {u'username': u'username', u'msg_id': u'3DBB06AD83C942DD85DC6477B08F1FBF', u'msg_type': u'comm_msg', u'session': u'0F6D6BE728DA47A38CFC4BDEACF34FC4'}, 'buffers': [], 'metadata': {}}\\nhandling click\\n{u'event': u'click'}\\nButton clicked.\\n2\\n\",\n", | |
|
283 | " 'name': 'stdout'},\n", | |
|
284 | " 'header': {'msg_id': 'd9dc144a-d86c-42c1-8bab-f8a6bc525723',\n", | |
|
285 | " 'msg_type': 'stream',\n", | |
|
286 | " 'session': '9b9408d8-7420-4e0c-976d-cdda9f8d2564',\n", | |
|
287 | " 'username': 'kernel'},\n", | |
|
288 | " 'metadata': {},\n", | |
|
289 | " 'msg_id': 'd9dc144a-d86c-42c1-8bab-f8a6bc525723',\n", | |
|
290 | " 'msg_type': 'stream',\n", | |
|
291 | " 'parent_header': {'msg_id': '3DBB06AD83C942DD85DC6477B08F1FBF',\n", | |
|
292 | " 'msg_type': 'comm_msg',\n", | |
|
293 | " 'session': '0F6D6BE728DA47A38CFC4BDEACF34FC4',\n", | |
|
294 | " 'username': 'username'}}" | |
|
528 | "70\n" | |
|
295 | 529 | ] |
|
296 | } | |
|
297 | ], | |
|
298 | "prompt_number": 11 | |
|
299 | }, | |
|
300 | { | |
|
301 | "cell_type": "code", | |
|
302 | "collapsed": false, | |
|
303 | "input": [ | |
|
304 | "def show_button(sender=None):\n", | |
|
305 | " button = widgets.ButtonWidget()\n", | |
|
306 | " button.clicks = 0\n", | |
|
307 | " if sender is None:\n", | |
|
308 | " button.description = \"0\"\n", | |
|
309 | " else:\n", | |
|
310 | " sender.clicks += 1\n", | |
|
311 | " button.description = \"%d\" % sender.clicks\n", | |
|
312 | " display(button)\n", | |
|
313 | " button.on_click(show_button)\n", | |
|
314 | "show_button()\n", | |
|
315 | " " | |
|
316 | ], | |
|
317 | "language": "python", | |
|
318 | "metadata": {}, | |
|
319 | "outputs": [ | |
|
530 | }, | |
|
320 | 531 | { |
|
321 | 532 | "output_type": "stream", |
|
322 | 533 | "stream": "stdout", |
|
323 | 534 | "text": [ |
|
324 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
325 | "[]\n", | |
|
326 | "[]\n" | |
|
535 | "67\n" | |
|
327 | 536 | ] |
|
328 | 537 | }, |
|
329 | 538 | { |
|
330 | 539 | "output_type": "stream", |
|
331 | 540 | "stream": "stdout", |
|
332 | 541 | "text": [ |
|
333 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
334 | "[]\n", | |
|
335 | "[]\n" | |
|
542 | "59\n" | |
|
336 | 543 | ] |
|
337 | 544 | }, |
|
338 | 545 | { |
|
339 | 546 | "output_type": "stream", |
|
340 | 547 | "stream": "stdout", |
|
341 | 548 | "text": [ |
|
342 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
343 | "[]\n", | |
|
344 | "[]\n" | |
|
549 | "56\n" | |
|
345 | 550 | ] |
|
346 | 551 | }, |
|
347 | 552 | { |
|
348 | 553 | "output_type": "stream", |
|
349 | 554 | "stream": "stdout", |
|
350 | 555 | "text": [ |
|
351 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
352 | "[]\n", | |
|
353 | "[]\n" | |
|
556 | "53\n" | |
|
354 | 557 | ] |
|
355 | 558 | }, |
|
356 | 559 | { |
|
357 | 560 | "output_type": "stream", |
|
358 | 561 | "stream": "stdout", |
|
359 | 562 | "text": [ |
|
360 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
361 | "[]\n", | |
|
362 | "[]\n" | |
|
563 | "51\n" | |
|
363 | 564 | ] |
|
364 | 565 | }, |
|
365 | 566 | { |
|
366 | 567 | "output_type": "stream", |
|
367 | 568 | "stream": "stdout", |
|
368 | 569 | "text": [ |
|
369 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
370 | "[]\n", | |
|
371 | "[]\n" | |
|
570 | "49\n" | |
|
372 | 571 | ] |
|
373 | 572 | }, |
|
374 | 573 | { |
|
375 | 574 | "output_type": "stream", |
|
376 | 575 | "stream": "stdout", |
|
377 | 576 | "text": [ |
|
378 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
379 | "[]\n", | |
|
380 | "[]\n" | |
|
577 | "47\n" | |
|
381 | 578 | ] |
|
382 | 579 | }, |
|
383 | 580 | { |
|
384 | 581 | "output_type": "stream", |
|
385 | 582 | "stream": "stdout", |
|
386 | 583 | "text": [ |
|
387 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
388 | "[]\n", | |
|
389 | "[]\n" | |
|
584 | "45\n" | |
|
390 | 585 | ] |
|
391 | 586 | }, |
|
392 | 587 | { |
|
393 | 588 | "output_type": "stream", |
|
394 | 589 | "stream": "stdout", |
|
395 | 590 | "text": [ |
|
396 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
397 | "[]\n", | |
|
398 | "[]\n" | |
|
591 | "44\n" | |
|
399 | 592 | ] |
|
400 | 593 | }, |
|
401 | 594 | { |
|
402 | 595 | "output_type": "stream", |
|
403 | 596 | "stream": "stdout", |
|
404 | 597 | "text": [ |
|
405 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
406 |
|
|
|
407 | "[]\n" | |
|
598 | "42\n" | |
|
599 | ] | |
|
600 | } | |
|
601 | ], | |
|
602 | "prompt_number": 7 | |
|
603 | }, | |
|
604 | { | |
|
605 | "cell_type": "code", | |
|
606 | "collapsed": false, | |
|
607 | "input": [ | |
|
608 | "button = widgets.ButtonWidget(description=\"Click Me!\")\n", | |
|
609 | "display(button)\n", | |
|
610 | "\n", | |
|
611 | "def on_button_clicked(sender):\n", | |
|
612 | " print(\"Button clicked.\")\n", | |
|
613 | " intrange.value +=1\n", | |
|
614 | "\n", | |
|
615 | "button.on_click(on_button_clicked)" | |
|
616 | ], | |
|
617 | "language": "python", | |
|
618 | "metadata": {}, | |
|
619 | "outputs": [ | |
|
620 | { | |
|
621 | "output_type": "stream", | |
|
622 | "stream": "stdout", | |
|
623 | "text": [ | |
|
624 | "Button clicked.\n", | |
|
625 | "43\n" | |
|
408 | 626 | ] |
|
409 | 627 | }, |
|
410 | 628 | { |
|
411 | 629 | "output_type": "stream", |
|
412 | 630 | "stream": "stdout", |
|
413 | 631 | "text": [ |
|
414 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
415 |
" |
|
|
416 | "[]\n" | |
|
632 | "Button clicked.\n", | |
|
633 | "44\n" | |
|
417 | 634 | ] |
|
418 | 635 | }, |
|
419 | 636 | { |
|
420 | 637 | "output_type": "stream", |
|
421 | 638 | "stream": "stdout", |
|
422 | 639 | "text": [ |
|
423 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
424 |
" |
|
|
425 | "[]\n" | |
|
640 | "Button clicked.\n", | |
|
641 | "45\n" | |
|
426 | 642 | ] |
|
427 | 643 | }, |
|
428 | 644 | { |
|
429 | 645 | "output_type": "stream", |
|
430 | 646 | "stream": "stdout", |
|
431 | 647 | "text": [ |
|
432 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
433 |
" |
|
|
434 | "[]\n" | |
|
648 | "Button clicked.\n", | |
|
649 | "46\n" | |
|
435 | 650 | ] |
|
436 | 651 | }, |
|
437 | 652 | { |
|
438 | 653 | "output_type": "stream", |
|
439 | 654 | "stream": "stdout", |
|
440 | 655 | "text": [ |
|
441 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
442 |
" |
|
|
443 | "[]\n" | |
|
656 | "Button clicked.\n", | |
|
657 | "47\n" | |
|
444 | 658 | ] |
|
445 | 659 | }, |
|
446 | 660 | { |
|
447 | 661 | "output_type": "stream", |
|
448 | 662 | "stream": "stdout", |
|
449 | 663 | "text": [ |
|
450 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
451 |
" |
|
|
452 | "[]\n" | |
|
664 | "Button clicked.\n", | |
|
665 | "48\n" | |
|
453 | 666 | ] |
|
454 | 667 | }, |
|
455 | 668 | { |
|
456 | 669 | "output_type": "stream", |
|
457 | 670 | "stream": "stdout", |
|
458 | 671 | "text": [ |
|
459 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'description', 'disabled']\n", | |
|
460 |
" |
|
|
461 | "[]\n" | |
|
672 | "Button clicked.\n", | |
|
673 | "49\n" | |
|
462 | 674 | ] |
|
463 | 675 | } |
|
464 | 676 | ], |
|
465 |
"prompt_number": |
|
|
677 | "prompt_number": 8 | |
|
678 | }, | |
|
679 | { | |
|
680 | "cell_type": "markdown", | |
|
681 | "metadata": {}, | |
|
682 | "source": [ | |
|
683 | "Event handlers can also be used to create widgets. In the example below, clicking a button spawns another button with a description equal to how many times the parent button had been clicked at the time." | |
|
684 | ] | |
|
685 | }, | |
|
686 | { | |
|
687 | "cell_type": "code", | |
|
688 | "collapsed": false, | |
|
689 | "input": [], | |
|
690 | "language": "python", | |
|
691 | "metadata": {}, | |
|
692 | "outputs": [ | |
|
693 | { | |
|
694 | "metadata": {}, | |
|
695 | "output_type": "pyout", | |
|
696 | "prompt_number": 11, | |
|
697 | "text": [ | |
|
698 | "{'content': {'data': \"{'parent_header': {}, 'msg_type': u'comm_msg', 'msg_id': u'3DBB06AD83C942DD85DC6477B08F1FBF', 'content': {u'data': {u'method': u'custom', u'custom_content': {u'event': u'click'}}, u'comm_id': u'eea5f11ae7aa473993dd0c81d6016648'}, 'header': {u'username': u'username', u'msg_id': u'3DBB06AD83C942DD85DC6477B08F1FBF', u'msg_type': u'comm_msg', u'session': u'0F6D6BE728DA47A38CFC4BDEACF34FC4'}, 'buffers': [], 'metadata': {}}\\ncustom message {'parent_header': {}, 'msg_type': u'comm_msg', 'msg_id': u'3DBB06AD83C942DD85DC6477B08F1FBF', 'content': {u'data': {u'method': u'custom', u'custom_content': {u'event': u'click'}}, u'comm_id': u'eea5f11ae7aa473993dd0c81d6016648'}, 'header': {u'username': u'username', u'msg_id': u'3DBB06AD83C942DD85DC6477B08F1FBF', u'msg_type': u'comm_msg', u'session': u'0F6D6BE728DA47A38CFC4BDEACF34FC4'}, 'buffers': [], 'metadata': {}}\\nhandling click\\n{u'event': u'click'}\\nButton clicked.\\n2\\n\",\n", | |
|
699 | " 'name': 'stdout'},\n", | |
|
700 | " 'header': {'msg_id': 'd9dc144a-d86c-42c1-8bab-f8a6bc525723',\n", | |
|
701 | " 'msg_type': 'stream',\n", | |
|
702 | " 'session': '9b9408d8-7420-4e0c-976d-cdda9f8d2564',\n", | |
|
703 | " 'username': 'kernel'},\n", | |
|
704 | " 'metadata': {},\n", | |
|
705 | " 'msg_id': 'd9dc144a-d86c-42c1-8bab-f8a6bc525723',\n", | |
|
706 | " 'msg_type': 'stream',\n", | |
|
707 | " 'parent_header': {'msg_id': '3DBB06AD83C942DD85DC6477B08F1FBF',\n", | |
|
708 | " 'msg_type': 'comm_msg',\n", | |
|
709 | " 'session': '0F6D6BE728DA47A38CFC4BDEACF34FC4',\n", | |
|
710 | " 'username': 'username'}}" | |
|
711 | ] | |
|
712 | } | |
|
713 | ], | |
|
714 | "prompt_number": 11 | |
|
715 | }, | |
|
716 | { | |
|
717 | "cell_type": "code", | |
|
718 | "collapsed": false, | |
|
719 | "input": [ | |
|
720 | "def show_button(sender=None):\n", | |
|
721 | " button = widgets.ButtonWidget()\n", | |
|
722 | " button.clicks = 0\n", | |
|
723 | " if sender is None:\n", | |
|
724 | " button.description = \"0\"\n", | |
|
725 | " else:\n", | |
|
726 | " sender.clicks += 1\n", | |
|
727 | " button.description = \"%d\" % sender.clicks\n", | |
|
728 | " display(button)\n", | |
|
729 | " button.on_click(show_button)\n", | |
|
730 | "show_button()\n", | |
|
731 | " " | |
|
732 | ], | |
|
733 | "language": "python", | |
|
734 | "metadata": {}, | |
|
735 | "outputs": [], | |
|
736 | "prompt_number": 9 | |
|
466 | 737 | }, |
|
467 | 738 | { |
|
468 | 739 | "cell_type": "code", |
@@ -17,6 +17,9 b'' | |||
|
17 | 17 | "cell_type": "code", |
|
18 | 18 | "collapsed": false, |
|
19 | 19 | "input": [ |
|
20 | "\n", | |
|
21 | "\n", | |
|
22 | "\n", | |
|
20 | 23 | "from IPython.html import widgets # Widget definitions\n", |
|
21 | 24 | "from IPython.display import display # Used to display widgets in the notebook" |
|
22 | 25 | ], |
@@ -50,7 +53,7 b'' | |||
|
50 | 53 | "floatrange = widgets.FloatRangeWidget() # You can set the parent in the constructor,\n", |
|
51 | 54 | "\n", |
|
52 | 55 | "string = widgets.StringWidget(value='hi')\n", |
|
53 |
"container = widgets. |
|
|
56 | "container = widgets.ContainerWidget(children=[floatrange, string])\n", | |
|
54 | 57 | "\n", |
|
55 | 58 | "display(container) # Displays the `container` and all of it's children." |
|
56 | 59 | ], |
@@ -72,15 +75,15 b'' | |||
|
72 | 75 | "cell_type": "code", |
|
73 | 76 | "collapsed": false, |
|
74 | 77 | "input": [ |
|
75 |
" |
|
|
76 | "display(container)\n", | |
|
78 | "intrange = widgets.IntRangeWidget() # Never gets displayed.\n", | |
|
79 | "container = widgets.MulticontainerWidget(children=[intrange])\n", | |
|
77 | 80 | "\n", |
|
78 | "intrange = widgets.IntRangeWidget(parent=container) # Never gets displayed." | |
|
81 | "display(container)\n" | |
|
79 | 82 | ], |
|
80 | 83 | "language": "python", |
|
81 | 84 | "metadata": {}, |
|
82 | 85 | "outputs": [], |
|
83 |
"prompt_number": |
|
|
86 | "prompt_number": 5 | |
|
84 | 87 | }, |
|
85 | 88 | { |
|
86 | 89 | "cell_type": "markdown", |
@@ -123,20 +126,18 b'' | |||
|
123 | 126 | "cell_type": "code", |
|
124 | 127 | "collapsed": false, |
|
125 | 128 | "input": [ |
|
126 | "container = widgets.MulticontainerWidget()\n", | |
|
127 | 129 | "\n", |
|
128 |
"floatrange = widgets.FloatRangeWidget( |
|
|
130 | "floatrange = widgets.FloatRangeWidget()\n", | |
|
129 | 131 | "floatrange.default_view_name = \"FloatTextView\" # It can be set as a property.\n", |
|
130 | 132 | "\n", |
|
131 | 133 | "string = widgets.StringWidget(default_view_name = \"TextAreaView\") # It can also be set in the constructor.\n", |
|
132 | "string.parent = container\n", | |
|
133 | "\n", | |
|
134 | "container = widgets.MulticontainerWidget(children=[floatrange, string])\n", | |
|
134 | 135 | "display(container)" |
|
135 | 136 | ], |
|
136 | 137 | "language": "python", |
|
137 | 138 | "metadata": {}, |
|
138 | 139 | "outputs": [], |
|
139 |
"prompt_number": |
|
|
140 | "prompt_number": 6 | |
|
140 | 141 | }, |
|
141 | 142 | { |
|
142 | 143 | "cell_type": "markdown", |
@@ -190,18 +191,8 b'' | |||
|
190 | 191 | ], |
|
191 | 192 | "language": "python", |
|
192 | 193 | "metadata": {}, |
|
193 | "outputs": [ | |
|
194 | { | |
|
195 | "output_type": "stream", | |
|
196 | "stream": "stdout", | |
|
197 | "text": [ | |
|
198 | "['visible', '_css', '_children_attr', '_children_lists_attr', 'default_view_name', 'value', 'disabled', 'description']\n", | |
|
199 | "[]\n", | |
|
200 | "[]\n" | |
|
201 | ] | |
|
202 | } | |
|
203 | ], | |
|
204 | "prompt_number": 11 | |
|
194 | "outputs": [], | |
|
195 | "prompt_number": 7 | |
|
205 | 196 | }, |
|
206 | 197 | { |
|
207 | 198 | "cell_type": "code", |
@@ -212,7 +203,7 b'' | |||
|
212 | 203 | "language": "python", |
|
213 | 204 | "metadata": {}, |
|
214 | 205 | "outputs": [], |
|
215 |
"prompt_number": |
|
|
206 | "prompt_number": 8 | |
|
216 | 207 | }, |
|
217 | 208 | { |
|
218 | 209 | "cell_type": "code", |
@@ -223,7 +214,7 b'' | |||
|
223 | 214 | "language": "python", |
|
224 | 215 | "metadata": {}, |
|
225 | 216 | "outputs": [], |
|
226 |
"prompt_number": |
|
|
217 | "prompt_number": 9 | |
|
227 | 218 | }, |
|
228 | 219 | { |
|
229 | 220 | "cell_type": "markdown", |
@@ -319,13 +310,6 b'' | |||
|
319 | 310 | "text": [ |
|
320 | 311 | "False\n" |
|
321 | 312 | ] |
|
322 | }, | |
|
323 | { | |
|
324 | "output_type": "stream", | |
|
325 | "stream": "stdout", | |
|
326 | "text": [ | |
|
327 | "True\n" | |
|
328 | ] | |
|
329 | 313 | } |
|
330 | 314 | ], |
|
331 | 315 | "prompt_number": 2 |
@@ -53,7 +53,7 b'' | |||
|
53 | 53 | "output_type": "stream", |
|
54 | 54 | "stream": "stdout", |
|
55 | 55 | "text": [ |
|
56 |
"Set one or more CSS properties of the widget (shared among all of the |
|
|
56 | "Set one or more CSS properties of the widget (shared among all of the\n", | |
|
57 | 57 | " views). This function has two signatures:\n", |
|
58 | 58 | " - set_css(css_dict, [selector=''])\n", |
|
59 | 59 | " - set_css(key, value, [selector=''])\n", |
@@ -94,8 +94,8 b'' | |||
|
94 | 94 | "output_type": "stream", |
|
95 | 95 | "stream": "stdout", |
|
96 | 96 | "text": [ |
|
97 |
"Get a CSS property of the widget. Note, this function does not |
|
|
98 |
" actually request the CSS from the front-end; Only properties that have |
|
|
97 | "Get a CSS property of the widget. Note, this function does not\n", | |
|
98 | " actually request the CSS from the front-end; Only properties that have\n", | |
|
99 | 99 | " been set with set_css can be read.\n", |
|
100 | 100 | "\n", |
|
101 | 101 | " Parameters\n", |
@@ -121,7 +121,9 b'' | |||
|
121 | 121 | "cell_type": "code", |
|
122 | 122 | "collapsed": false, |
|
123 | 123 | "input": [ |
|
124 | "container = widgets.ContainerWidget()\n", | |
|
124 | "label = widgets.StringWidget(default_view_name=\"HTMLView\")\n", | |
|
125 | "label.value = \"<strong>ALERT: </strong> Hello World!\"\n", | |
|
126 | "container = widgets.ContainerWidget(children=[label])\n", | |
|
125 | 127 | "\n", |
|
126 | 128 | "# set_css used to set a single CSS attribute.\n", |
|
127 | 129 | "container.set_css('border', '3px solid black') # Border the container\n", |
@@ -130,9 +132,6 b'' | |||
|
130 | 132 | "container.set_css({'padding': '6px', # Add padding to the container\n", |
|
131 | 133 | " 'background': 'yellow'}) # Fill the container yellow\n", |
|
132 | 134 | "\n", |
|
133 | "label = widgets.StringWidget(default_view_name=\"HTMLView\", parent=container)\n", | |
|
134 | "label.value = \"<strong>ALERT: </strong> Hello World!\"\n", | |
|
135 | "\n", | |
|
136 | 135 | "display(container)" |
|
137 | 136 | ], |
|
138 | 137 | "language": "python", |
@@ -173,10 +172,10 b'' | |||
|
173 | 172 | " Parameters\n", |
|
174 | 173 | " ----------\n", |
|
175 | 174 | " class_name: unicode\n", |
|
176 |
" Class name(s) to add to the DOM element(s). Multiple class names |
|
|
175 | " Class name(s) to add to the DOM element(s). Multiple class names\n", | |
|
177 | 176 | " must be space separated.\n", |
|
178 | 177 | " selector: unicode (optional)\n", |
|
179 |
" JQuery selector to select the DOM element(s) that the class(es) will |
|
|
178 | " JQuery selector to select the DOM element(s) that the class(es) will\n", | |
|
180 | 179 | " be added to.\n", |
|
181 | 180 | " \n" |
|
182 | 181 | ] |
@@ -200,16 +199,16 b'' | |||
|
200 | 199 | " 'padding': '6px', \n", |
|
201 | 200 | " 'background': 'yellow'}) \n", |
|
202 | 201 | "\n", |
|
203 |
"label = widgets.StringWidget(default_view_name=\"HTMLView\" |
|
|
202 | "label = widgets.StringWidget(default_view_name=\"HTMLView\")\n", | |
|
204 | 203 | "label.value = \"<strong>ALERT: </strong> Hello World!\"\n", |
|
205 | "\n", | |
|
204 | "container.children = [label]\n", | |
|
206 | 205 | "display(container)\n", |
|
207 | 206 | "container.add_class('corner-all') # Must be called AFTER display" |
|
208 | 207 | ], |
|
209 | 208 | "language": "python", |
|
210 | 209 | "metadata": {}, |
|
211 | 210 | "outputs": [], |
|
212 |
"prompt_number": |
|
|
211 | "prompt_number": 7 | |
|
213 | 212 | }, |
|
214 | 213 | { |
|
215 | 214 | "cell_type": "markdown", |
@@ -231,7 +230,7 b'' | |||
|
231 | 230 | "language": "python", |
|
232 | 231 | "metadata": {}, |
|
233 | 232 | "outputs": [], |
|
234 |
"prompt_number": |
|
|
233 | "prompt_number": 11 | |
|
235 | 234 | }, |
|
236 | 235 | { |
|
237 | 236 | "cell_type": "markdown", |
@@ -261,7 +260,7 b'' | |||
|
261 | 260 | "language": "python", |
|
262 | 261 | "metadata": {}, |
|
263 | 262 | "outputs": [], |
|
264 |
"prompt_number": |
|
|
263 | "prompt_number": 12 | |
|
265 | 264 | }, |
|
266 | 265 | { |
|
267 | 266 | "cell_type": "markdown", |
@@ -288,16 +287,16 b'' | |||
|
288 | 287 | " Parameters\n", |
|
289 | 288 | " ----------\n", |
|
290 | 289 | " class_name: unicode\n", |
|
291 |
" Class name(s) to remove from the DOM element(s). Multiple class |
|
|
290 | " Class name(s) to remove from the DOM element(s). Multiple class\n", | |
|
292 | 291 | " names must be space separated.\n", |
|
293 | 292 | " selector: unicode (optional)\n", |
|
294 |
" JQuery selector to select the DOM element(s) that the class(es) will |
|
|
293 | " JQuery selector to select the DOM element(s) that the class(es) will\n", | |
|
295 | 294 | " be removed from.\n", |
|
296 | 295 | " \n" |
|
297 | 296 | ] |
|
298 | 297 | } |
|
299 | 298 | ], |
|
300 |
"prompt_number": |
|
|
299 | "prompt_number": 13 | |
|
301 | 300 | }, |
|
302 | 301 | { |
|
303 | 302 | "cell_type": "markdown", |
@@ -328,7 +327,15 b'' | |||
|
328 | 327 | "language": "python", |
|
329 | 328 | "metadata": {}, |
|
330 | 329 | "outputs": [], |
|
331 |
"prompt_number": 1 |
|
|
330 | "prompt_number": 14 | |
|
331 | }, | |
|
332 | { | |
|
333 | "cell_type": "code", | |
|
334 | "collapsed": false, | |
|
335 | "input": [], | |
|
336 | "language": "python", | |
|
337 | "metadata": {}, | |
|
338 | "outputs": [] | |
|
332 | 339 | } |
|
333 | 340 | ], |
|
334 | 341 | "metadata": {} |
@@ -132,9 +132,9 b'' | |||
|
132 | 132 | "def fill_container(container):\n", |
|
133 | 133 | " components = []\n", |
|
134 | 134 | " for i in range(3):\n", |
|
135 |
" components.append(widgets.StringWidget( |
|
|
135 | " components.append(widgets.StringWidget(default_view_name='HTMLView', value=\"ABC\"[i]))\n", | |
|
136 | 136 | " components[i].set_css(child_style)\n", |
|
137 |
" |
|
|
137 | " container.children = components\n", | |
|
138 | 138 | " \n", |
|
139 | 139 | "container = make_container('VBox')\n", |
|
140 | 140 | "container.vbox()\n", |
@@ -205,7 +205,7 b'' | |||
|
205 | 205 | " components[i].flex1()\n", |
|
206 | 206 | " elif flexes[i] == 2:\n", |
|
207 | 207 | " components[i].flex2()\n", |
|
208 |
" |
|
|
208 | " container.children = components\n", | |
|
209 | 209 | " \n", |
|
210 | 210 | "container = make_container('Different Flex Configurations')\n", |
|
211 | 211 | "container.hbox()\n", |
@@ -234,7 +234,7 b'' | |||
|
234 | 234 | "language": "python", |
|
235 | 235 | "metadata": {}, |
|
236 | 236 | "outputs": [], |
|
237 |
"prompt_number": |
|
|
237 | "prompt_number": 8 | |
|
238 | 238 | }, |
|
239 | 239 | { |
|
240 | 240 | "cell_type": "markdown", |
@@ -253,7 +253,7 b'' | |||
|
253 | 253 | " components.append(widgets.StringWidget(parent=container, default_view_name='HTMLView', value=\"ABC\"[i]))\n", |
|
254 | 254 | " components[i].set_css(child_style)\n", |
|
255 | 255 | " components[i].set_css('height', str((i+1) * 50) + 'px')\n", |
|
256 |
" |
|
|
256 | " container.children = components\n", | |
|
257 | 257 | "\n", |
|
258 | 258 | "container = make_container('HBox Align Start')\n", |
|
259 | 259 | "container.hbox()\n", |
@@ -273,7 +273,7 b'' | |||
|
273 | 273 | "language": "python", |
|
274 | 274 | "metadata": {}, |
|
275 | 275 | "outputs": [], |
|
276 |
"prompt_number": |
|
|
276 | "prompt_number": 9 | |
|
277 | 277 | }, |
|
278 | 278 | { |
|
279 | 279 | "cell_type": "markdown", |
@@ -288,14 +288,22 b'' | |||
|
288 | 288 | "input": [ |
|
289 | 289 | "container = widgets.ContainerWidget()\n", |
|
290 | 290 | "container.hbox()\n", |
|
291 | "for i in range(15):\n", | |
|
292 | " widgets.FloatRangeWidget(orientation='vertical', parent=container, description=str(i+1), value=50.0)\n", | |
|
291 | "container.children=[widgets.FloatRangeWidget(orientation='vertical', description=str(i+1), value=50.0) \n", | |
|
292 | " for i in range(15)]\n", | |
|
293 | 293 | "display(container)" |
|
294 | 294 | ], |
|
295 | 295 | "language": "python", |
|
296 | 296 | "metadata": {}, |
|
297 | 297 | "outputs": [], |
|
298 |
"prompt_number": |
|
|
298 | "prompt_number": 11 | |
|
299 | }, | |
|
300 | { | |
|
301 | "cell_type": "code", | |
|
302 | "collapsed": false, | |
|
303 | "input": [], | |
|
304 | "language": "python", | |
|
305 | "metadata": {}, | |
|
306 | "outputs": [] | |
|
299 | 307 | } |
|
300 | 308 | ], |
|
301 | 309 | "metadata": {} |
@@ -37,7 +37,7 b'' | |||
|
37 | 37 | "language": "python", |
|
38 | 38 | "metadata": {}, |
|
39 | 39 | "outputs": [], |
|
40 | "prompt_number": 1 | |
|
40 | "prompt_number": 15 | |
|
41 | 41 | }, |
|
42 | 42 | { |
|
43 | 43 | "cell_type": "markdown", |
@@ -56,7 +56,7 b'' | |||
|
56 | 56 | "language": "python", |
|
57 | 57 | "metadata": {}, |
|
58 | 58 | "outputs": [], |
|
59 |
"prompt_number": |
|
|
59 | "prompt_number": 16 | |
|
60 | 60 | }, |
|
61 | 61 | { |
|
62 | 62 | "cell_type": "heading", |
@@ -112,7 +112,7 b'' | |||
|
112 | 112 | "language": "python", |
|
113 | 113 | "metadata": {}, |
|
114 | 114 | "outputs": [], |
|
115 |
"prompt_number": |
|
|
115 | "prompt_number": 17 | |
|
116 | 116 | }, |
|
117 | 117 | { |
|
118 | 118 | "cell_type": "markdown", |
@@ -143,7 +143,7 b'' | |||
|
143 | 143 | "input": [ |
|
144 | 144 | "%%javascript\n", |
|
145 | 145 | "\n", |
|
146 | "require([\"notebook/js/widget\"], function(){\n", | |
|
146 | "require([\"notebook/js/widgets/\"], function(){\n", | |
|
147 | 147 | "\n", |
|
148 | 148 | "});" |
|
149 | 149 | ], |
@@ -160,11 +160,11 b'' | |||
|
160 | 160 | "metadata": {}, |
|
161 | 161 | "output_type": "display_data", |
|
162 | 162 | "text": [ |
|
163 |
"<IPython.core.display.Javascript at 0x |
|
|
163 | "<IPython.core.display.Javascript at 0x10a26a850>" | |
|
164 | 164 | ] |
|
165 | 165 | } |
|
166 | 166 | ], |
|
167 |
"prompt_number": |
|
|
167 | "prompt_number": 18 | |
|
168 | 168 | }, |
|
169 | 169 | { |
|
170 | 170 | "cell_type": "markdown", |
@@ -179,7 +179,7 b'' | |||
|
179 | 179 | "input": [ |
|
180 | 180 | "%%javascript\n", |
|
181 | 181 | "\n", |
|
182 | "require([\"notebook/js/widget\"], function(){\n", | |
|
182 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
183 | 183 | " \n", |
|
184 | 184 | " // Define the DateModel and register it with the widget manager.\n", |
|
185 | 185 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -192,7 +192,7 b'' | |||
|
192 | 192 | { |
|
193 | 193 | "javascript": [ |
|
194 | 194 | "\n", |
|
195 | "require([\"notebook/js/widget\"], function(){\n", | |
|
195 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
196 | 196 | " \n", |
|
197 | 197 | " // Define the DateModel and register it with the widget manager.\n", |
|
198 | 198 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -202,11 +202,11 b'' | |||
|
202 | 202 | "metadata": {}, |
|
203 | 203 | "output_type": "display_data", |
|
204 | 204 | "text": [ |
|
205 |
"<IPython.core.display.Javascript at 0x |
|
|
205 | "<IPython.core.display.Javascript at 0x10a26aa10>" | |
|
206 | 206 | ] |
|
207 | 207 | } |
|
208 | 208 | ], |
|
209 |
"prompt_number": |
|
|
209 | "prompt_number": 20 | |
|
210 | 210 | }, |
|
211 | 211 | { |
|
212 | 212 | "cell_type": "markdown", |
@@ -223,7 +223,7 b'' | |||
|
223 | 223 | "input": [ |
|
224 | 224 | "%%javascript\n", |
|
225 | 225 | "\n", |
|
226 | "require([\"notebook/js/widget\"], function(){\n", | |
|
226 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
227 | 227 | " \n", |
|
228 | 228 | " // Define the DateModel and register it with the widget manager.\n", |
|
229 | 229 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -248,7 +248,7 b'' | |||
|
248 | 248 | { |
|
249 | 249 | "javascript": [ |
|
250 | 250 | "\n", |
|
251 | "require([\"notebook/js/widget\"], function(){\n", | |
|
251 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
252 | 252 | " \n", |
|
253 | 253 | " // Define the DateModel and register it with the widget manager.\n", |
|
254 | 254 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -270,11 +270,11 b'' | |||
|
270 | 270 | "metadata": {}, |
|
271 | 271 | "output_type": "display_data", |
|
272 | 272 | "text": [ |
|
273 |
"<IPython.core.display.Javascript at 0x |
|
|
273 | "<IPython.core.display.Javascript at 0x10a26ae90>" | |
|
274 | 274 | ] |
|
275 | 275 | } |
|
276 | 276 | ], |
|
277 |
"prompt_number": |
|
|
277 | "prompt_number": 23 | |
|
278 | 278 | }, |
|
279 | 279 | { |
|
280 | 280 | "cell_type": "heading", |
@@ -301,7 +301,7 b'' | |||
|
301 | 301 | "language": "python", |
|
302 | 302 | "metadata": {}, |
|
303 | 303 | "outputs": [], |
|
304 |
"prompt_number": |
|
|
304 | "prompt_number": 24 | |
|
305 | 305 | }, |
|
306 | 306 | { |
|
307 | 307 | "cell_type": "heading", |
@@ -346,7 +346,7 b'' | |||
|
346 | 346 | "language": "python", |
|
347 | 347 | "metadata": {}, |
|
348 | 348 | "outputs": [], |
|
349 |
"prompt_number": |
|
|
349 | "prompt_number": 25 | |
|
350 | 350 | }, |
|
351 | 351 | { |
|
352 | 352 | "cell_type": "heading", |
@@ -369,7 +369,7 b'' | |||
|
369 | 369 | "input": [ |
|
370 | 370 | "%%javascript\n", |
|
371 | 371 | "\n", |
|
372 | "require([\"notebook/js/widget\"], function(){\n", | |
|
372 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
373 | 373 | " \n", |
|
374 | 374 | " // Define the DateModel and register it with the widget manager.\n", |
|
375 | 375 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -399,7 +399,7 b'' | |||
|
399 | 399 | { |
|
400 | 400 | "javascript": [ |
|
401 | 401 | "\n", |
|
402 | "require([\"notebook/js/widget\"], function(){\n", | |
|
402 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
403 | 403 | " \n", |
|
404 | 404 | " // Define the DateModel and register it with the widget manager.\n", |
|
405 | 405 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -426,11 +426,11 b'' | |||
|
426 | 426 | "metadata": {}, |
|
427 | 427 | "output_type": "display_data", |
|
428 | 428 | "text": [ |
|
429 |
"<IPython.core.display.Javascript at 0x |
|
|
429 | "<IPython.core.display.Javascript at 0x10a274050>" | |
|
430 | 430 | ] |
|
431 | 431 | } |
|
432 | 432 | ], |
|
433 |
"prompt_number": |
|
|
433 | "prompt_number": 26 | |
|
434 | 434 | }, |
|
435 | 435 | { |
|
436 | 436 | "cell_type": "markdown", |
@@ -445,7 +445,7 b'' | |||
|
445 | 445 | "input": [ |
|
446 | 446 | "%%javascript\n", |
|
447 | 447 | "\n", |
|
448 | "require([\"notebook/js/widget\"], function(){\n", | |
|
448 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
449 | 449 | " \n", |
|
450 | 450 | " // Define the DateModel and register it with the widget manager.\n", |
|
451 | 451 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -482,7 +482,7 b'' | |||
|
482 | 482 | { |
|
483 | 483 | "javascript": [ |
|
484 | 484 | "\n", |
|
485 | "require([\"notebook/js/widget\"], function(){\n", | |
|
485 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
486 | 486 | " \n", |
|
487 | 487 | " // Define the DateModel and register it with the widget manager.\n", |
|
488 | 488 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -516,11 +516,11 b'' | |||
|
516 | 516 | "metadata": {}, |
|
517 | 517 | "output_type": "display_data", |
|
518 | 518 | "text": [ |
|
519 |
"<IPython.core.display.Javascript at 0x |
|
|
519 | "<IPython.core.display.Javascript at 0x10a2740d0>" | |
|
520 | 520 | ] |
|
521 | 521 | } |
|
522 | 522 | ], |
|
523 |
"prompt_number": |
|
|
523 | "prompt_number": 27 | |
|
524 | 524 | }, |
|
525 | 525 | { |
|
526 | 526 | "cell_type": "markdown", |
@@ -539,7 +539,7 b'' | |||
|
539 | 539 | "input": [ |
|
540 | 540 | "%%javascript\n", |
|
541 | 541 | "\n", |
|
542 | "require([\"notebook/js/widget\"], function(){\n", | |
|
542 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
543 | 543 | " \n", |
|
544 | 544 | " // Define the DateModel and register it with the widget manager.\n", |
|
545 | 545 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -573,7 +573,6 b'' | |||
|
573 | 573 | " // Callback for when the date is changed.\n", |
|
574 | 574 | " handle_date_change: function(event) {\n", |
|
575 | 575 | " this.model.set('value', this.$date.val());\n", |
|
576 | " this.model.update_other_views(this);\n", | |
|
577 | 576 | " },\n", |
|
578 | 577 | " \n", |
|
579 | 578 | " });\n", |
@@ -588,7 +587,7 b'' | |||
|
588 | 587 | { |
|
589 | 588 | "javascript": [ |
|
590 | 589 | "\n", |
|
591 | "require([\"notebook/js/widget\"], function(){\n", | |
|
590 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
592 | 591 | " \n", |
|
593 | 592 | " // Define the DateModel and register it with the widget manager.\n", |
|
594 | 593 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -622,7 +621,6 b'' | |||
|
622 | 621 | " // Callback for when the date is changed.\n", |
|
623 | 622 | " handle_date_change: function(event) {\n", |
|
624 | 623 | " this.model.set('value', this.$date.val());\n", |
|
625 | " this.model.update_other_views(this);\n", | |
|
626 | 624 | " },\n", |
|
627 | 625 | " \n", |
|
628 | 626 | " });\n", |
@@ -634,11 +632,11 b'' | |||
|
634 | 632 | "metadata": {}, |
|
635 | 633 | "output_type": "display_data", |
|
636 | 634 | "text": [ |
|
637 |
"<IPython.core.display.Javascript at 0x |
|
|
635 | "<IPython.core.display.Javascript at 0x10a274a10>" | |
|
638 | 636 | ] |
|
639 | 637 | } |
|
640 | 638 | ], |
|
641 |
"prompt_number": |
|
|
639 | "prompt_number": 52 | |
|
642 | 640 | }, |
|
643 | 641 | { |
|
644 | 642 | "cell_type": "heading", |
@@ -665,7 +663,7 b'' | |||
|
665 | 663 | "language": "python", |
|
666 | 664 | "metadata": {}, |
|
667 | 665 | "outputs": [], |
|
668 |
"prompt_number": |
|
|
666 | "prompt_number": 29 | |
|
669 | 667 | }, |
|
670 | 668 | { |
|
671 | 669 | "cell_type": "markdown", |
@@ -683,7 +681,7 b'' | |||
|
683 | 681 | "language": "python", |
|
684 | 682 | "metadata": {}, |
|
685 | 683 | "outputs": [], |
|
686 |
"prompt_number": |
|
|
684 | "prompt_number": 30 | |
|
687 | 685 | }, |
|
688 | 686 | { |
|
689 | 687 | "cell_type": "markdown", |
@@ -704,13 +702,13 b'' | |||
|
704 | 702 | { |
|
705 | 703 | "metadata": {}, |
|
706 | 704 | "output_type": "pyout", |
|
707 |
"prompt_number": |
|
|
705 | "prompt_number": 37, | |
|
708 | 706 | "text": [ |
|
709 |
" |
|
|
707 | "u'1998-12-01'" | |
|
710 | 708 | ] |
|
711 | 709 | } |
|
712 | 710 | ], |
|
713 |
"prompt_number": |
|
|
711 | "prompt_number": 37 | |
|
714 | 712 | }, |
|
715 | 713 | { |
|
716 | 714 | "cell_type": "markdown", |
@@ -723,12 +721,12 b'' | |||
|
723 | 721 | "cell_type": "code", |
|
724 | 722 | "collapsed": false, |
|
725 | 723 | "input": [ |
|
726 |
"my_widget.value = \"199 |
|
|
724 | "my_widget.value = \"1998-12-01\" # December 1st, 1999" | |
|
727 | 725 | ], |
|
728 | 726 | "language": "python", |
|
729 | 727 | "metadata": {}, |
|
730 | 728 | "outputs": [], |
|
731 |
"prompt_number": |
|
|
729 | "prompt_number": 34 | |
|
732 | 730 | }, |
|
733 | 731 | { |
|
734 | 732 | "cell_type": "heading", |
@@ -786,7 +784,7 b'' | |||
|
786 | 784 | "language": "python", |
|
787 | 785 | "metadata": {}, |
|
788 | 786 | "outputs": [], |
|
789 |
"prompt_number": |
|
|
787 | "prompt_number": 38 | |
|
790 | 788 | }, |
|
791 | 789 | { |
|
792 | 790 | "cell_type": "markdown", |
@@ -831,7 +829,7 b'' | |||
|
831 | 829 | "language": "python", |
|
832 | 830 | "metadata": {}, |
|
833 | 831 | "outputs": [], |
|
834 |
"prompt_number": |
|
|
832 | "prompt_number": 39 | |
|
835 | 833 | }, |
|
836 | 834 | { |
|
837 | 835 | "cell_type": "markdown", |
@@ -879,7 +877,7 b'' | |||
|
879 | 877 | "language": "python", |
|
880 | 878 | "metadata": {}, |
|
881 | 879 | "outputs": [], |
|
882 |
"prompt_number": |
|
|
880 | "prompt_number": 40 | |
|
883 | 881 | }, |
|
884 | 882 | { |
|
885 | 883 | "cell_type": "markdown", |
@@ -957,7 +955,7 b'' | |||
|
957 | 955 | "language": "python", |
|
958 | 956 | "metadata": {}, |
|
959 | 957 | "outputs": [], |
|
960 |
"prompt_number": 1 |
|
|
958 | "prompt_number": 41 | |
|
961 | 959 | }, |
|
962 | 960 | { |
|
963 | 961 | "cell_type": "heading", |
@@ -982,7 +980,7 b'' | |||
|
982 | 980 | "input": [ |
|
983 | 981 | "%%javascript\n", |
|
984 | 982 | "\n", |
|
985 | "require([\"notebook/js/widget\"], function(){\n", | |
|
983 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
986 | 984 | " \n", |
|
987 | 985 | " // Define the DateModel and register it with the widget manager.\n", |
|
988 | 986 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -1034,7 +1032,6 b'' | |||
|
1034 | 1032 | " // Callback for when the date is changed.\n", |
|
1035 | 1033 | " handle_date_change: function(event) {\n", |
|
1036 | 1034 | " this.model.set('value', this.$date.val());\n", |
|
1037 | " this.model.update_other_views(this);\n", | |
|
1038 | 1035 | " },\n", |
|
1039 | 1036 | " \n", |
|
1040 | 1037 | " });\n", |
@@ -1049,7 +1046,7 b'' | |||
|
1049 | 1046 | { |
|
1050 | 1047 | "javascript": [ |
|
1051 | 1048 | "\n", |
|
1052 | "require([\"notebook/js/widget\"], function(){\n", | |
|
1049 | "require([\"notebook/js/widgets/base\"], function(){\n", | |
|
1053 | 1050 | " \n", |
|
1054 | 1051 | " // Define the DateModel and register it with the widget manager.\n", |
|
1055 | 1052 | " var DateModel = IPython.WidgetModel.extend({});\n", |
@@ -1101,7 +1098,6 b'' | |||
|
1101 | 1098 | " // Callback for when the date is changed.\n", |
|
1102 | 1099 | " handle_date_change: function(event) {\n", |
|
1103 | 1100 | " this.model.set('value', this.$date.val());\n", |
|
1104 | " this.model.update_other_views(this);\n", | |
|
1105 | 1101 | " },\n", |
|
1106 | 1102 | " \n", |
|
1107 | 1103 | " });\n", |
@@ -1113,11 +1109,11 b'' | |||
|
1113 | 1109 | "metadata": {}, |
|
1114 | 1110 | "output_type": "display_data", |
|
1115 | 1111 | "text": [ |
|
1116 |
"<IPython.core.display.Javascript at 0x |
|
|
1112 | "<IPython.core.display.Javascript at 0x10a274a10>" | |
|
1117 | 1113 | ] |
|
1118 | 1114 | } |
|
1119 | 1115 | ], |
|
1120 |
"prompt_number": |
|
|
1116 | "prompt_number": 53 | |
|
1121 | 1117 | }, |
|
1122 | 1118 | { |
|
1123 | 1119 | "cell_type": "heading", |
@@ -1148,7 +1144,7 b'' | |||
|
1148 | 1144 | "language": "python", |
|
1149 | 1145 | "metadata": {}, |
|
1150 | 1146 | "outputs": [], |
|
1151 |
"prompt_number": |
|
|
1147 | "prompt_number": 43 | |
|
1152 | 1148 | }, |
|
1153 | 1149 | { |
|
1154 | 1150 | "cell_type": "markdown", |
@@ -1166,7 +1162,7 b'' | |||
|
1166 | 1162 | "language": "python", |
|
1167 | 1163 | "metadata": {}, |
|
1168 | 1164 | "outputs": [], |
|
1169 |
"prompt_number": |
|
|
1165 | "prompt_number": 44 | |
|
1170 | 1166 | }, |
|
1171 | 1167 | { |
|
1172 | 1168 | "cell_type": "markdown", |
@@ -1189,7 +1185,7 b'' | |||
|
1189 | 1185 | "language": "python", |
|
1190 | 1186 | "metadata": {}, |
|
1191 | 1187 | "outputs": [], |
|
1192 |
"prompt_number": |
|
|
1188 | "prompt_number": 57 | |
|
1193 | 1189 | }, |
|
1194 | 1190 | { |
|
1195 | 1191 | "cell_type": "code", |
@@ -1201,7 +1197,7 b'' | |||
|
1201 | 1197 | "language": "python", |
|
1202 | 1198 | "metadata": {}, |
|
1203 | 1199 | "outputs": [], |
|
1204 |
"prompt_number": |
|
|
1200 | "prompt_number": 46 | |
|
1205 | 1201 | }, |
|
1206 | 1202 | { |
|
1207 | 1203 | "cell_type": "code", |
@@ -1213,7 +1209,35 b'' | |||
|
1213 | 1209 | "language": "python", |
|
1214 | 1210 | "metadata": {}, |
|
1215 | 1211 | "outputs": [], |
|
1216 |
"prompt_number": |
|
|
1212 | "prompt_number": 48 | |
|
1213 | }, | |
|
1214 | { | |
|
1215 | "cell_type": "code", | |
|
1216 | "collapsed": false, | |
|
1217 | "input": [ | |
|
1218 | "my_widget.value" | |
|
1219 | ], | |
|
1220 | "language": "python", | |
|
1221 | "metadata": {}, | |
|
1222 | "outputs": [ | |
|
1223 | { | |
|
1224 | "metadata": {}, | |
|
1225 | "output_type": "pyout", | |
|
1226 | "prompt_number": 58, | |
|
1227 | "text": [ | |
|
1228 | "u''" | |
|
1229 | ] | |
|
1230 | } | |
|
1231 | ], | |
|
1232 | "prompt_number": 58 | |
|
1233 | }, | |
|
1234 | { | |
|
1235 | "cell_type": "code", | |
|
1236 | "collapsed": false, | |
|
1237 | "input": [], | |
|
1238 | "language": "python", | |
|
1239 | "metadata": {}, | |
|
1240 | "outputs": [] | |
|
1217 | 1241 | } |
|
1218 | 1242 | ], |
|
1219 | 1243 | "metadata": {} |
General Comments 0
You need to be logged in to leave comments.
Login now