From cdae251186d8d710041223c8b55f0a87e6546167 Mon Sep 17 00:00:00 2001 From: jdavidheiser Date: Wed, 2 Apr 2014 09:56:36 -0700 Subject: [PATCH 1/5] fix minor bugs in export as (nbconvert) example --- examples/Interactive Widgets/Export As (nbconvert).ipynb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/Interactive Widgets/Export As (nbconvert).ipynb b/examples/Interactive Widgets/Export As (nbconvert).ipynb index 714b48aaa..36d50f213 100644 --- a/examples/Interactive Widgets/Export As (nbconvert).ipynb +++ b/examples/Interactive Widgets/Export As (nbconvert).ipynb @@ -20,6 +20,8 @@ "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.nbconvert.utils.exceptions import ConversionException\n", + ], "language": "python", "metadata": {}, @@ -151,7 +153,7 @@ " download_link.value = \"
Results: \\\"{filename}\\\"\".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 +185,4 @@ "metadata": {} } ] -} \ No newline at end of file +} From 96d350068732bd9fa4d956898094c993a33daa8e Mon Sep 17 00:00:00 2001 From: jdavidheiser Date: Wed, 2 Apr 2014 10:03:08 -0700 Subject: [PATCH 2/5] Update Export As (nbconvert).ipynb --- examples/Interactive Widgets/Export As (nbconvert).ipynb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/Interactive Widgets/Export As (nbconvert).ipynb b/examples/Interactive Widgets/Export As (nbconvert).ipynb index 36d50f213..9c6e758f6 100644 --- a/examples/Interactive Widgets/Export As (nbconvert).ipynb +++ b/examples/Interactive Widgets/Export As (nbconvert).ipynb @@ -19,9 +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.nbconvert.utils.exceptions import ConversionException\n", - + "from IPython.nbformat import current\n", + "from IPython.nbconvert.utils.exceptions import ConversionException" ], "language": "python", "metadata": {}, From 981003398856b15692f2adc2afb63a52e23a6e2a Mon Sep 17 00:00:00 2001 From: jdavidheiser Date: Thu, 3 Apr 2014 16:26:43 -0700 Subject: [PATCH 3/5] widget_selection update Fix for the fact that dictionary randomization sometimes switches the order of the arguments passed to the class on initialization. This means that, potentially, 'value' can be updated BEFORE 'values', and since the method to update 'value' checks to see whether it exists in 'values', this breaks things. --- IPython/html/widgets/widget_selection.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/IPython/html/widgets/widget_selection.py b/IPython/html/widgets/widget_selection.py index aa3f194fe..7807fe66c 100644 --- a/IPython/html/widgets/widget_selection.py +++ b/IPython/html/widgets/widget_selection.py @@ -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['values'] DOMWidget.__init__(self, *args, **kwargs) def _values_changed(self, name, old, new): From 52e58dce6d0c57b203db1ebac70e5f52cdd0d54f Mon Sep 17 00:00:00 2001 From: jdavidheiser Date: Thu, 3 Apr 2014 18:31:30 -0700 Subject: [PATCH 4/5] Update widget_selection.py --- IPython/html/widgets/widget_selection.py | 1 + 1 file changed, 1 insertion(+) diff --git a/IPython/html/widgets/widget_selection.py b/IPython/html/widgets/widget_selection.py index 7807fe66c..ac4207e56 100644 --- a/IPython/html/widgets/widget_selection.py +++ b/IPython/html/widgets/widget_selection.py @@ -63,6 +63,7 @@ class _SelectionWidget(DOMWidget): # 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['values'] + kwargs.pop('values') DOMWidget.__init__(self, *args, **kwargs) def _values_changed(self, name, old, new): From e0a40d54cb4d6356af2c136e4f57a8d544d27d8d Mon Sep 17 00:00:00 2001 From: jdavidheiser Date: Thu, 3 Apr 2014 18:45:25 -0700 Subject: [PATCH 5/5] Update widget_selection.py --- IPython/html/widgets/widget_selection.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/IPython/html/widgets/widget_selection.py b/IPython/html/widgets/widget_selection.py index ac4207e56..e9706d11f 100644 --- a/IPython/html/widgets/widget_selection.py +++ b/IPython/html/widgets/widget_selection.py @@ -62,8 +62,7 @@ class _SelectionWidget(DOMWidget): # 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['values'] - kwargs.pop('values') + self.values = kwargs.pop('values') DOMWidget.__init__(self, *args, **kwargs) def _values_changed(self, name, old, new):