|
367 | 367 | "source": [
|
368 | 368 | "from collections import OrderedDict\n",
|
369 | 369 | "from IPython.display import display, clear_output\n",
|
370 |
| - "from IPython.html.widgets import DropdownWidget" |
| 370 | + "from ipywidgets import Dropdown\n", |
| 371 | + "#from IPython.html.widgets import DropdownWidget # IPython < 4.x" |
371 | 372 | ]
|
372 | 373 | },
|
373 | 374 | {
|
|
378 | 379 | },
|
379 | 380 | "outputs": [],
|
380 | 381 | "source": [
|
381 |
| - "# We create a DropdownWidget, with a dictionary containing\n", |
| 382 | + "# We create a Dropdown widget, with a dictionary containing\n", |
382 | 383 | "# the keys (video name) and the values (Youtube identifier) \n",
|
383 | 384 | "# of every menu item.\n",
|
384 |
| - "dw = DropdownWidget(values=OrderedDict([\n", |
| 385 | + "dw = Dropdown(options=OrderedDict([\n", |
| 386 | + "# dw = DropdownWidget(values=OrderedDict([ # IPython < 4.x\n", |
385 | 387 | " ('SciPy 2012', 'iwVvqwLDsJo'), \n",
|
386 | 388 | " ('PyCon 2012', '2G5YTlheCbw'),\n",
|
387 | 389 | " ('SciPy 2013', 'j9YpkSX7NNM')]))\n",
|
|
395 | 397 | "# contains the value of the selected item.\n",
|
396 | 398 | "dw.on_trait_change(on_value_change, 'value')\n",
|
397 | 399 | "# We choose a default value.\n",
|
398 |
| - "dw.value = dw.values['SciPy 2013']\n", |
| 400 | + "dw.value = dw.options['SciPy 2013']\n", |
| 401 | + "# dw.value = dw.values['SciPy 2013'] # IPyhon < 4.x\n", |
399 | 402 | "# Finally, we display the widget.\n",
|
400 | 403 | "display(dw)"
|
401 | 404 | ]
|
|
433 | 436 | "name": "python",
|
434 | 437 | "nbconvert_exporter": "python",
|
435 | 438 | "pygments_lexer": "ipython3",
|
436 |
| - "version": "3.4.2" |
| 439 | + "version": "3.5.0" |
437 | 440 | }
|
438 | 441 | },
|
439 | 442 | "nbformat": 4,
|
|
0 commit comments