mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
Merge pull request #5493 from jdavidheiser/master
made a minor fix to one of the widget examples
This commit is contained in:
commit
46602a00a0
@ -59,6 +59,10 @@ class _SelectionWidget(DOMWidget):
|
||||
if isinstance(values, list):
|
||||
# preserve list order with an OrderedDict
|
||||
kwargs['values'] = OrderedDict((unicode_type(v), v) for v in values)
|
||||
# python3.3 turned on hash randomization by default - this means that sometimes, randomly
|
||||
# we try to set value before setting values, due to dictionary ordering. To fix this, force
|
||||
# the setting of self.values right now, before anything else runs
|
||||
self.values = kwargs.pop('values')
|
||||
DOMWidget.__init__(self, *args, **kwargs)
|
||||
|
||||
def _values_changed(self, name, old, new):
|
||||
|
@ -19,7 +19,8 @@
|
||||
"# nbconvert related imports\n",
|
||||
"from IPython.nbconvert import get_export_names, export_by_name\n",
|
||||
"from IPython.nbconvert.writers import FilesWriter\n",
|
||||
"from IPython.nbformat import current"
|
||||
"from IPython.nbformat import current\n",
|
||||
"from IPython.nbconvert.utils.exceptions import ConversionException"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
@ -151,7 +152,7 @@
|
||||
" download_link.value = \"<br>Results: <a href='files/{filename}'><i>\\\"{filename}\\\"</i></a>\".format(filename=write_results)\n",
|
||||
" download_link.visible = True\n",
|
||||
" \n",
|
||||
"def handle_export():\n",
|
||||
"def handle_export(widget):\n",
|
||||
" with open(filename, 'r') as f:\n",
|
||||
" export(filename, current.read(f, 'json'))\n",
|
||||
"export_button.on_click(handle_export)"
|
||||
@ -183,4 +184,4 @@
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user