From dad379de55bae54208a2286c7ccab56173ffa855 Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Fri, 25 May 2018 17:17:06 -0700 Subject: [PATCH] Stop supporting ipywidgets 4 --- opmd_viewer/openpmd_timeseries/interactive.py | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/opmd_viewer/openpmd_timeseries/interactive.py b/opmd_viewer/openpmd_timeseries/interactive.py index 45644332..5e8e1118 100644 --- a/opmd_viewer/openpmd_timeseries/interactive.py +++ b/opmd_viewer/openpmd_timeseries/interactive.py @@ -55,6 +55,12 @@ def slider(self, figsize=(6, 5), fields_figure=0, particles_figure=1, if not dependencies_installed: raise RuntimeError("Failed to load the openPMD-viewer slider.\n" "(Make sure that ipywidgets and matplotlib are installed.)") + elif ipywidgets_version <= 4: + raise RuntimeError( + 'Your version of ipywidgets is too old.\n' + 'Please install a newer version of ipywidgets.\n' + 'e.g. with: pip install --upgrade ipywidgets\n' + 'or with: conda install -c conda-forge ipywidgets') # ----------------------- # Define useful functions @@ -572,22 +578,12 @@ def to_container( self ): # Gather the different widgets on two lines cmap_container = widgets.HBox( children=[ widgets.HTML( "Colorbar:"), self.cmap ]) - if ipywidgets_version > 4: - # For newer version of ipywidgets: add the "x10^" on same line - range_container = widgets.HBox( children=[ self.active, - add_description("from", self.low_bound, width=30 ), - add_description("to", self.up_bound, width=20 ), - add_description("x 10^", self.exponent, width=45 ) ] ) - final_container = widgets.VBox( - children=[ cmap_container, range_container ]) - else: - # For older version of ipywidgets: add the "x10^" on new line - range_container = widgets.HBox( children=[ self.active, - add_description("from", self.low_bound, width=30 ), - add_description("to", self.up_bound, width=20 ) ] ) - final_container = widgets.VBox( - children=[ cmap_container, range_container, - add_description("x 10^", self.exponent, width=45 ) ]) + range_container = widgets.HBox( children=[ self.active, + add_description("from", self.low_bound, width=30 ), + add_description("to", self.up_bound, width=20 ), + add_description("x 10^", self.exponent, width=45 ) ] ) + final_container = widgets.VBox( + children=[ cmap_container, range_container ]) set_widget_dimensions( final_container, width=310 ) return( final_container )