From ad30c2b9d589f2e60946465ba8cc6c6ac17096f9 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 4 Mar 2015 12:14:34 +0000 Subject: [PATCH 1/8] Remove *Widget from widgets, remove popup All widgets no longer have the suffix *Widget and the popup widget has been removed. Fix this in our widgets. --- menpo/feature/features.py | 9 +- menpo/image/base.py | 7 +- menpo/landmark/base.py | 13 +- menpo/shape/graph.py | 7 +- menpo/shape/mesh/base.py | 7 +- menpo/shape/pointcloud.py | 7 +- menpo/visualize/viewmatplotlib.py | 9 +- menpo/visualize/widgets/base.py | 111 +++------ menpo/visualize/widgets/options.py | 156 ++++++------ menpo/visualize/widgets/tools.py | 388 ++++++++++++++--------------- 10 files changed, 320 insertions(+), 394 deletions(-) diff --git a/menpo/feature/features.py b/menpo/feature/features.py index 14200632a..bde19b932 100644 --- a/menpo/feature/features.py +++ b/menpo/feature/features.py @@ -787,17 +787,12 @@ def no_op(pixels): return pixels.copy() -def features_selection_widget(popup=True): +def features_selection_widget(): r""" Widget that allows for easy selection of a features function and its options. It also has a 'preview' tab for visual inspection. It returns a `list` of length 1 with the selected features function closure. - Parameters - ---------- - popup : `bool`, optional - If ``True``, the widget will appear as a popup window. - Returns ------- features_function : `list` of length ``1`` @@ -821,4 +816,4 @@ def features_selection_widget(popup=True): """ from menpo.visualize.widgets import features_selection - return features_selection(popup=popup) + return features_selection() diff --git a/menpo/image/base.py b/menpo/image/base.py index 973dc4dee..6a7c366d5 100644 --- a/menpo/image/base.py +++ b/menpo/image/base.py @@ -572,16 +572,13 @@ def _view_2d(self, figure_id=None, new_figure=False, channels=None, axes_font_weight=axes_font_weight, axes_x_limits=axes_x_limits, axes_y_limits=axes_y_limits, figure_size=figure_size) - def view_widget(self, popup=False, browser_style='buttons', - figure_size=(10, 8)): + def view_widget(self, browser_style='buttons', figure_size=(10, 8)): r""" Visualizes the image object using the :map:`visualize_images` widget. Currently only supports the rendering of 2D images. Parameters ---------- - popup : `bool`, optional - If ``True``, the widget will appear as a popup window. browser_style : ``{buttons, slider}``, optional It defines whether the selector of the images will have the form of plus/minus buttons or a slider. @@ -589,7 +586,7 @@ def view_widget(self, popup=False, browser_style='buttons', The initial size of the rendered figure. """ from menpo.visualize import visualize_images - visualize_images(self, figure_size=figure_size, popup=popup, + visualize_images(self, figure_size=figure_size, browser_style=browser_style) def _view_landmarks_2d(self, channels=None, group=None, diff --git a/menpo/landmark/base.py b/menpo/landmark/base.py index 95dfb876f..aa0683b51 100644 --- a/menpo/landmark/base.py +++ b/menpo/landmark/base.py @@ -288,7 +288,7 @@ def _transform_inplace(self, transform): group.lms._transform_inplace(transform) return self - def view_widget(self, popup=False, browser_style='buttons', + def view_widget(self, browser_style='buttons', figure_size=(10, 8)): r""" Visualizes the landmark manager object using the @@ -296,8 +296,6 @@ def view_widget(self, popup=False, browser_style='buttons', Parameters ---------- - popup : `bool`, optional - If ``True``, the widget will appear as a popup window. browser_style : {``buttons``, ``slider``}, optional It defines whether the selector of the landmark managers will have the form of plus/minus buttons or a slider. @@ -305,7 +303,7 @@ def view_widget(self, popup=False, browser_style='buttons', The initial size of the rendered figure. """ from menpo.visualize import visualize_landmarks - visualize_landmarks(self, figure_size=figure_size, popup=popup, + visualize_landmarks(self, figure_size=figure_size, browser_style=browser_style) def __str__(self): @@ -887,16 +885,13 @@ def _view_3d(self, figure_id=None, new_figure=False, **kwargs): from menpo.visualize import Menpo3dErrorMessage raise ImportError(Menpo3dErrorMessage) - def view_widget(self, popup=False, browser_style='buttons', - figure_size=(10, 8)): + def view_widget(self, browser_style='buttons', figure_size=(10, 8)): r""" Visualizes the landmark group object using the :map:`visualize_landmarkgroups` widget. Parameters ---------- - popup : `bool`, optional - If ``True``, the widget will appear as a popup window. browser_style : {``buttons``, ``slider``}, optional It defines whether the selector of the landmark managers will have the form of plus/minus buttons or a slider. @@ -904,7 +899,7 @@ def view_widget(self, popup=False, browser_style='buttons', The initial size of the rendered figure. """ from menpo.visualize import visualize_landmarkgroups - visualize_landmarkgroups(self, figure_size=figure_size, popup=popup, + visualize_landmarkgroups(self, figure_size=figure_size, browser_style=browser_style) def __str__(self): diff --git a/menpo/shape/graph.py b/menpo/shape/graph.py index b87e4e3af..065819347 100644 --- a/menpo/shape/graph.py +++ b/menpo/shape/graph.py @@ -1080,16 +1080,13 @@ def _view_3d(self, figure_id=None, new_figure=False): from menpo.visualize import Menpo3dErrorMessage raise ImportError(Menpo3dErrorMessage) - def view_widget(self, popup=False, browser_style='buttons', - figure_size=(10, 8)): + def view_widget(self, browser_style='buttons', figure_size=(10, 8)): r""" Visualization of the PointGraph using the :map:`visualize_pointclouds` widget. Parameters ---------- - popup : `bool`, optional - If ``True``, the widget will be rendered in a popup window. browser_style : ``{buttons, slider}``, optional It defines whether the selector of the PointGraph objects will have the form of plus/minus buttons or a slider. @@ -1097,7 +1094,7 @@ def view_widget(self, popup=False, browser_style='buttons', The initial size of the rendered figure. """ from menpo.visualize import visualize_pointclouds - visualize_pointclouds(self, popup=popup, figure_size=figure_size, + visualize_pointclouds(self, figure_size=figure_size, browser_style=browser_style) diff --git a/menpo/shape/mesh/base.py b/menpo/shape/mesh/base.py index 494a9139c..5335d8d5f 100644 --- a/menpo/shape/mesh/base.py +++ b/menpo/shape/mesh/base.py @@ -325,16 +325,13 @@ def _view_3d(self, figure_id=None, new_figure=False, **kwargs): from menpo.visualize import Menpo3dErrorMessage raise ImportError(Menpo3dErrorMessage) - def view_widget(self, popup=False, browser_style='buttons', - figure_size=(10, 8)): + def view_widget(self, browser_style='buttons', figure_size=(10, 8)): r""" Visualization of the TriMesh using the :map:`visualize_pointclouds` widget. Parameters ---------- - popup : `bool`, optional - If ``True``, the widget will be rendered in a popup window. browser_style : ``{buttons, slider}``, optional It defines whether the selector of the TriMesh objects will have the form of plus/minus buttons or a slider. @@ -342,5 +339,5 @@ def view_widget(self, popup=False, browser_style='buttons', The initial size of the rendered figure. """ from menpo.visualize import visualize_pointclouds - visualize_pointclouds(self, popup=popup, figure_size=figure_size, + visualize_pointclouds(self, figure_size=figure_size, browser_style=browser_style) diff --git a/menpo/shape/pointcloud.py b/menpo/shape/pointcloud.py index 9e52e8ab3..1a3150d32 100644 --- a/menpo/shape/pointcloud.py +++ b/menpo/shape/pointcloud.py @@ -622,16 +622,13 @@ def _view_landmarks_3d(self, figure_id=None, new_figure=False, from menpo.visualize import Menpo3dErrorMessage raise ImportError(Menpo3dErrorMessage) - def view_widget(self, popup=False, browser_style='buttons', - figure_size=(10, 8)): + def view_widget(self, browser_style='buttons', figure_size=(10, 8)): r""" Visualization of the PointCloud using the :map:`visualize_pointclouds` widget. Parameters ---------- - popup : `bool`, optional - If ``True``, the widget will be rendered in a popup window. browser_style : ``{buttons, slider}``, optional It defines whether the selector of the PointCloud objects will have the form of plus/minus buttons or a slider. @@ -639,7 +636,7 @@ def view_widget(self, popup=False, browser_style='buttons', The initial size of the rendered figure. """ from menpo.visualize import visualize_pointclouds - visualize_pointclouds(self, popup=popup, figure_size=figure_size, + visualize_pointclouds(self, figure_size=figure_size, browser_style=browser_style) def _transform_self_inplace(self, transform): diff --git a/menpo/visualize/viewmatplotlib.py b/menpo/visualize/viewmatplotlib.py index c8037d39a..aad19c7ae 100644 --- a/menpo/visualize/viewmatplotlib.py +++ b/menpo/visualize/viewmatplotlib.py @@ -119,18 +119,13 @@ def save_figure(self, filename, format='png', dpi=None, face_colour='w', _export(save_fig_args, filename, self._extensions_map, format, overwrite=overwrite) - def save_figure_widget(self, popup=True): + def save_figure_widget(self): r""" Method for saving the figure of the current ``figure_id`` to file using :func:`menpo.visualize.widgets.base.save_matplotlib_figure` widget. - - Parameters - ---------- - popup : `bool`, optional - If ``True``, the widget will appear as a popup window. """ from menpo.visualize.widgets import save_matplotlib_figure - save_matplotlib_figure(self, popup=popup) + save_matplotlib_figure(self) class MatplotlibSubplots(object): diff --git a/menpo/visualize/widgets/base.py b/menpo/visualize/widgets/base.py index 0e2187f52..a9ec94e38 100644 --- a/menpo/visualize/widgets/base.py +++ b/menpo/visualize/widgets/base.py @@ -19,7 +19,7 @@ glyph = None -def visualize_pointclouds(pointclouds, figure_size=(10, 8), popup=False, +def visualize_pointclouds(pointclouds, figure_size=(10, 8), browser_style='buttons'): r""" Widget that allows browsing through a `list` of :map:`PointCloud`, @@ -34,8 +34,6 @@ def visualize_pointclouds(pointclouds, figure_size=(10, 8), popup=False, The `list` of objects to be visualized. figure_size : (`int`, `int`), optional The initial size of the rendered figure. - popup : `bool`, optional - If ``True``, the widget will appear as a popup window. browser_style : {``buttons``, ``slider``}, optional It defines whether the selector of the objects will have the form of plus/minus buttons or a slider. @@ -146,7 +144,7 @@ def update_info(pointcloud): format(cm[0], cm[1]) # viewer options widget - axes_mode_wid = ipywidgets.RadioButtonsWidget( + axes_mode_wid = ipywidgets.RadioButtons( values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', value=2) axes_mode_wid.on_trait_change(plot_function, 'value') @@ -156,7 +154,7 @@ def update_info(pointcloud): plot_function=plot_function, toggle_show_visible=False, toggle_show_default=True) - viewer_options_all = ipywidgets.ContainerWidget(children=[axes_mode_wid, + viewer_options_all = ipywidgets.Box(children=[axes_mode_wid, viewer_options_wid]) info_wid = info_print(n_bullets=4, toggle_show_default=True, toggle_show_visible=False) @@ -180,21 +178,17 @@ def update_info(pointcloud): toggle_show_visible=False) # final widget - logo_wid = ipywidgets.ContainerWidget(children=[logo(), + logo_wid = ipywidgets.Box(children=[logo(), pointcloud_number_wid]) button_title = 'Pointclouds Menu' else: # final widget logo_wid = logo() button_title = 'Pointcloud Menu' - # create popup widget if asked - cont_wid = ipywidgets.TabWidget(children=[info_wid, viewer_options_all, + + cont_wid = ipywidgets.Tab(children=[info_wid, viewer_options_all, save_figure_wid]) - if popup: - wid = ipywidgets.PopupWidget(children=[logo_wid, cont_wid], - button_text=button_title) - else: - wid = ipywidgets.ContainerWidget(children=[logo_wid, cont_wid]) + wid = ipywidgets.Box(children=[logo_wid, cont_wid]) # display final widget ipydisplay.display(wid) @@ -239,7 +233,7 @@ def update_info(pointcloud): axes_mode_wid.value = 1 -def visualize_landmarkgroups(landmarkgroups, figure_size=(10, 8), popup=False, +def visualize_landmarkgroups(landmarkgroups, figure_size=(10, 8), browser_style='buttons'): r""" Widget that allows browsing through a `list` of :map:`LandmarkGroup` @@ -256,8 +250,6 @@ def visualize_landmarkgroups(landmarkgroups, figure_size=(10, 8), popup=False, The `list` of landmark groups to be visualized. figure_size : (`int`, `int`), optional The initial size of the rendered figure. - popup : `bool`, optional - If ``True``, the widget will appear as a popup window. browser_style : {``buttons``, ``slider``}, optional It defines whether the selector of the landmark managers will have the form of plus/minus buttons or a slider. @@ -464,7 +456,7 @@ def update_info(landmarkgroup): toggle_show_visible=False) # viewer options widget - axes_mode_wid = ipywidgets.RadioButtonsWidget( + axes_mode_wid = ipywidgets.RadioButtons( values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', value=2) axes_mode_wid.on_trait_change(plot_function, 'value') @@ -479,7 +471,7 @@ def update_info(landmarkgroup): # make the selection dropdown invisible, as ti is controlled by the # landmarks selection viewer_options_wid.children[1].children[0].visible = False - viewer_options_all = ipywidgets.ContainerWidget(children=[axes_mode_wid, + viewer_options_all = ipywidgets.Box(children=[axes_mode_wid, viewer_options_wid]) info_wid = info_print(n_bullets=5, toggle_show_default=True, toggle_show_visible=False) @@ -525,22 +517,18 @@ def update_widgets(name, value): toggle_show_visible=False) # final widget - logo_wid = ipywidgets.ContainerWidget(children=[logo(), + logo_wid = ipywidgets.Box(children=[logo(), landmark_number_wid]) button_title = 'Shapes Menu' else: # final widget logo_wid = logo() button_title = 'Shape Menu' - # create popup widget if asked - cont_wid = ipywidgets.TabWidget(children=[info_wid, landmark_options_wid, + + cont_wid = ipywidgets.Tab(children=[info_wid, landmark_options_wid, viewer_options_all, save_figure_wid]) - if popup: - wid = ipywidgets.PopupWidget(children=[logo_wid, cont_wid], - button_text=button_title) - else: - wid = ipywidgets.ContainerWidget(children=[logo_wid, cont_wid]) + wid = ipywidgets.Box(children=[logo_wid, cont_wid]) # display final widget ipydisplay.display(wid) @@ -593,7 +581,7 @@ def update_widgets(name, value): axes_mode_wid.value = 1 -def visualize_landmarks(landmarks, figure_size=(10, 8), popup=False, +def visualize_landmarks(landmarks, figure_size=(10, 8), browser_style='buttons'): r""" Widget that allows browsing through a `list` of :map:`LandmarkManager` @@ -610,8 +598,6 @@ def visualize_landmarks(landmarks, figure_size=(10, 8), popup=False, The `list` of landmark managers to be visualized. figure_size : (`int`, `int`), optional The initial size of the rendered figure. - popup : `bool`, optional - If ``True``, the widget will appear as a popup window. browser_style : {``buttons``, ``slider``}, optional It defines whether the selector of the landmark managers will have the form of plus/minus buttons or a slider. @@ -838,7 +824,7 @@ def update_info(landmarks, group): landmark_options_wid.children[1].disabled = not first_has_landmarks # viewer options widget - axes_mode_wid = ipywidgets.RadioButtonsWidget( + axes_mode_wid = ipywidgets.RadioButtons( values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', value=2) axes_mode_wid.on_trait_change(plot_function, 'value') @@ -853,7 +839,7 @@ def update_info(landmarks, group): # make the selection dropdown invisible, as ti is controlled by the # landmarks selection viewer_options_wid.children[1].children[0].visible = False - viewer_options_all = ipywidgets.ContainerWidget(children=[axes_mode_wid, + viewer_options_all = ipywidgets.Box(children=[axes_mode_wid, viewer_options_wid]) info_wid = info_print(n_bullets=5, toggle_show_default=True, toggle_show_visible=False) @@ -897,22 +883,18 @@ def update_widgets(name, value): toggle_show_visible=False) # final widget - logo_wid = ipywidgets.ContainerWidget(children=[logo(), + logo_wid = ipywidgets.Box(children=[logo(), landmark_number_wid]) button_title = 'Shapes Menu' else: # final widget logo_wid = logo() button_title = 'Shape Menu' - # create popup widget if asked - cont_wid = ipywidgets.TabWidget(children=[info_wid, landmark_options_wid, + + cont_wid = ipywidgets.Tab(children=[info_wid, landmark_options_wid, viewer_options_all, save_figure_wid]) - if popup: - wid = ipywidgets.PopupWidget(children=[logo_wid, cont_wid], - button_text=button_title) - else: - wid = ipywidgets.ContainerWidget(children=[logo_wid, cont_wid]) + wid = ipywidgets.Box(children=[logo_wid, cont_wid]) # display final widget ipydisplay.display(wid) @@ -973,7 +955,7 @@ def update_viewer_options(name, value): axes_mode_wid.value = 1 -def visualize_images(images, figure_size=(10, 8), popup=False, +def visualize_images(images, figure_size=(10, 8), browser_style='buttons'): r""" Widget that allows browsing through a `list` of :map:`Image` (or subclass) @@ -991,8 +973,6 @@ def visualize_images(images, figure_size=(10, 8), popup=False, The `list` of images to be visualized. figure_size : (`int`, `int`), optional The initial size of the rendered figure. - popup : `bool`, optional - If ``True``, the widget will appear as a popup window. browser_style : {``buttons``, ``slider``}, optional It defines whether the selector of the images will have the form of plus/minus buttons or a slider. @@ -1300,23 +1280,18 @@ def update_widgets(name, value): toggle_show_visible=False) # final widget - logo_wid = ipywidgets.ContainerWidget(children=[logo(), - image_number_wid]) + logo_wid = ipywidgets.Box(children=[logo(), image_number_wid]) button_title = 'Images Menu' else: # final widget logo_wid = logo() button_title = 'Image Menu' - # create popup widget if asked - cont_wid = ipywidgets.TabWidget(children=[info_wid, channel_options_wid, + + cont_wid = ipywidgets.Tab(children=[info_wid, channel_options_wid, landmark_options_wid, viewer_options_wid, save_figure_wid]) - if popup: - wid = ipywidgets.PopupWidget(children=[logo_wid, cont_wid], - button_text=button_title) - else: - wid = ipywidgets.ContainerWidget(children=[logo_wid, cont_wid]) + wid = ipywidgets.Box(children=[logo_wid, cont_wid]) # display final widget ipydisplay.display(wid) @@ -1382,7 +1357,7 @@ def update_viewer_options(name, value): viewer_options_wid.children[1].children[1].children[3].children[1].children[0].value = False -def save_matplotlib_figure(renderer, popup=True): +def save_matplotlib_figure(renderer): r""" Widget that allows to save a figure, which was generated with Matplotlib, to file. @@ -1391,8 +1366,6 @@ def save_matplotlib_figure(renderer, popup=True): ---------- renderer : :map:`MatplotlibRenderer` The Matplotlib renderer object. - popup : `bool`, optional - If ``True``, the widget will appear as a popup window. """ import IPython.display as ipydisplay import IPython.html.widgets as ipywidgets @@ -1401,14 +1374,7 @@ def save_matplotlib_figure(renderer, popup=True): save_figure_wid = save_figure_options(renderer, toggle_show_default=True, toggle_show_visible=False) - # Create final widget - if popup: - wid = ipywidgets.PopupWidget(children=[logo_wid, save_figure_wid], - button_text='Save Figure') - # set width of popup widget - wid.set_css({'width': '11cm'}, selector='modal') - else: - wid = ipywidgets.ContainerWidget(children=[logo_wid, save_figure_wid]) + wid = ipywidgets.Box(children=[logo_wid, save_figure_wid]) # Display widget ipydisplay.display(wid) @@ -1422,18 +1388,13 @@ def save_matplotlib_figure(renderer, popup=True): format_logo(logo_wid, border_visible=False) -def features_selection(popup=True): +def features_selection(): r""" Widget that allows selecting a features function and its options. The widget supports all features from :ref:`api-feature-index` and has a preview tab. It returns a `list` of length 1 with the selected features function closure. - Parameters - ---------- - popup : `bool`, optional - If ``True``, the widget will appear as a popup window. - Returns ------- features_function : `list` of length ``1`` @@ -1449,16 +1410,12 @@ def features_selection(popup=True): logo_wid = logo() features_options_wid = features_options(toggle_show_default=True, toggle_show_visible=False) - features_wid = ipywidgets.ContainerWidget(children=[logo_wid, + features_wid = ipywidgets.Box(children=[logo_wid, features_options_wid]) - select_but = ipywidgets.ButtonWidget(description='Select') + select_but = ipywidgets.Button(description='Select') # Create final widget - if popup: - wid = ipywidgets.PopupWidget(children=[features_wid, select_but], - button_text='Features Selection') - else: - wid = ipywidgets.ContainerWidget(children=[features_wid, select_but]) + wid = ipywidgets.Box(children=[features_wid, select_but]) # function for select button def select_function(name): @@ -1473,10 +1430,6 @@ def select_function(name): # Format widgets format_features_options(features_options_wid, border_visible=True) format_logo(logo_wid, border_visible=False) - # set popup width - if popup: - wid.set_css({ - 'width': '13cm'}, selector='modal') # align logo at the end features_wid.add_class('align-end') # align select button at the centre diff --git a/menpo/visualize/widgets/options.py b/menpo/visualize/widgets/options.py index f7ea61670..bb799f06e 100644 --- a/menpo/visualize/widgets/options.py +++ b/menpo/visualize/widgets/options.py @@ -113,63 +113,63 @@ def channel_options(channels_options_default, plot_function=None, # Create all necessary widgets # If single channel, disable all options apart from masked - but = ipywidgets.ToggleButtonWidget(description='Channels Options', + but = ipywidgets.ToggleButton(description='Channels Options', value=toggle_show_default, visible=toggle_show_visible) - mode = ipywidgets.RadioButtonsWidget( + mode = ipywidgets.RadioButtons( values=["Single", "Multiple"], value=mode_default, description='Mode:', visible=toggle_show_default, disabled=channels_options_default['n_channels'] == 1) - masked = ipywidgets.CheckboxWidget( + masked = ipywidgets.Checkbox( value=channels_options_default['masked_enabled'], description='Masked', visible=toggle_show_default and channels_options_default[ 'image_is_masked']) - first_slider_wid = ipywidgets.IntSliderWidget( + first_slider_wid = ipywidgets.IntSlider( min=0, max=channels_options_default['n_channels'] - 1, step=1, value=first_slider_default, description='Channel', visible=toggle_show_default, disabled=channels_options_default['n_channels'] == 1) - second_slider_wid = ipywidgets.IntSliderWidget( + second_slider_wid = ipywidgets.IntSlider( min=1, max=channels_options_default['n_channels'] - 1, step=1, value=second_slider_default, description='To', visible=mode_default == "Multiple") - rgb_wid = ipywidgets.CheckboxWidget( + rgb_wid = ipywidgets.Checkbox( value=channels_options_default['n_channels'] == 3 and channels_options_default['channels'] is None, description='RGB', visible=toggle_show_default and channels_options_default[ 'n_channels'] == 3) - sum_wid = ipywidgets.CheckboxWidget( + sum_wid = ipywidgets.Checkbox( value=channels_options_default['sum_enabled'], description='Sum', visible=False, disabled=channels_options_default['n_channels'] == 1) - glyph_wid = ipywidgets.CheckboxWidget( + glyph_wid = ipywidgets.Checkbox( value=channels_options_default['glyph_enabled'], description='Glyph', visible=False, disabled=channels_options_default['n_channels'] == 1) - glyph_block_size = ipywidgets.BoundedIntTextWidget( + glyph_block_size = ipywidgets.BoundedIntText( description='Block size', min=1, max=25, value=channels_options_default['glyph_block_size'], visible=False, disabled=channels_options_default['n_channels'] == 1) - glyph_use_negative = ipywidgets.CheckboxWidget( + glyph_use_negative = ipywidgets.Checkbox( description='Negative values', value=channels_options_default['glyph_use_negative'], visible=False, disabled=channels_options_default['n_channels'] == 1) # Group widgets - glyph_options = ipywidgets.ContainerWidget(children=[glyph_block_size, + glyph_options = ipywidgets.Box(children=[glyph_block_size, glyph_use_negative]) - glyph_all = ipywidgets.ContainerWidget(children=[glyph_wid, glyph_options]) - multiple_checkboxes = ipywidgets.ContainerWidget( + glyph_all = ipywidgets.Box(children=[glyph_wid, glyph_options]) + multiple_checkboxes = ipywidgets.Box( children=[sum_wid, glyph_all, rgb_wid]) - sliders = ipywidgets.ContainerWidget( + sliders = ipywidgets.Box( children=[first_slider_wid, second_slider_wid]) - all_but_radiobuttons = ipywidgets.ContainerWidget( + all_but_radiobuttons = ipywidgets.Box( children=[sliders, multiple_checkboxes]) - mode_and_masked = ipywidgets.ContainerWidget(children=[mode, masked]) - all_but_toggle = ipywidgets.ContainerWidget(children=[mode_and_masked, + mode_and_masked = ipywidgets.Box(children=[mode, masked]) + all_but_toggle = ipywidgets.Box(children=[mode_and_masked, all_but_radiobuttons]) # Widget container - channel_options_wid = ipywidgets.ContainerWidget( + channel_options_wid = ipywidgets.Box( children=[but, all_but_toggle]) # Initialize output variables @@ -577,27 +577,27 @@ def landmark_options(landmark_options_default, plot_function=None, """ import IPython.html.widgets as ipywidgets # Create all necessary widgets - but = ipywidgets.ToggleButtonWidget(description='Landmarks Options', + but = ipywidgets.ToggleButton(description='Landmarks Options', value=toggle_show_default, visible=toggle_show_visible) - landmarks = ipywidgets.CheckboxWidget(description='Render landmarks', + landmarks = ipywidgets.Checkbox(description='Render landmarks', value=landmark_options_default[ 'render_landmarks']) - group = ipywidgets.DropdownWidget( + group = ipywidgets.Dropdown( values=landmark_options_default['group_keys'], description='Group') - labels_toggles = [[ipywidgets.ToggleButtonWidget(description=k, value=True) + labels_toggles = [[ipywidgets.ToggleButton(description=k, value=True) for k in s_keys] for s_keys in landmark_options_default['labels_keys']] - labels_text = ipywidgets.LatexWidget(value='Labels') - labels = ipywidgets.ContainerWidget(children=labels_toggles[0]) + labels_text = ipywidgets.Latex(value='Labels') + labels = ipywidgets.Box(children=labels_toggles[0]) # Group widgets - labels_and_text = ipywidgets.ContainerWidget(children=[labels_text, labels]) - group_wid = ipywidgets.ContainerWidget(children=[group, labels_and_text]) + labels_and_text = ipywidgets.Box(children=[labels_text, labels]) + group_wid = ipywidgets.Box(children=[group, labels_and_text]) # Widget container - landmark_options_wid = ipywidgets.ContainerWidget( + landmark_options_wid = ipywidgets.Box( children=[but, landmarks, group_wid]) # Initialize output variables @@ -788,17 +788,17 @@ def update_landmark_options(landmark_options_wid, group_keys, labels_keys, landmark_options_wid.selected_values['group_keys'], landmark_options_wid.selected_values['labels_keys']): # Create all necessary widgets - group = ipywidgets.DropdownWidget(values=group_keys, + group = ipywidgets.Dropdown(values=group_keys, description='Group') labels_toggles = [ - [ipywidgets.ToggleButtonWidget(description=k, value=True) + [ipywidgets.ToggleButton(description=k, value=True) for k in s_keys] for s_keys in labels_keys] # Group widgets landmark_options_wid.children[2].children[1].children[1]. \ children = labels_toggles[0] labels = landmark_options_wid.children[2].children[1] - cont = ipywidgets.ContainerWidget(children=[group, labels]) + cont = ipywidgets.Box(children=[group, labels]) landmark_options_wid.children = [landmark_options_wid.children[0], landmark_options_wid.children[1], cont] @@ -931,14 +931,14 @@ def info_print(n_bullets, toggle_show_default=True, toggle_show_visible=True): """ import IPython.html.widgets as ipywidgets # Create toggle button - but = ipywidgets.ToggleButtonWidget(description='Info', + but = ipywidgets.ToggleButton(description='Info', value=toggle_show_default, visible=toggle_show_visible) # Create text widget - children = [ipywidgets.LatexWidget(value="> menpo") + children = [ipywidgets.Latex(value="> menpo") for _ in range(n_bullets)] - text_wid = ipywidgets.ContainerWidget(children=children) + text_wid = ipywidgets.Box(children=children) # Toggle button function def show_options(name, value): @@ -948,7 +948,7 @@ def show_options(name, value): but.on_trait_change(show_options, 'value') # Group widgets - info_wid = ipywidgets.ContainerWidget(children=[but, text_wid]) + info_wid = ipywidgets.Box(children=[but, text_wid]) return info_wid @@ -1119,26 +1119,26 @@ def animation_options(index_selection_default, plot_function=None, text_editable=index_text_editable) # Create other widgets - but = ipywidgets.ToggleButtonWidget(description=toggle_show_title, + but = ipywidgets.ToggleButton(description=toggle_show_title, value=toggle_show_default, visible=toggle_show_visible) - play_but = ipywidgets.ToggleButtonWidget(description='Play >', value=False) - stop_but = ipywidgets.ToggleButtonWidget(description='Stop', value=True, + play_but = ipywidgets.ToggleButton(description='Play >', value=False) + stop_but = ipywidgets.ToggleButton(description='Stop', value=True, disabled=True) - play_options = ipywidgets.ToggleButtonWidget(description='Options', + play_options = ipywidgets.ToggleButton(description='Options', value=False) - loop = ipywidgets.CheckboxWidget(description='Loop', value=loop_default, + loop = ipywidgets.Checkbox(description='Loop', value=loop_default, visible=False) - interval = ipywidgets.FloatTextWidget(description='Interval (sec)', + interval = ipywidgets.FloatText(description='Interval (sec)', value=interval_default, visible=False) # Widget container - tmp_options = ipywidgets.ContainerWidget(children=[interval, loop]) - buttons = ipywidgets.ContainerWidget( + tmp_options = ipywidgets.Box(children=[interval, loop]) + buttons = ipywidgets.Box( children=[play_but, stop_but, play_options]) - animation = ipywidgets.ContainerWidget(children=[buttons, tmp_options]) - cont = ipywidgets.ContainerWidget(children=[index_wid, animation]) - animation_options_wid = ipywidgets.ContainerWidget(children=[but, cont]) + animation = ipywidgets.Box(children=[buttons, tmp_options]) + cont = ipywidgets.Box(children=[index_wid, animation]) + animation_options_wid = ipywidgets.Box(children=[but, cont]) # Initialize variables animation_options_wid.selected_values = index_selection_default @@ -1476,7 +1476,7 @@ def viewer_options(viewer_options_default, options_tabs, objects_names=None, # Create widgets # toggle button - but = ipywidgets.ToggleButtonWidget(description='Viewer Options', + but = ipywidgets.ToggleButton(description='Viewer Options', value=toggle_show_default, visible=toggle_show_visible) @@ -1488,7 +1488,7 @@ def viewer_options(viewer_options_default, options_tabs, objects_names=None, else: for k, g in enumerate(objects_names): objects_dict[g] = k - selection = ipywidgets.DropdownWidget(values=objects_dict, value=0, + selection = ipywidgets.Dropdown(values=objects_dict, value=0, description='Select', visible=(selection_visible and toggle_show_default)) @@ -1565,11 +1565,11 @@ def viewer_options(viewer_options_default, options_tabs, objects_names=None, plot_function=plot_function, show_checkbox_title='Render grid')) tab_titles.append('Grid') - options = ipywidgets.TabWidget(children=options_widgets) + options = ipywidgets.Tab(children=options_widgets) # Final widget - all_options = ipywidgets.ContainerWidget(children=[selection, options]) - viewer_options_wid = ipywidgets.ContainerWidget(children=[but, all_options]) + all_options = ipywidgets.Box(children=[selection, options]) + viewer_options_wid = ipywidgets.Box(children=[but, all_options]) # save tab titles and options str to widget in order to be passed to the # format function @@ -1813,7 +1813,7 @@ def save_figure_options(renderer, format_default='png', dpi_default=None, from os.path import join, splitext # create widgets - but = ipywidgets.ToggleButtonWidget(description='Save Figure', + but = ipywidgets.ToggleButton(description='Save Figure', value=toggle_show_default, visible=toggle_show_visible) format_dict = OrderedDict() @@ -1823,7 +1823,7 @@ def save_figure_options(renderer, format_default='png', dpi_default=None, format_dict['eps'] = 'eps' format_dict['postscript'] = 'ps' format_dict['svg'] = 'svg' - format_wid = ipywidgets.SelectWidget(values=format_dict, + format_wid = ipywidgets.Select(values=format_dict, value=format_default, description='Format') @@ -1839,11 +1839,11 @@ def set_extension(name, value): format_wid.on_trait_change(set_extension, 'value') if dpi_default is None: dpi_default = 0 - dpi_wid = ipywidgets.FloatTextWidget(description='DPI', value=dpi_default) + dpi_wid = ipywidgets.FloatText(description='DPI', value=dpi_default) orientation_dict = OrderedDict() orientation_dict['portrait'] = 'portrait' orientation_dict['landscape'] = 'landscape' - orientation_wid = ipywidgets.DropdownWidget(values=orientation_dict, + orientation_wid = ipywidgets.Dropdown(values=orientation_dict, value=orientation_default, description='Orientation') papertype_dict = OrderedDict() @@ -1874,38 +1874,38 @@ def set_extension(name, value): papertype_dict['b9'] = 'b9' papertype_dict['b10'] = 'b10' is_ps_type = not format_default == 'ps' - papertype_wid = ipywidgets.DropdownWidget(values=papertype_dict, + papertype_wid = ipywidgets.Dropdown(values=papertype_dict, value=papertype_default, description='Paper type', disabled=is_ps_type) - transparent_wid = ipywidgets.CheckboxWidget(description='Transparent', + transparent_wid = ipywidgets.Checkbox(description='Transparent', value=transparent_default) facecolour_wid = colour_selection([facecolour_default], title='Face colour') edgecolour_wid = colour_selection([edgecolour_default], title='Edge colour') - pad_inches_wid = ipywidgets.FloatTextWidget(description='Pad (inch)', + pad_inches_wid = ipywidgets.FloatText(description='Pad (inch)', value=pad_inches_default) - filename = ipywidgets.TextWidget(description='Path', + filename = ipywidgets.Text(description='Path', value=join(getcwd(), 'Untitled.' + format_default)) - overwrite = ipywidgets.CheckboxWidget( + overwrite = ipywidgets.Checkbox( description='Overwrite if file exists', value=overwrite_default) - error_str = ipywidgets.LatexWidget(value="") - save_but = ipywidgets.ButtonWidget(description='Save') + error_str = ipywidgets.Latex(value="") + save_but = ipywidgets.Button(description='Save') # create final widget - path_wid = ipywidgets.ContainerWidget( + path_wid = ipywidgets.Box( children=[filename, format_wid, overwrite, papertype_wid]) - page_wid = ipywidgets.ContainerWidget(children=[orientation_wid, dpi_wid, + page_wid = ipywidgets.Box(children=[orientation_wid, dpi_wid, pad_inches_wid]) - colour_wid = ipywidgets.ContainerWidget( + colour_wid = ipywidgets.Box( children=[facecolour_wid, edgecolour_wid, transparent_wid]) - options_wid = ipywidgets.TabWidget( + options_wid = ipywidgets.Tab( children=[path_wid, page_wid, colour_wid]) - save_wid = ipywidgets.ContainerWidget(children=[save_but, error_str]) - save_figure_wid = ipywidgets.ContainerWidget( + save_wid = ipywidgets.Box(children=[save_but, error_str]) + save_figure_wid = ipywidgets.Box( children=[but, options_wid, save_wid]) # Assign renderer @@ -2056,7 +2056,7 @@ def features_options(toggle_show_default=True, toggle_show_visible=True): import IPython.html.widgets as ipywidgets # Toggle button that controls options' visibility - but = ipywidgets.ToggleButtonWidget(description='Features Options', + but = ipywidgets.ToggleButton(description='Features Options', value=toggle_show_default, visible=toggle_show_visible) @@ -2069,7 +2069,7 @@ def features_options(toggle_show_default=True, toggle_show_visible=True): tmp['LBP'] = lbp tmp['Gradient'] = gradient tmp['None'] = no_op - feature = ipywidgets.RadioButtonsWidget(value=no_op, values=tmp, + feature = ipywidgets.RadioButtons(value=no_op, values=tmp, description='Feature type:') # feature-related options @@ -2081,7 +2081,7 @@ def features_options(toggle_show_default=True, toggle_show_visible=True): toggle_show_visible=False) daisy_options_wid = daisy_options(toggle_show_default=True, toggle_show_visible=False) - no_options_wid = ipywidgets.LatexWidget(value='No options available.') + no_options_wid = ipywidgets.Latex(value='No options available.') # load and rescale preview image (lenna) image = mio.import_builtin_asset.lenna_png() @@ -2089,28 +2089,28 @@ def features_options(toggle_show_default=True, toggle_show_visible=True): image = image.as_greyscale() # per feature options widget - per_feature_options = ipywidgets.ContainerWidget( + per_feature_options = ipywidgets.Box( children=[hog_options_wid, igo_options_wid, lbp_options_wid, daisy_options_wid, no_options_wid]) # preview tab widget - preview_img = ipywidgets.ImageWidget(value=_convert_image_to_bytes(image), + preview_img = ipywidgets.Image(value=_convert_image_to_bytes(image), visible=False) - preview_input = ipywidgets.LatexWidget( + preview_input = ipywidgets.Latex( value="Input: {}W x {}H x {}C".format( image.width, image.height, image.n_channels), visible=False) - preview_output = ipywidgets.LatexWidget(value="") - preview_time = ipywidgets.LatexWidget(value="") - preview = ipywidgets.ContainerWidget(children=[preview_img, preview_input, + preview_output = ipywidgets.Latex(value="") + preview_time = ipywidgets.Latex(value="") + preview = ipywidgets.Box(children=[preview_img, preview_input, preview_output, preview_time]) # options tab widget - all_options = ipywidgets.TabWidget( + all_options = ipywidgets.Tab( children=[feature, per_feature_options, preview]) # Widget container - features_options_wid = ipywidgets.ContainerWidget( + features_options_wid = ipywidgets.Box( children=[but, all_options]) # Initialize output dictionary diff --git a/menpo/visualize/widgets/tools.py b/menpo/visualize/widgets/tools.py index 082388f79..a19fde4c8 100644 --- a/menpo/visualize/widgets/tools.py +++ b/menpo/visualize/widgets/tools.py @@ -35,8 +35,8 @@ def logo(scale=0.3): image = mio.import_builtin_asset.menpo_thumbnail_jpg() MENPO_LOGO = image.rescale(scale) MENPO_LOGO_SCALE = scale - logo_wid = ipywidgets.ImageWidget(value=_convert_image_to_bytes(MENPO_LOGO)) - return ipywidgets.ContainerWidget(children=[logo_wid]) + logo_wid = ipywidgets.Image(value=_convert_image_to_bytes(MENPO_LOGO)) + return ipywidgets.Box(children=[logo_wid]) def format_logo(logo_wid, container_border='1px solid black', @@ -95,7 +95,7 @@ def index_selection_slider(index_selection_default, plot_function=None, """ import IPython.html.widgets as ipywidgets # Create widget - index_wid = ipywidgets.IntSliderWidget(min=index_selection_default['min'], + index_wid = ipywidgets.IntSlider(min=index_selection_default['min'], max=index_selection_default['max'], value=index_selection_default[ 'index'], @@ -169,12 +169,12 @@ def index_selection_buttons(index_selection_default, plot_function=None, """ import IPython.html.widgets as ipywidgets # Create widgets - tlt = ipywidgets.LatexWidget(value=description) - but_minus = ipywidgets.ButtonWidget(description=minus_description) - but_plus = ipywidgets.ButtonWidget(description=plus_description) - val = ipywidgets.IntTextWidget(value=index_selection_default['index'], + tlt = ipywidgets.Latex(value=description) + but_minus = ipywidgets.Button(description=minus_description) + but_plus = ipywidgets.Button(description=plus_description) + val = ipywidgets.IntText(value=index_selection_default['index'], disabled=not text_editable) - index_wid = ipywidgets.ContainerWidget(children=[tlt, but_minus, val, + index_wid = ipywidgets.Box(children=[tlt, but_minus, val, but_plus]) # Assign output @@ -246,7 +246,7 @@ def format_index_selection(index_wid, text_width='0.5cm'): """ import IPython.html.widgets as ipywidgets - if not isinstance(index_wid, ipywidgets.IntSliderWidget): + if not isinstance(index_wid, ipywidgets.IntSlider): # align all widgets index_wid.remove_class('vbox') index_wid.add_class('hbox') @@ -305,7 +305,7 @@ def update_index_selection(index_wid, index_selection_default, index_selection_default['max'] == index_wid_selected['max'] and index_selection_default['step'] == index_wid_selected['step'] and index_selection_default['index'] == index_wid_selected['index']): - if isinstance(index_wid, ipywidgets.IntSliderWidget): + if isinstance(index_wid, ipywidgets.IntSlider): # created by `index_selection_slider()` function index_wid.min = index_selection_default['min'] index_wid.max = index_selection_default['max'] @@ -406,23 +406,23 @@ def colour_selection(default_colour_list, plot_function=None, title='Colour', else: for k, l in enumerate(labels): labels_dict[l] = k - selection = ipywidgets.DropdownWidget(values=labels_dict, value=0) - apply_to_all = ipywidgets.ButtonWidget(description='apply to all labels') - labels_wid = ipywidgets.ContainerWidget(children=[selection, apply_to_all], + selection = ipywidgets.Dropdown(values=labels_dict, value=0) + apply_to_all = ipywidgets.Button(description='apply to all labels') + labels_wid = ipywidgets.Box(children=[selection, apply_to_all], visible=multiple) # find default values default_colour, r_val, g_val, b_val = _decode_colour(default_colour_list[0]) # create widgets - r_wid = ipywidgets.BoundedFloatTextWidget(value=r_val, description='RGB', + r_wid = ipywidgets.BoundedFloatText(value=r_val, description='RGB', min=0.0, max=1.0) - g_wid = ipywidgets.BoundedFloatTextWidget(value=g_val, min=0.0, max=1.0) - b_wid = ipywidgets.BoundedFloatTextWidget(value=b_val, min=0.0, max=1.0) - menu = ipywidgets.DropdownWidget(values=colour_dict, value=default_colour, + g_wid = ipywidgets.BoundedFloatText(value=g_val, min=0.0, max=1.0) + b_wid = ipywidgets.BoundedFloatText(value=b_val, min=0.0, max=1.0) + menu = ipywidgets.Dropdown(values=colour_dict, value=default_colour, description='') - rgb = ipywidgets.ContainerWidget(children=[r_wid, g_wid, b_wid]) + rgb = ipywidgets.Box(children=[r_wid, g_wid, b_wid]) if multiple: selection.description = title @@ -430,7 +430,7 @@ def colour_selection(default_colour_list, plot_function=None, title='Colour', menu.description = title # Final widget - colour_selection_wid = ipywidgets.ContainerWidget( + colour_selection_wid = ipywidgets.Box( children=[labels_wid, menu, rgb]) # Assign output @@ -659,21 +659,21 @@ def image_options(image_options_default, plot_function=None, import IPython.html.widgets as ipywidgets # Create widgets # toggle button - but = ipywidgets.ToggleButtonWidget(description=toggle_title, + but = ipywidgets.ToggleButton(description=toggle_title, value=toggle_show_default, visible=toggle_show_visible) # alpha, interpolation - interpolation = ipywidgets.CheckboxWidget( + interpolation = ipywidgets.Checkbox( description='Pixelated', value=image_options_default['interpolation'] == 'none') - alpha = ipywidgets.FloatSliderWidget(description='Alpha', + alpha = ipywidgets.FloatSlider(description='Alpha', value=image_options_default['alpha'], min=0.0, max=1.0, step=0.05) - options_wid = ipywidgets.ContainerWidget(children=[interpolation, alpha]) + options_wid = ipywidgets.Box(children=[interpolation, alpha]) # Final widget - image_options_wid = ipywidgets.ContainerWidget(children=[but, options_wid]) + image_options_wid = ipywidgets.Box(children=[but, options_wid]) # Assign output image_options_wid.selected_values = image_options_default @@ -828,15 +828,15 @@ def line_options(line_options_default, plot_function=None, import IPython.html.widgets as ipywidgets # Create widgets # toggle button - but = ipywidgets.ToggleButtonWidget(description=toggle_title, + but = ipywidgets.ToggleButton(description=toggle_title, value=toggle_show_default, visible=toggle_show_visible) # line_style, line_width, line_colour - render_lines = ipywidgets.CheckboxWidget(description=show_checkbox_title, + render_lines = ipywidgets.Checkbox(description=show_checkbox_title, value=line_options_default[ 'render_lines']) - line_width = ipywidgets.BoundedFloatTextWidget(description='Width', + line_width = ipywidgets.BoundedFloatText(description='Width', value=line_options_default[ 'line_width'], min=0.) @@ -845,7 +845,7 @@ def line_options(line_options_default, plot_function=None, line_style_dict['dashed'] = '--' line_style_dict['dash-dot'] = '-.' line_style_dict['dotted'] = ':' - line_style = ipywidgets.DropdownWidget(values=line_style_dict, + line_style = ipywidgets.Dropdown(values=line_style_dict, value=line_options_default[ 'line_style'], description='Style') @@ -854,14 +854,14 @@ def line_options(line_options_default, plot_function=None, plot_function=plot_function) # Options widget - all_line_options = ipywidgets.ContainerWidget( + all_line_options = ipywidgets.Box( children=[line_style, line_width, line_colour]) - options_wid = ipywidgets.ContainerWidget( + options_wid = ipywidgets.Box( children=[render_lines, all_line_options]) # Final widget - line_options_wid = ipywidgets.ContainerWidget(children=[but, options_wid]) + line_options_wid = ipywidgets.Box(children=[but, options_wid]) # Assign output line_options_wid.selected_values = line_options_default @@ -1073,18 +1073,18 @@ def marker_options(marker_options_default, plot_function=None, import IPython.html.widgets as ipywidgets # Create widgets # toggle button - but = ipywidgets.ToggleButtonWidget(description=toggle_title, + but = ipywidgets.ToggleButton(description=toggle_title, value=toggle_show_default, visible=toggle_show_visible) # marker_size, marker_edge_width, marker_style, marker_face_colour, # marker_edge_colour - render_markers = ipywidgets.CheckboxWidget( + render_markers = ipywidgets.Checkbox( description=show_checkbox_title, value=marker_options_default['render_markers']) - marker_size = ipywidgets.BoundedIntTextWidget( + marker_size = ipywidgets.BoundedIntText( description='Size', value=marker_options_default['marker_size'], min=0) - marker_edge_width = ipywidgets.BoundedFloatTextWidget( + marker_edge_width = ipywidgets.BoundedFloatText( description='Edge width', value=marker_options_default['marker_edge_width'], min=0.) marker_style_dict = OrderedDict() @@ -1109,7 +1109,7 @@ def marker_options(marker_options_default, plot_function=None, marker_style_dict['x'] = 'x' marker_style_dict['diamond'] = 'D' marker_style_dict['thin diamond'] = 'd' - marker_style = ipywidgets.DropdownWidget(values=marker_style_dict, + marker_style = ipywidgets.Dropdown(values=marker_style_dict, value=marker_options_default[ 'marker_style'], description='Style') @@ -1121,16 +1121,16 @@ def marker_options(marker_options_default, plot_function=None, plot_function=plot_function) # Options widget - all_marker_options = ipywidgets.ContainerWidget( + all_marker_options = ipywidgets.Box( children=[marker_style, marker_size, marker_edge_width, marker_face_colour, marker_edge_colour]) - options_wid = ipywidgets.ContainerWidget( + options_wid = ipywidgets.Box( children=[render_markers, all_marker_options]) # Final widget - marker_options_wid = ipywidgets.ContainerWidget(children=[but, options_wid]) + marker_options_wid = ipywidgets.Box(children=[but, options_wid]) # Assign output marker_options_wid.selected_values = marker_options_default @@ -1381,13 +1381,13 @@ def numbering_options(numbers_options_default, plot_function=None, import IPython.html.widgets as ipywidgets # Create widgets # toggle button - but = ipywidgets.ToggleButtonWidget(description=toggle_title, + but = ipywidgets.ToggleButton(description=toggle_title, value=toggle_show_default, visible=toggle_show_visible) # numbers_font_name, numbers_font_size, numbers_font_style, # numbers_font_weight, numbers_font_colour - render_numbering = ipywidgets.CheckboxWidget( + render_numbering = ipywidgets.Checkbox( description=show_checkbox_title, value=numbers_options_default['render_numbering']) numbers_font_name_dict = OrderedDict() @@ -1396,17 +1396,17 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_font_name_dict['cursive'] = 'cursive' numbers_font_name_dict['fantasy'] = 'fantasy' numbers_font_name_dict['monospace'] = 'monospace' - numbers_font_name = ipywidgets.DropdownWidget( + numbers_font_name = ipywidgets.Dropdown( values=numbers_font_name_dict, value=numbers_options_default['numbers_font_name'], description='Font') - numbers_font_size = ipywidgets.BoundedIntTextWidget( + numbers_font_size = ipywidgets.BoundedIntText( description='Size', value=numbers_options_default['numbers_font_size'], min=2) numbers_font_style_dict = OrderedDict() numbers_font_style_dict['normal'] = 'normal' numbers_font_style_dict['italic'] = 'italic' numbers_font_style_dict['oblique'] = 'oblique' - numbers_font_style = ipywidgets.DropdownWidget( + numbers_font_style = ipywidgets.Dropdown( values=numbers_font_style_dict, value=numbers_options_default['numbers_font_style'], description='Style') @@ -1425,7 +1425,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_font_weight_dict['heavy'] = 'heavy' numbers_font_weight_dict['extra bold'] = 'extra bold' numbers_font_weight_dict['black'] = 'black' - numbers_font_weight = ipywidgets.DropdownWidget( + numbers_font_weight = ipywidgets.Dropdown( values=numbers_font_weight_dict, value=numbers_options_default['numbers_font_weight'], description='Weight') @@ -1436,7 +1436,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_horizontal_align_dict['center'] = 'center' numbers_horizontal_align_dict['right'] = 'right' numbers_horizontal_align_dict['left'] = 'left' - numbers_horizontal_align = ipywidgets.DropdownWidget( + numbers_horizontal_align = ipywidgets.Dropdown( values=numbers_horizontal_align_dict, value=numbers_options_default['numbers_horizontal_align'], description='Align hor.') @@ -1445,21 +1445,21 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_vertical_align_dict['top'] = 'top' numbers_vertical_align_dict['bottom'] = 'bottom' numbers_vertical_align_dict['baseline'] = 'baseline' - numbers_vertical_align = ipywidgets.DropdownWidget( + numbers_vertical_align = ipywidgets.Dropdown( values=numbers_vertical_align_dict, value=numbers_options_default['numbers_vertical_align'], description='Align ver.') # Options widget - all_font_options = ipywidgets.ContainerWidget( + all_font_options = ipywidgets.Box( children=[numbers_font_name, numbers_font_size, numbers_font_style, numbers_font_weight, numbers_font_colour, numbers_horizontal_align, numbers_vertical_align]) - options_wid = ipywidgets.ContainerWidget( + options_wid = ipywidgets.Box( children=[render_numbering, all_font_options]) # Final widget - numbering_options_wid = ipywidgets.ContainerWidget( + numbering_options_wid = ipywidgets.Box( children=[but, options_wid]) # Assign output @@ -1737,19 +1737,19 @@ def figure_options(figure_options_default, plot_function=None, import IPython.html.widgets as ipywidgets # Create widgets # toggle button - but = ipywidgets.ToggleButtonWidget(description='Figure Options', + but = ipywidgets.ToggleButton(description='Figure Options', value=toggle_show_default, visible=toggle_show_visible) # figure_scale, render_axes - figure_scale = ipywidgets.FloatSliderWidget(description='Figure scale:', + figure_scale = ipywidgets.FloatSlider(description='Figure scale:', value=figure_options_default[ 'x_scale'], min=figure_scale_bounds[0], max=figure_scale_bounds[1], step=figure_scale_step, visible=figure_scale_visible) - render_axes = ipywidgets.CheckboxWidget(description='Render axes', + render_axes = ipywidgets.Checkbox(description='Render axes', value=figure_options_default[ 'render_axes'], visible=axes_visible) @@ -1759,18 +1759,18 @@ def figure_options(figure_options_default, plot_function=None, axes_font_name_dict['cursive'] = 'cursive' axes_font_name_dict['fantasy'] = 'fantasy' axes_font_name_dict['monospace'] = 'monospace' - axes_font_name = ipywidgets.DropdownWidget( + axes_font_name = ipywidgets.Dropdown( values=axes_font_name_dict, value=figure_options_default['axes_font_name'], description='Font', visible=axes_visible) - axes_font_size = ipywidgets.BoundedIntTextWidget( + axes_font_size = ipywidgets.BoundedIntText( description='Size', value=figure_options_default['axes_font_size'], min=0, visible=axes_visible) axes_font_style_dict = OrderedDict() axes_font_style_dict['normal'] = 'normal' axes_font_style_dict['italic'] = 'italic' axes_font_style_dict['oblique'] = 'oblique' - axes_font_style = ipywidgets.DropdownWidget( + axes_font_style = ipywidgets.Dropdown( values=axes_font_style_dict, value=figure_options_default['axes_font_style'], description='Style', visible=axes_visible) @@ -1789,7 +1789,7 @@ def figure_options(figure_options_default, plot_function=None, axes_font_weight_dict['heavy'] = 'heavy' axes_font_weight_dict['extra bold'] = 'extra bold' axes_font_weight_dict['black'] = 'black' - axes_font_weight = ipywidgets.DropdownWidget( + axes_font_weight = ipywidgets.Dropdown( values=axes_font_weight_dict, value=figure_options_default['axes_font_weight'], description='Weight', visible=axes_visible) @@ -1801,11 +1801,11 @@ def figure_options(figure_options_default, plot_function=None, tmp1 = True tmp2 = figure_options_default['axes_x_limits'][0] tmp3 = figure_options_default['axes_x_limits'][1] - axes_x_limits_enable = ipywidgets.CheckboxWidget(value=tmp1, + axes_x_limits_enable = ipywidgets.Checkbox(value=tmp1, description='X limits') - axes_x_limits_from = ipywidgets.FloatTextWidget(value=tmp2, description='') - axes_x_limits_to = ipywidgets.FloatTextWidget(value=tmp3, description='') - axes_x_limits = ipywidgets.ContainerWidget(children=[axes_x_limits_enable, + axes_x_limits_from = ipywidgets.FloatText(value=tmp2, description='') + axes_x_limits_to = ipywidgets.FloatText(value=tmp3, description='') + axes_x_limits = ipywidgets.Box(children=[axes_x_limits_enable, axes_x_limits_from, axes_x_limits_to]) if figure_options_default['axes_y_limits'] is None: @@ -1816,16 +1816,16 @@ def figure_options(figure_options_default, plot_function=None, tmp1 = True tmp2 = figure_options_default['axes_y_limits'][0] tmp3 = figure_options_default['axes_y_limits'][1] - axes_y_limits_enable = ipywidgets.CheckboxWidget(value=tmp1, + axes_y_limits_enable = ipywidgets.Checkbox(value=tmp1, description='Y limits') - axes_y_limits_from = ipywidgets.FloatTextWidget(value=tmp2, description='') - axes_y_limits_to = ipywidgets.FloatTextWidget(value=tmp3, description='') - axes_y_limits = ipywidgets.ContainerWidget(children=[axes_y_limits_enable, + axes_y_limits_from = ipywidgets.FloatText(value=tmp2, description='') + axes_y_limits_to = ipywidgets.FloatText(value=tmp3, description='') + axes_y_limits = ipywidgets.Box(children=[axes_y_limits_enable, axes_y_limits_from, axes_y_limits_to]) # Final widget - figure_options_wid = ipywidgets.ContainerWidget(children=[but, figure_scale, + figure_options_wid = ipywidgets.Box(children=[but, figure_scale, render_axes, axes_font_name, axes_font_size, @@ -2170,30 +2170,30 @@ def figure_options_two_scales(figure_options_default, plot_function=None, import IPython.html.widgets as ipywidgets # Create widgets # toggle button - but = ipywidgets.ToggleButtonWidget(description='Figure Options', + but = ipywidgets.ToggleButton(description='Figure Options', value=toggle_show_default, visible=toggle_show_visible) # figure_scale, render_axes - x_scale = ipywidgets.FloatSliderWidget(description='Figure size: X scale', + x_scale = ipywidgets.FloatSlider(description='Figure size: X scale', value=figure_options_default[ 'x_scale'], min=figure_scales_bounds[0], max=figure_scales_bounds[1], step=figure_scales_step) - y_scale = ipywidgets.FloatSliderWidget(description='Y scale', + y_scale = ipywidgets.FloatSlider(description='Y scale', value=figure_options_default[ 'y_scale'], min=figure_scales_bounds[0], max=figure_scales_bounds[1], step=figure_scales_step, disabled=coupled_default) - coupled = ipywidgets.CheckboxWidget(description='Coupled', + coupled = ipywidgets.Checkbox(description='Coupled', value=coupled_default) - figure_scale = ipywidgets.ContainerWidget( + figure_scale = ipywidgets.Box( children=[x_scale, y_scale, coupled], visible=figure_scales_visible) - render_axes = ipywidgets.CheckboxWidget(description='Render axes', + render_axes = ipywidgets.Checkbox(description='Render axes', value=figure_options_default[ 'render_axes'], visible=axes_visible) @@ -2203,18 +2203,18 @@ def figure_options_two_scales(figure_options_default, plot_function=None, axes_font_name_dict['cursive'] = 'cursive' axes_font_name_dict['fantasy'] = 'fantasy' axes_font_name_dict['monospace'] = 'monospace' - axes_font_name = ipywidgets.DropdownWidget( + axes_font_name = ipywidgets.Dropdown( values=axes_font_name_dict, value=figure_options_default['axes_font_name'], description='Font', visible=axes_visible) - axes_font_size = ipywidgets.BoundedIntTextWidget( + axes_font_size = ipywidgets.BoundedIntText( description='Size', value=figure_options_default['axes_font_size'], min=0, visible=axes_visible) axes_font_style_dict = OrderedDict() axes_font_style_dict['normal'] = 'normal' axes_font_style_dict['italic'] = 'italic' axes_font_style_dict['oblique'] = 'oblique' - axes_font_style = ipywidgets.DropdownWidget( + axes_font_style = ipywidgets.Dropdown( values=axes_font_style_dict, value=figure_options_default['axes_font_style'], description='Style', visible=axes_visible) @@ -2233,7 +2233,7 @@ def figure_options_two_scales(figure_options_default, plot_function=None, axes_font_weight_dict['heavy'] = 'heavy' axes_font_weight_dict['extra bold'] = 'extra bold' axes_font_weight_dict['black'] = 'black' - axes_font_weight = ipywidgets.DropdownWidget( + axes_font_weight = ipywidgets.Dropdown( values=axes_font_weight_dict, value=figure_options_default['axes_font_weight'], description='Weight', visible=axes_visible) @@ -2245,11 +2245,11 @@ def figure_options_two_scales(figure_options_default, plot_function=None, tmp1 = True tmp2 = figure_options_default['axes_x_limits'][0] tmp3 = figure_options_default['axes_x_limits'][1] - axes_x_limits_enable = ipywidgets.CheckboxWidget(value=tmp1, + axes_x_limits_enable = ipywidgets.Checkbox(value=tmp1, description='X limits') - axes_x_limits_from = ipywidgets.FloatTextWidget(value=tmp2, description='') - axes_x_limits_to = ipywidgets.FloatTextWidget(value=tmp3, description='') - axes_x_limits = ipywidgets.ContainerWidget(children=[axes_x_limits_enable, + axes_x_limits_from = ipywidgets.FloatText(value=tmp2, description='') + axes_x_limits_to = ipywidgets.FloatText(value=tmp3, description='') + axes_x_limits = ipywidgets.Box(children=[axes_x_limits_enable, axes_x_limits_from, axes_x_limits_to]) if figure_options_default['axes_y_limits'] is None: @@ -2260,16 +2260,16 @@ def figure_options_two_scales(figure_options_default, plot_function=None, tmp1 = True tmp2 = figure_options_default['axes_y_limits'][0] tmp3 = figure_options_default['axes_y_limits'][1] - axes_y_limits_enable = ipywidgets.CheckboxWidget(value=tmp1, + axes_y_limits_enable = ipywidgets.Checkbox(value=tmp1, description='Y limits') - axes_y_limits_from = ipywidgets.FloatTextWidget(value=tmp2, description='') - axes_y_limits_to = ipywidgets.FloatTextWidget(value=tmp3, description='') - axes_y_limits = ipywidgets.ContainerWidget(children=[axes_y_limits_enable, + axes_y_limits_from = ipywidgets.FloatText(value=tmp2, description='') + axes_y_limits_to = ipywidgets.FloatText(value=tmp3, description='') + axes_y_limits = ipywidgets.Box(children=[axes_y_limits_enable, axes_y_limits_from, axes_y_limits_to]) # Final widget - figure_options_wid = ipywidgets.ContainerWidget(children=[but, figure_scale, + figure_options_wid = ipywidgets.Box(children=[but, figure_scale, render_axes, axes_font_name, axes_font_size, @@ -2638,12 +2638,12 @@ def legend_options(legend_options_default, plot_function=None, import IPython.html.widgets as ipywidgets # Create widgets # toggle button - but = ipywidgets.ToggleButtonWidget(description=toggle_title, + but = ipywidgets.ToggleButton(description=toggle_title, value=toggle_show_default, visible=toggle_show_visible) # render legend - render_legend = ipywidgets.CheckboxWidget( + render_legend = ipywidgets.Checkbox( description=show_checkbox_title, value=legend_options_default['render_legend']) @@ -2654,17 +2654,17 @@ def legend_options(legend_options_default, plot_function=None, legend_font_name_dict['cursive'] = 'cursive' legend_font_name_dict['fantasy'] = 'fantasy' legend_font_name_dict['monospace'] = 'monospace' - legend_font_name = ipywidgets.DropdownWidget( + legend_font_name = ipywidgets.Dropdown( values=legend_font_name_dict, value=legend_options_default['legend_font_name'], description='Font') - legend_font_size = ipywidgets.BoundedIntTextWidget( + legend_font_size = ipywidgets.BoundedIntText( description='Size', value=legend_options_default['legend_font_size'], min=0) legend_font_style_dict = OrderedDict() legend_font_style_dict['normal'] = 'normal' legend_font_style_dict['italic'] = 'italic' legend_font_style_dict['oblique'] = 'oblique' - legend_font_style = ipywidgets.DropdownWidget( + legend_font_style = ipywidgets.Dropdown( values=legend_font_style_dict, value=legend_options_default['legend_font_style'], description='Style') legend_font_weight_dict = OrderedDict() @@ -2682,19 +2682,19 @@ def legend_options(legend_options_default, plot_function=None, legend_font_weight_dict['heavy'] = 'heavy' legend_font_weight_dict['extra bold'] = 'extra bold' legend_font_weight_dict['black'] = 'black' - legend_font_weight = ipywidgets.DropdownWidget( + legend_font_weight = ipywidgets.Dropdown( values=legend_font_weight_dict, value=legend_options_default['legend_font_weight'], description='Weight') - legend_title = ipywidgets.TextWidget(description='Title', + legend_title = ipywidgets.Text(description='Title', value=legend_options_default[ 'legend_title']) - font_cont_tmp = ipywidgets.ContainerWidget( - children=[ipywidgets.ContainerWidget(children=[legend_font_name, + font_cont_tmp = ipywidgets.Box( + children=[ipywidgets.Box(children=[legend_font_name, legend_font_size]), - ipywidgets.ContainerWidget(children=[legend_font_style, + ipywidgets.Box(children=[legend_font_style, legend_font_weight])]) - font_cont = ipywidgets.ContainerWidget( + font_cont = ipywidgets.Box( children=[legend_title, font_cont_tmp]) # legend_location-related @@ -2710,7 +2710,7 @@ def legend_options(legend_options_default, plot_function=None, legend_location_dict['lower center'] = 8 legend_location_dict['upper center'] = 9 legend_location_dict['center'] = 10 - legend_location = ipywidgets.DropdownWidget( + legend_location = ipywidgets.Dropdown( values=legend_location_dict, value=legend_options_default['legend_location'], description='Predefined location') @@ -2722,67 +2722,67 @@ def legend_options(legend_options_default, plot_function=None, tmp1 = True tmp2 = legend_options_default['legend_bbox_to_anchor'][0] tmp3 = legend_options_default['legend_bbox_to_anchor'][1] - bbox_to_anchor_enable = ipywidgets.CheckboxWidget( + bbox_to_anchor_enable = ipywidgets.Checkbox( value=tmp1, description='Arbitrary location') - bbox_to_anchor_x = ipywidgets.FloatTextWidget(value=tmp2, description='') - bbox_to_anchor_y = ipywidgets.FloatTextWidget(value=tmp3, description='') - legend_bbox_to_anchor = ipywidgets.ContainerWidget( + bbox_to_anchor_x = ipywidgets.FloatText(value=tmp2, description='') + bbox_to_anchor_y = ipywidgets.FloatText(value=tmp3, description='') + legend_bbox_to_anchor = ipywidgets.Box( children=[bbox_to_anchor_enable, bbox_to_anchor_x, bbox_to_anchor_y]) - legend_border_axes_pad = ipywidgets.BoundedFloatTextWidget( + legend_border_axes_pad = ipywidgets.BoundedFloatText( value=legend_options_default['legend_border_axes_pad'], description='Distance to axes', min=0.) - location_cont = ipywidgets.ContainerWidget( + location_cont = ipywidgets.Box( children=[legend_location, legend_bbox_to_anchor, legend_border_axes_pad]) # formatting-related - legend_n_columns = ipywidgets.BoundedIntTextWidget( + legend_n_columns = ipywidgets.BoundedIntText( value=legend_options_default['legend_n_columns'], description='Columns', min=0) - legend_marker_scale = ipywidgets.BoundedFloatTextWidget( + legend_marker_scale = ipywidgets.BoundedFloatText( description='Marker scale', value=legend_options_default['legend_marker_scale'], min=0.) - legend_horizontal_spacing = ipywidgets.BoundedFloatTextWidget( + legend_horizontal_spacing = ipywidgets.BoundedFloatText( value=legend_options_default['legend_horizontal_spacing'], description='Horizontal space', min=0.) - legend_vertical_spacing = ipywidgets.BoundedFloatTextWidget( + legend_vertical_spacing = ipywidgets.BoundedFloatText( value=legend_options_default['legend_vertical_spacing'], description='Vertical space', min=0.) - spacing = ipywidgets.ContainerWidget( - children=[ipywidgets.ContainerWidget(children=[legend_n_columns, + spacing = ipywidgets.Box( + children=[ipywidgets.Box(children=[legend_n_columns, legend_marker_scale]), - ipywidgets.ContainerWidget( + ipywidgets.Box( children=[legend_horizontal_spacing, legend_vertical_spacing])]) - legend_border = ipywidgets.CheckboxWidget( + legend_border = ipywidgets.Checkbox( description='Border', value=legend_options_default['legend_border']) - legend_border_padding = ipywidgets.BoundedFloatTextWidget( + legend_border_padding = ipywidgets.BoundedFloatText( value=legend_options_default['legend_border_padding'], description='Border pad', min=0.) - border = ipywidgets.ContainerWidget( + border = ipywidgets.Box( children=[legend_border, legend_border_padding]) - legend_shadow = ipywidgets.CheckboxWidget( + legend_shadow = ipywidgets.Checkbox( description='Shadow', value=legend_options_default['legend_shadow']) - legend_rounded_corners = ipywidgets.CheckboxWidget( + legend_rounded_corners = ipywidgets.Checkbox( description='Rounded corners', value=legend_options_default['legend_rounded_corners']) - shadow_fancy = ipywidgets.ContainerWidget(children=[legend_shadow, + shadow_fancy = ipywidgets.Box(children=[legend_shadow, legend_rounded_corners]) - formatting_cont = ipywidgets.ContainerWidget( + formatting_cont = ipywidgets.Box( children=[spacing, border, shadow_fancy]) # Options widget - tab_options = ipywidgets.TabWidget(children=[location_cont, font_cont, + tab_options = ipywidgets.Tab(children=[location_cont, font_cont, formatting_cont]) - options_wid = ipywidgets.ContainerWidget( + options_wid = ipywidgets.Box( children=[render_legend, tab_options]) # Final widget - legend_options_wid = ipywidgets.ContainerWidget(children=[but, options_wid]) + legend_options_wid = ipywidgets.Box(children=[but, options_wid]) # Assign output legend_options_wid.selected_values = legend_options_default @@ -3276,15 +3276,15 @@ def grid_options(grid_options_default, plot_function=None, import IPython.html.widgets as ipywidgets # Create widgets # toggle button - but = ipywidgets.ToggleButtonWidget(description=toggle_title, + but = ipywidgets.ToggleButton(description=toggle_title, value=toggle_show_default, visible=toggle_show_visible) # grid_line_style, grid_line_width - render_grid = ipywidgets.CheckboxWidget( + render_grid = ipywidgets.Checkbox( description=show_checkbox_title, value=grid_options_default['render_grid']) - grid_line_width = ipywidgets.BoundedFloatTextWidget( + grid_line_width = ipywidgets.BoundedFloatText( description='Width', value=grid_options_default['grid_line_width'], min=0.) grid_line_style_dict = OrderedDict() @@ -3292,18 +3292,18 @@ def grid_options(grid_options_default, plot_function=None, grid_line_style_dict['dashed'] = '--' grid_line_style_dict['dash-dot'] = '-.' grid_line_style_dict['dotted'] = ':' - grid_line_style = ipywidgets.DropdownWidget( + grid_line_style = ipywidgets.Dropdown( values=grid_line_style_dict, value=grid_options_default['grid_line_style'], description='Style') # Options widget - all_grid_options = ipywidgets.ContainerWidget( + all_grid_options = ipywidgets.Box( children=[grid_line_style, grid_line_width]) - options_wid = ipywidgets.ContainerWidget( + options_wid = ipywidgets.Box( children=[render_grid, all_grid_options]) # Final widget - grid_options_wid = ipywidgets.ContainerWidget(children=[but, options_wid]) + grid_options_wid = ipywidgets.Box(children=[but, options_wid]) # Assign output grid_options_wid.selected_values = grid_options_default @@ -3470,7 +3470,7 @@ def hog_options(toggle_show_default=True, toggle_show_visible=True): """ import IPython.html.widgets as ipywidgets # Toggle button that controls options' visibility - but = ipywidgets.ToggleButtonWidget(description='HOG Options', + but = ipywidgets.ToggleButton(description='HOG Options', value=toggle_show_default, visible=toggle_show_visible) @@ -3478,70 +3478,70 @@ def hog_options(toggle_show_default=True, toggle_show_visible=True): tmp = OrderedDict() tmp['Dense'] = 'dense' tmp['Sparse'] = 'sparse' - mode = ipywidgets.RadioButtonsWidget(values=tmp, description='Mode') - padding = ipywidgets.CheckboxWidget(value=True, description='Padding') - mode_wid = ipywidgets.ContainerWidget(children=[mode, padding]) - window_height = ipywidgets.BoundedIntTextWidget(value='1', + mode = ipywidgets.RadioButtons(values=tmp, description='Mode') + padding = ipywidgets.Checkbox(value=True, description='Padding') + mode_wid = ipywidgets.Box(children=[mode, padding]) + window_height = ipywidgets.BoundedIntText(value='1', description='Height', min=1) - window_width = ipywidgets.BoundedIntTextWidget(value='1', + window_width = ipywidgets.BoundedIntText(value='1', description='Width', min=1) tmp = OrderedDict() tmp['Blocks'] = 'blocks' tmp['Pixels'] = 'pixels' - window_size_unit = ipywidgets.RadioButtonsWidget(values=tmp, + window_size_unit = ipywidgets.RadioButtons(values=tmp, description=' Size unit') - window_size_wid = ipywidgets.ContainerWidget( + window_size_wid = ipywidgets.Box( children=[window_height, window_width, window_size_unit]) - window_vertical = ipywidgets.BoundedIntTextWidget(value='1', + window_vertical = ipywidgets.BoundedIntText(value='1', description='Step Y', min=1) - window_horizontal = ipywidgets.BoundedIntTextWidget(value='1', + window_horizontal = ipywidgets.BoundedIntText(value='1', description='Step X', min=1) tmp = OrderedDict() tmp['Pixels'] = 'pixels' tmp['Cells'] = 'cells' - window_step_unit = ipywidgets.RadioButtonsWidget(values=tmp, + window_step_unit = ipywidgets.RadioButtons(values=tmp, description='Step unit') - window_step_wid = ipywidgets.ContainerWidget(children=[window_vertical, + window_step_wid = ipywidgets.Box(children=[window_vertical, window_horizontal, window_step_unit]) - window_wid = ipywidgets.ContainerWidget( + window_wid = ipywidgets.Box( children=[window_size_wid, window_step_wid]) - window_wid = ipywidgets.ContainerWidget(children=[mode_wid, window_wid]) + window_wid = ipywidgets.Box(children=[mode_wid, window_wid]) # algorithm related options tmp = OrderedDict() tmp['Dalal & Triggs'] = 'dalaltriggs' tmp['Zhu & Ramanan'] = 'zhuramanan' - algorithm = ipywidgets.RadioButtonsWidget(values=tmp, value='dalaltriggs', + algorithm = ipywidgets.RadioButtons(values=tmp, value='dalaltriggs', description='Algorithm') - cell_size = ipywidgets.BoundedIntTextWidget( + cell_size = ipywidgets.BoundedIntText( value='8', description='Cell size (in pixels)', min=1) - block_size = ipywidgets.BoundedIntTextWidget( + block_size = ipywidgets.BoundedIntText( value='2', description='Block size (in cells)', min=1) - num_bins = ipywidgets.BoundedIntTextWidget( + num_bins = ipywidgets.BoundedIntText( value='9', description='Orientation bins', min=1) - algorithm_sizes = ipywidgets.ContainerWidget( + algorithm_sizes = ipywidgets.Box( children=[cell_size, block_size, num_bins]) - signed_gradient = ipywidgets.CheckboxWidget(value=True, + signed_gradient = ipywidgets.Checkbox(value=True, description='Signed gradients') - l2_norm_clipping = ipywidgets.BoundedFloatTextWidget( + l2_norm_clipping = ipywidgets.BoundedFloatText( value='0.2', description='L2 norm clipping', min=0.) - algorithm_other = ipywidgets.ContainerWidget(children=[signed_gradient, + algorithm_other = ipywidgets.Box(children=[signed_gradient, l2_norm_clipping]) - algorithm_options = ipywidgets.ContainerWidget(children=[algorithm_sizes, + algorithm_options = ipywidgets.Box(children=[algorithm_sizes, algorithm_other]) - algorithm_wid = ipywidgets.ContainerWidget( + algorithm_wid = ipywidgets.Box( children=[algorithm, algorithm_options]) # options tab widget - all_options = ipywidgets.TabWidget(children=[window_wid, algorithm_wid]) + all_options = ipywidgets.Tab(children=[window_wid, algorithm_wid]) # Widget container - hog_options_wid = ipywidgets.ContainerWidget(children=[but, all_options]) + hog_options_wid = ipywidgets.Box(children=[but, all_options]) # Initialize output dictionary hog_options_wid.options = {'mode': 'dense', 'algorithm': 'dalaltriggs', @@ -3757,20 +3757,20 @@ def daisy_options(toggle_show_default=True, toggle_show_visible=True): """ import IPython.html.widgets as ipywidgets # Toggle button that controls options' visibility - but = ipywidgets.ToggleButtonWidget(description='Daisy Options', + but = ipywidgets.ToggleButton(description='Daisy Options', value=toggle_show_default, visible=toggle_show_visible) # options widgets - step = ipywidgets.BoundedIntTextWidget(value='1', description='Step', min=1) - radius = ipywidgets.BoundedIntTextWidget(value='15', description='Radius', + step = ipywidgets.BoundedIntText(value='1', description='Step', min=1) + radius = ipywidgets.BoundedIntText(value='15', description='Radius', min=1) - rings = ipywidgets.BoundedIntTextWidget(value='2', description='Rings', + rings = ipywidgets.BoundedIntText(value='2', description='Rings', min=1) - histograms = ipywidgets.BoundedIntTextWidget(value='2', + histograms = ipywidgets.BoundedIntText(value='2', description='Histograms', min=1) - orientations = ipywidgets.BoundedIntTextWidget(value='8', + orientations = ipywidgets.BoundedIntText(value='8', description='Orientations', min=1) tmp = OrderedDict() @@ -3778,21 +3778,21 @@ def daisy_options(toggle_show_default=True, toggle_show_visible=True): tmp['L2'] = 'l2' tmp['Daisy'] = 'daisy' tmp['None'] = None - normalization = ipywidgets.DropdownWidget(value='l1', values=tmp, + normalization = ipywidgets.Dropdown(value='l1', values=tmp, description='Normalization') - sigmas = ipywidgets.TextWidget(description='Sigmas') - ring_radii = ipywidgets.TextWidget(description='Ring radii') + sigmas = ipywidgets.Text(description='Sigmas') + ring_radii = ipywidgets.Text(description='Ring radii') # group widgets - cont1 = ipywidgets.ContainerWidget( + cont1 = ipywidgets.Box( children=[step, radius, rings, histograms]) - cont2 = ipywidgets.ContainerWidget( + cont2 = ipywidgets.Box( children=[orientations, normalization, sigmas, ring_radii]) - options = ipywidgets.ContainerWidget(children=[cont1, cont2]) + options = ipywidgets.Box(children=[cont1, cont2]) # Widget container - daisy_options_wid = ipywidgets.ContainerWidget(children=[but, options]) + daisy_options_wid = ipywidgets.Box(children=[but, options]) # Initialize output dictionary daisy_options_wid.options = {'step': 1, 'radius': 15, @@ -3937,7 +3937,7 @@ def lbp_options(toggle_show_default=True, toggle_show_visible=True): """ import IPython.html.widgets as ipywidgets # Toggle button that controls options' visibility - but = ipywidgets.ToggleButtonWidget(description='LBP Options', + but = ipywidgets.ToggleButton(description='LBP Options', value=toggle_show_default, visible=toggle_show_visible) @@ -3947,37 +3947,37 @@ def lbp_options(toggle_show_default=True, toggle_show_visible=True): tmp['Rotation-Invariant'] = 'ri' tmp['Both'] = 'riu2' tmp['None'] = 'none' - mapping_type = ipywidgets.DropdownWidget(value='u2', values=tmp, + mapping_type = ipywidgets.Dropdown(value='u2', values=tmp, description='Mapping') - radius = ipywidgets.TextWidget(value='1, 2, 3, 4', description='Radius') - samples = ipywidgets.TextWidget(value='8, 8, 8, 8', description='Samples') - algorithm_wid = ipywidgets.ContainerWidget(children=[radius, + radius = ipywidgets.Text(value='1, 2, 3, 4', description='Radius') + samples = ipywidgets.Text(value='8, 8, 8, 8', description='Samples') + algorithm_wid = ipywidgets.Box(children=[radius, samples, mapping_type]) # window related options - window_vertical = ipywidgets.BoundedIntTextWidget(value='1', + window_vertical = ipywidgets.BoundedIntText(value='1', description='Step Y', min=1) - window_horizontal = ipywidgets.BoundedIntTextWidget(value='1', + window_horizontal = ipywidgets.BoundedIntText(value='1', description='Step X', min=1) tmp = OrderedDict() tmp['Pixels'] = 'pixels' tmp['Windows'] = 'cells' - window_step_unit = ipywidgets.RadioButtonsWidget(values=tmp, + window_step_unit = ipywidgets.RadioButtons(values=tmp, description='Step unit') - padding = ipywidgets.CheckboxWidget(value=True, description='Padding') - window_wid = ipywidgets.ContainerWidget(children=[window_vertical, + padding = ipywidgets.Checkbox(value=True, description='Padding') + window_wid = ipywidgets.Box(children=[window_vertical, window_horizontal, window_step_unit, padding]) # options widget - options = ipywidgets.ContainerWidget(children=[window_wid, algorithm_wid]) + options = ipywidgets.Box(children=[window_wid, algorithm_wid]) # Widget container - lbp_options_wid = ipywidgets.ContainerWidget(children=[but, options]) + lbp_options_wid = ipywidgets.Box(children=[but, options]) # Initialize output dictionary lbp_options_wid.options = {'radius': range(1, 5), 'samples': [8] * 4, @@ -4098,16 +4098,16 @@ def igo_options(toggle_show_default=True, toggle_show_visible=True): """ import IPython.html.widgets as ipywidgets # Toggle button that controls options' visibility - but = ipywidgets.ToggleButtonWidget(description='IGO Options', + but = ipywidgets.ToggleButton(description='IGO Options', value=toggle_show_default, visible=toggle_show_visible) # options widget - double_angles = ipywidgets.CheckboxWidget(value=False, + double_angles = ipywidgets.Checkbox(value=False, description='Double angles') # Widget container - igo_options_wid = ipywidgets.ContainerWidget(children=[but, double_angles]) + igo_options_wid = ipywidgets.Box(children=[but, double_angles]) # Initialize output dictionary igo_options_wid.options = {'double_angles': False} @@ -4187,21 +4187,21 @@ def function_definition(default_function='def my_function():\n pass', """ import IPython.html.widgets as ipywidgets # Toggle button that controls options' visibility - but = ipywidgets.ToggleButtonWidget(description='Features Options', + but = ipywidgets.ToggleButton(description='Features Options', value=toggle_show_default, visible=toggle_show_visible) # code widget - code = ipywidgets.TextareaWidget(value=default_function) - define_but = ipywidgets.ButtonWidget(description='Define') - msg_wid = ipywidgets.LatexWidget(value='') - define_wid = ipywidgets.ContainerWidget(children=[msg_wid, define_but]) + code = ipywidgets.Textarea(value=default_function) + define_but = ipywidgets.Button(description='Define') + msg_wid = ipywidgets.Latex(value='') + define_wid = ipywidgets.Box(children=[msg_wid, define_but]) # options widget - all_options = ipywidgets.ContainerWidget(children=[code, define_wid]) + all_options = ipywidgets.Box(children=[code, define_wid]) # Widget container - function_definition_wid = ipywidgets.ContainerWidget( + function_definition_wid = ipywidgets.Box( children=[but, all_options]) # Initialize output dictionary @@ -4283,10 +4283,10 @@ def format_function_definition(function_definition_wid, container_padding='6px', function_definition_wid.set_css('border', container_border) -class IntListTextWidget(): +class IntListText(): r""" Basic widget that returns a `list` of `int` numbers. It uses - `IPython.html.widgets.TextWidget()` and converts its value to a `list` of + `IPython.html.widgets.Text()` and converts its value to a `list` of `int`. Parameters @@ -4311,7 +4311,7 @@ def __init__(self, value='', description=''): val = value else: raise ValueError("value must be str or list") - self.text_wid = ipywidgets.TextWidget(value=val, + self.text_wid = ipywidgets.Text(value=val, description=description) @property @@ -4336,10 +4336,10 @@ def model_id(self): return self.text_wid.model_id -class FloatListTextWidget(IntListTextWidget): +class FloatListText(IntListText): r""" Basic widget that returns a `list` of `float` numbers. It uses - `IPython.html.widgets.TextWidget()` and converts its value to a `list` of + `IPython.html.widgets.Text()` and converts its value to a `list` of `float`. Parameters @@ -4412,7 +4412,7 @@ def _get_function_handle_from_string(s): def _convert_image_to_bytes(image): r""" Function that given a menpo.Image object, it converts it to the correct - bytes format that can be used by IPython.html.widgets.ImageWidget(). + bytes format that can be used by IPython.html.widgets.Image(). """ fp = StringIO() image.as_PILImage().save(fp, format='png') From ed94c730e7bdfd89c26d72f56197cf93ceb09e62 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 4 Mar 2015 13:44:15 +0000 Subject: [PATCH 2/8] Change value to default_value For dropdown, radiobutton and select widgets. --- menpo/visualize/widgets/base.py | 10 +-- menpo/visualize/widgets/options.py | 48 +++++------ menpo/visualize/widgets/tools.py | 129 +++++++++++++++-------------- 3 files changed, 94 insertions(+), 93 deletions(-) diff --git a/menpo/visualize/widgets/base.py b/menpo/visualize/widgets/base.py index a9ec94e38..476ac8c54 100644 --- a/menpo/visualize/widgets/base.py +++ b/menpo/visualize/widgets/base.py @@ -146,7 +146,7 @@ def update_info(pointcloud): # viewer options widget axes_mode_wid = ipywidgets.RadioButtons( values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', - value=2) + default_value=2) axes_mode_wid.on_trait_change(plot_function, 'value') viewer_options_wid = viewer_options(viewer_options_default, ['lines', 'markers', 'figure_one'], @@ -458,7 +458,7 @@ def update_info(landmarkgroup): # viewer options widget axes_mode_wid = ipywidgets.RadioButtons( values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', - value=2) + default_value=2) axes_mode_wid.on_trait_change(plot_function, 'value') viewer_options_wid = viewer_options(viewer_options_default, ['lines', 'markers', 'numbering', @@ -472,7 +472,7 @@ def update_info(landmarkgroup): # landmarks selection viewer_options_wid.children[1].children[0].visible = False viewer_options_all = ipywidgets.Box(children=[axes_mode_wid, - viewer_options_wid]) + viewer_options_wid]) info_wid = info_print(n_bullets=5, toggle_show_default=True, toggle_show_visible=False) @@ -826,7 +826,7 @@ def update_info(landmarks, group): # viewer options widget axes_mode_wid = ipywidgets.RadioButtons( values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', - value=2) + default_value=2) axes_mode_wid.on_trait_change(plot_function, 'value') viewer_options_wid = viewer_options(viewer_options_default, ['lines', 'markers', 'numbering', @@ -840,7 +840,7 @@ def update_info(landmarks, group): # landmarks selection viewer_options_wid.children[1].children[0].visible = False viewer_options_all = ipywidgets.Box(children=[axes_mode_wid, - viewer_options_wid]) + viewer_options_wid]) info_wid = info_print(n_bullets=5, toggle_show_default=True, toggle_show_visible=False) diff --git a/menpo/visualize/widgets/options.py b/menpo/visualize/widgets/options.py index bb799f06e..613b72930 100644 --- a/menpo/visualize/widgets/options.py +++ b/menpo/visualize/widgets/options.py @@ -114,10 +114,11 @@ def channel_options(channels_options_default, plot_function=None, # Create all necessary widgets # If single channel, disable all options apart from masked but = ipywidgets.ToggleButton(description='Channels Options', - value=toggle_show_default, - visible=toggle_show_visible) + default_value=toggle_show_default, + visible=toggle_show_visible) mode = ipywidgets.RadioButtons( - values=["Single", "Multiple"], value=mode_default, description='Mode:', + values=["Single", "Multiple"], default_value=mode_default, + description='Mode:', visible=toggle_show_default, disabled=channels_options_default['n_channels'] == 1) masked = ipywidgets.Checkbox( @@ -578,11 +579,10 @@ def landmark_options(landmark_options_default, plot_function=None, import IPython.html.widgets as ipywidgets # Create all necessary widgets but = ipywidgets.ToggleButton(description='Landmarks Options', - value=toggle_show_default, - visible=toggle_show_visible) + value=toggle_show_default, + visible=toggle_show_visible) landmarks = ipywidgets.Checkbox(description='Render landmarks', - value=landmark_options_default[ - 'render_landmarks']) + value=landmark_options_default['render_landmarks']) group = ipywidgets.Dropdown( values=landmark_options_default['group_keys'], description='Group') @@ -789,7 +789,7 @@ def update_landmark_options(landmark_options_wid, group_keys, labels_keys, landmark_options_wid.selected_values['labels_keys']): # Create all necessary widgets group = ipywidgets.Dropdown(values=group_keys, - description='Group') + description='Group') labels_toggles = [ [ipywidgets.ToggleButton(description=k, value=True) for k in s_keys] for s_keys in labels_keys] @@ -1488,10 +1488,10 @@ def viewer_options(viewer_options_default, options_tabs, objects_names=None, else: for k, g in enumerate(objects_names): objects_dict[g] = k - selection = ipywidgets.Dropdown(values=objects_dict, value=0, - description='Select', - visible=(selection_visible and - toggle_show_default)) + selection = ipywidgets.Dropdown(values=objects_dict, default_value=0, + description='Select', + visible=(selection_visible and + toggle_show_default)) # options widgets options_widgets = [] @@ -1814,8 +1814,8 @@ def save_figure_options(renderer, format_default='png', dpi_default=None, # create widgets but = ipywidgets.ToggleButton(description='Save Figure', - value=toggle_show_default, - visible=toggle_show_visible) + value=toggle_show_default, + visible=toggle_show_visible) format_dict = OrderedDict() format_dict['png'] = 'png' format_dict['jpg'] = 'jpg' @@ -1824,8 +1824,8 @@ def save_figure_options(renderer, format_default='png', dpi_default=None, format_dict['postscript'] = 'ps' format_dict['svg'] = 'svg' format_wid = ipywidgets.Select(values=format_dict, - value=format_default, - description='Format') + default_value=format_default, + description='Format') def papertype_visibility(name, value): papertype_wid.disabled = not value == 'ps' @@ -1844,8 +1844,8 @@ def set_extension(name, value): orientation_dict['portrait'] = 'portrait' orientation_dict['landscape'] = 'landscape' orientation_wid = ipywidgets.Dropdown(values=orientation_dict, - value=orientation_default, - description='Orientation') + default_value=orientation_default, + description='Orientation') papertype_dict = OrderedDict() papertype_dict['letter'] = 'letter' papertype_dict['legal'] = 'legal' @@ -1875,11 +1875,11 @@ def set_extension(name, value): papertype_dict['b10'] = 'b10' is_ps_type = not format_default == 'ps' papertype_wid = ipywidgets.Dropdown(values=papertype_dict, - value=papertype_default, - description='Paper type', - disabled=is_ps_type) + default_value=papertype_default, + description='Paper type', + disabled=is_ps_type) transparent_wid = ipywidgets.Checkbox(description='Transparent', - value=transparent_default) + value=transparent_default) facecolour_wid = colour_selection([facecolour_default], title='Face colour') edgecolour_wid = colour_selection([edgecolour_default], title='Edge colour') pad_inches_wid = ipywidgets.FloatText(description='Pad (inch)', @@ -2069,8 +2069,8 @@ def features_options(toggle_show_default=True, toggle_show_visible=True): tmp['LBP'] = lbp tmp['Gradient'] = gradient tmp['None'] = no_op - feature = ipywidgets.RadioButtons(value=no_op, values=tmp, - description='Feature type:') + feature = ipywidgets.RadioButtons(default_value=no_op, values=tmp, + description='Feature type:') # feature-related options hog_options_wid = hog_options(toggle_show_default=True, diff --git a/menpo/visualize/widgets/tools.py b/menpo/visualize/widgets/tools.py index a19fde4c8..c1168c339 100644 --- a/menpo/visualize/widgets/tools.py +++ b/menpo/visualize/widgets/tools.py @@ -406,22 +406,22 @@ def colour_selection(default_colour_list, plot_function=None, title='Colour', else: for k, l in enumerate(labels): labels_dict[l] = k - selection = ipywidgets.Dropdown(values=labels_dict, value=0) + selection = ipywidgets.Dropdown(values=labels_dict, default_value=0) apply_to_all = ipywidgets.Button(description='apply to all labels') labels_wid = ipywidgets.Box(children=[selection, apply_to_all], - visible=multiple) + visible=multiple) # find default values default_colour, r_val, g_val, b_val = _decode_colour(default_colour_list[0]) # create widgets r_wid = ipywidgets.BoundedFloatText(value=r_val, description='RGB', - min=0.0, - max=1.0) + min=0.0, + max=1.0) g_wid = ipywidgets.BoundedFloatText(value=g_val, min=0.0, max=1.0) b_wid = ipywidgets.BoundedFloatText(value=b_val, min=0.0, max=1.0) - menu = ipywidgets.Dropdown(values=colour_dict, value=default_colour, - description='') + menu = ipywidgets.Dropdown(values=colour_dict, default_value=default_colour, + description='') rgb = ipywidgets.Box(children=[r_wid, g_wid, b_wid]) if multiple: @@ -846,9 +846,8 @@ def line_options(line_options_default, plot_function=None, line_style_dict['dash-dot'] = '-.' line_style_dict['dotted'] = ':' line_style = ipywidgets.Dropdown(values=line_style_dict, - value=line_options_default[ - 'line_style'], - description='Style') + default_value=line_options_default['line_style'], + description='Style') line_colour = colour_selection(line_options_default['line_colour'], title='Colour', labels=labels, plot_function=plot_function) @@ -1074,8 +1073,8 @@ def marker_options(marker_options_default, plot_function=None, # Create widgets # toggle button but = ipywidgets.ToggleButton(description=toggle_title, - value=toggle_show_default, - visible=toggle_show_visible) + value=toggle_show_default, + visible=toggle_show_visible) # marker_size, marker_edge_width, marker_style, marker_face_colour, # marker_edge_colour @@ -1110,9 +1109,9 @@ def marker_options(marker_options_default, plot_function=None, marker_style_dict['diamond'] = 'D' marker_style_dict['thin diamond'] = 'd' marker_style = ipywidgets.Dropdown(values=marker_style_dict, - value=marker_options_default[ + default_value=marker_options_default[ 'marker_style'], - description='Style') + description='Style') marker_face_colour = colour_selection( marker_options_default['marker_face_colour'], title='Face Colour', plot_function=plot_function) @@ -1398,7 +1397,8 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_font_name_dict['monospace'] = 'monospace' numbers_font_name = ipywidgets.Dropdown( values=numbers_font_name_dict, - value=numbers_options_default['numbers_font_name'], description='Font') + default_value=numbers_options_default['numbers_font_name'], + description='Font') numbers_font_size = ipywidgets.BoundedIntText( description='Size', value=numbers_options_default['numbers_font_size'], min=2) @@ -1408,7 +1408,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_font_style_dict['oblique'] = 'oblique' numbers_font_style = ipywidgets.Dropdown( values=numbers_font_style_dict, - value=numbers_options_default['numbers_font_style'], + default_value=numbers_options_default['numbers_font_style'], description='Style') numbers_font_weight_dict = OrderedDict() numbers_font_weight_dict['normal'] = 'normal' @@ -1427,7 +1427,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_font_weight_dict['black'] = 'black' numbers_font_weight = ipywidgets.Dropdown( values=numbers_font_weight_dict, - value=numbers_options_default['numbers_font_weight'], + default_value=numbers_options_default['numbers_font_weight'], description='Weight') numbers_font_colour = colour_selection( numbers_options_default['numbers_font_colour'], title='Colour', @@ -1438,7 +1438,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_horizontal_align_dict['left'] = 'left' numbers_horizontal_align = ipywidgets.Dropdown( values=numbers_horizontal_align_dict, - value=numbers_options_default['numbers_horizontal_align'], + default_value=numbers_options_default['numbers_horizontal_align'], description='Align hor.') numbers_vertical_align_dict = OrderedDict() numbers_vertical_align_dict['center'] = 'center' @@ -1447,7 +1447,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_vertical_align_dict['baseline'] = 'baseline' numbers_vertical_align = ipywidgets.Dropdown( values=numbers_vertical_align_dict, - value=numbers_options_default['numbers_vertical_align'], + default_value=numbers_options_default['numbers_vertical_align'], description='Align ver.') # Options widget @@ -1761,7 +1761,8 @@ def figure_options(figure_options_default, plot_function=None, axes_font_name_dict['monospace'] = 'monospace' axes_font_name = ipywidgets.Dropdown( values=axes_font_name_dict, - value=figure_options_default['axes_font_name'], description='Font', + default_value=figure_options_default['axes_font_name'], + description='Font', visible=axes_visible) axes_font_size = ipywidgets.BoundedIntText( description='Size', value=figure_options_default['axes_font_size'], @@ -1772,7 +1773,7 @@ def figure_options(figure_options_default, plot_function=None, axes_font_style_dict['oblique'] = 'oblique' axes_font_style = ipywidgets.Dropdown( values=axes_font_style_dict, - value=figure_options_default['axes_font_style'], + default_value=figure_options_default['axes_font_style'], description='Style', visible=axes_visible) axes_font_weight_dict = OrderedDict() axes_font_weight_dict['normal'] = 'normal' @@ -1791,7 +1792,7 @@ def figure_options(figure_options_default, plot_function=None, axes_font_weight_dict['black'] = 'black' axes_font_weight = ipywidgets.Dropdown( values=axes_font_weight_dict, - value=figure_options_default['axes_font_weight'], + default_value=figure_options_default['axes_font_weight'], description='Weight', visible=axes_visible) if figure_options_default['axes_x_limits'] is None: tmp1 = False @@ -2205,7 +2206,8 @@ def figure_options_two_scales(figure_options_default, plot_function=None, axes_font_name_dict['monospace'] = 'monospace' axes_font_name = ipywidgets.Dropdown( values=axes_font_name_dict, - value=figure_options_default['axes_font_name'], description='Font', + default_value=figure_options_default['axes_font_name'], + description='Font', visible=axes_visible) axes_font_size = ipywidgets.BoundedIntText( description='Size', value=figure_options_default['axes_font_size'], @@ -2216,7 +2218,7 @@ def figure_options_two_scales(figure_options_default, plot_function=None, axes_font_style_dict['oblique'] = 'oblique' axes_font_style = ipywidgets.Dropdown( values=axes_font_style_dict, - value=figure_options_default['axes_font_style'], + default_value=figure_options_default['axes_font_style'], description='Style', visible=axes_visible) axes_font_weight_dict = OrderedDict() axes_font_weight_dict['normal'] = 'normal' @@ -2235,7 +2237,7 @@ def figure_options_two_scales(figure_options_default, plot_function=None, axes_font_weight_dict['black'] = 'black' axes_font_weight = ipywidgets.Dropdown( values=axes_font_weight_dict, - value=figure_options_default['axes_font_weight'], + default_value=figure_options_default['axes_font_weight'], description='Weight', visible=axes_visible) if figure_options_default['axes_x_limits'] is None: tmp1 = False @@ -2656,7 +2658,8 @@ def legend_options(legend_options_default, plot_function=None, legend_font_name_dict['monospace'] = 'monospace' legend_font_name = ipywidgets.Dropdown( values=legend_font_name_dict, - value=legend_options_default['legend_font_name'], description='Font') + default_value=legend_options_default['legend_font_name'], + description='Font') legend_font_size = ipywidgets.BoundedIntText( description='Size', value=legend_options_default['legend_font_size'], min=0) @@ -2666,7 +2669,8 @@ def legend_options(legend_options_default, plot_function=None, legend_font_style_dict['oblique'] = 'oblique' legend_font_style = ipywidgets.Dropdown( values=legend_font_style_dict, - value=legend_options_default['legend_font_style'], description='Style') + default_value=legend_options_default['legend_font_style'], + description='Style') legend_font_weight_dict = OrderedDict() legend_font_weight_dict['normal'] = 'normal' legend_font_weight_dict['ultralight'] = 'ultralight' @@ -2684,7 +2688,7 @@ def legend_options(legend_options_default, plot_function=None, legend_font_weight_dict['black'] = 'black' legend_font_weight = ipywidgets.Dropdown( values=legend_font_weight_dict, - value=legend_options_default['legend_font_weight'], + default_value=legend_options_default['legend_font_weight'], description='Weight') legend_title = ipywidgets.Text(description='Title', value=legend_options_default[ @@ -2712,7 +2716,7 @@ def legend_options(legend_options_default, plot_function=None, legend_location_dict['center'] = 10 legend_location = ipywidgets.Dropdown( values=legend_location_dict, - value=legend_options_default['legend_location'], + default_value=legend_options_default['legend_location'], description='Predefined location') if legend_options_default['legend_bbox_to_anchor'] is None: tmp1 = False @@ -3294,7 +3298,8 @@ def grid_options(grid_options_default, plot_function=None, grid_line_style_dict['dotted'] = ':' grid_line_style = ipywidgets.Dropdown( values=grid_line_style_dict, - value=grid_options_default['grid_line_style'], description='Style') + default_value=grid_options_default['grid_line_style'], + description='Style') # Options widget all_grid_options = ipywidgets.Box( @@ -3482,31 +3487,31 @@ def hog_options(toggle_show_default=True, toggle_show_visible=True): padding = ipywidgets.Checkbox(value=True, description='Padding') mode_wid = ipywidgets.Box(children=[mode, padding]) window_height = ipywidgets.BoundedIntText(value='1', - description='Height', min=1) + description='Height', min=1) window_width = ipywidgets.BoundedIntText(value='1', - description='Width', min=1) + description='Width', min=1) tmp = OrderedDict() tmp['Blocks'] = 'blocks' tmp['Pixels'] = 'pixels' window_size_unit = ipywidgets.RadioButtons(values=tmp, - description=' Size unit') + description=' Size unit') window_size_wid = ipywidgets.Box( children=[window_height, window_width, window_size_unit]) window_vertical = ipywidgets.BoundedIntText(value='1', - description='Step Y', - min=1) + description='Step Y', + min=1) window_horizontal = ipywidgets.BoundedIntText(value='1', - description='Step X', - min=1) + description='Step X', + min=1) tmp = OrderedDict() tmp['Pixels'] = 'pixels' tmp['Cells'] = 'cells' window_step_unit = ipywidgets.RadioButtons(values=tmp, - description='Step unit') + description='Step unit') window_step_wid = ipywidgets.Box(children=[window_vertical, - window_horizontal, - window_step_unit]) + window_horizontal, + window_step_unit]) window_wid = ipywidgets.Box( children=[window_size_wid, window_step_wid]) window_wid = ipywidgets.Box(children=[mode_wid, window_wid]) @@ -3515,8 +3520,8 @@ def hog_options(toggle_show_default=True, toggle_show_visible=True): tmp = OrderedDict() tmp['Dalal & Triggs'] = 'dalaltriggs' tmp['Zhu & Ramanan'] = 'zhuramanan' - algorithm = ipywidgets.RadioButtons(values=tmp, value='dalaltriggs', - description='Algorithm') + algorithm = ipywidgets.RadioButtons(values=tmp, default_value='dalaltriggs', + description='Algorithm') cell_size = ipywidgets.BoundedIntText( value='8', description='Cell size (in pixels)', min=1) block_size = ipywidgets.BoundedIntText( @@ -3527,13 +3532,13 @@ def hog_options(toggle_show_default=True, toggle_show_visible=True): children=[cell_size, block_size, num_bins]) signed_gradient = ipywidgets.Checkbox(value=True, - description='Signed gradients') + description='Signed gradients') l2_norm_clipping = ipywidgets.BoundedFloatText( value='0.2', description='L2 norm clipping', min=0.) algorithm_other = ipywidgets.Box(children=[signed_gradient, - l2_norm_clipping]) + l2_norm_clipping]) algorithm_options = ipywidgets.Box(children=[algorithm_sizes, - algorithm_other]) + algorithm_other]) algorithm_wid = ipywidgets.Box( children=[algorithm, algorithm_options]) @@ -3758,28 +3763,28 @@ def daisy_options(toggle_show_default=True, toggle_show_visible=True): import IPython.html.widgets as ipywidgets # Toggle button that controls options' visibility but = ipywidgets.ToggleButton(description='Daisy Options', - value=toggle_show_default, - visible=toggle_show_visible) + value=toggle_show_default, + visible=toggle_show_visible) # options widgets step = ipywidgets.BoundedIntText(value='1', description='Step', min=1) radius = ipywidgets.BoundedIntText(value='15', description='Radius', - min=1) + min=1) rings = ipywidgets.BoundedIntText(value='2', description='Rings', - min=1) + min=1) histograms = ipywidgets.BoundedIntText(value='2', - description='Histograms', - min=1) + description='Histograms', + min=1) orientations = ipywidgets.BoundedIntText(value='8', - description='Orientations', - min=1) + description='Orientations', + min=1) tmp = OrderedDict() tmp['L1'] = 'l1' tmp['L2'] = 'l2' tmp['Daisy'] = 'daisy' tmp['None'] = None - normalization = ipywidgets.Dropdown(value='l1', values=tmp, - description='Normalization') + normalization = ipywidgets.Dropdown(default_value='l1', values=tmp, + description='Normalization') sigmas = ipywidgets.Text(description='Sigmas') ring_radii = ipywidgets.Text(description='Ring radii') @@ -3947,13 +3952,11 @@ def lbp_options(toggle_show_default=True, toggle_show_visible=True): tmp['Rotation-Invariant'] = 'ri' tmp['Both'] = 'riu2' tmp['None'] = 'none' - mapping_type = ipywidgets.Dropdown(value='u2', values=tmp, - description='Mapping') + mapping_type = ipywidgets.Dropdown(default_value='u2', values=tmp, + description='Mapping') radius = ipywidgets.Text(value='1, 2, 3, 4', description='Radius') samples = ipywidgets.Text(value='8, 8, 8, 8', description='Samples') - algorithm_wid = ipywidgets.Box(children=[radius, - samples, - mapping_type]) + algorithm_wid = ipywidgets.Box(children=[radius, samples, mapping_type]) # window related options window_vertical = ipywidgets.BoundedIntText(value='1', @@ -3966,12 +3969,10 @@ def lbp_options(toggle_show_default=True, toggle_show_visible=True): tmp['Pixels'] = 'pixels' tmp['Windows'] = 'cells' window_step_unit = ipywidgets.RadioButtons(values=tmp, - description='Step unit') + description='Step unit') padding = ipywidgets.Checkbox(value=True, description='Padding') - window_wid = ipywidgets.Box(children=[window_vertical, - window_horizontal, - window_step_unit, - padding]) + window_wid = ipywidgets.Box(children=[window_vertical, window_horizontal, + window_step_unit, padding]) # options widget options = ipywidgets.Box(children=[window_wid, algorithm_wid]) From 14fb0f54af3e0c85aa4b42b84e9da2d5296435ee Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 4 Mar 2015 14:37:22 +0000 Subject: [PATCH 3/8] Removing usages of set_css --- menpo/visualize/widgets/options.py | 98 +++++----- menpo/visualize/widgets/tools.py | 298 +++++++++++++---------------- 2 files changed, 174 insertions(+), 222 deletions(-) diff --git a/menpo/visualize/widgets/options.py b/menpo/visualize/widgets/options.py index 613b72930..0ff007fc9 100644 --- a/menpo/visualize/widgets/options.py +++ b/menpo/visualize/widgets/options.py @@ -379,7 +379,7 @@ def format_channel_options(channel_options_wid, container_padding='6px', channel_options_wid.children[1].children[1].children[1].children[ 1].children[1].add_class('hbox') channel_options_wid.children[1].children[1].children[1].children[ - 1].children[1].children[0].set_css('width', '0.8cm') + 1].children[1].children[0].width = '0.8cm' # align sum and glyph checkboxes channel_options_wid.children[1].children[1].children[1].remove_class('vbox') @@ -391,14 +391,13 @@ def format_channel_options(channel_options_wid, container_padding='6px', channel_options_wid.children[1].add_class('align-start') # set toggle button font bold - channel_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + channel_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - channel_options_wid.set_css('padding', container_padding) - channel_options_wid.set_css('margin', container_margin) + channel_options_wid.padding = container_padding + channel_options_wid.margin = container_margin if border_visible: - channel_options_wid.set_css('border', container_border) + channel_options_wid.border = container_border def update_channel_options(channel_options_wid, n_channels, image_is_masked, @@ -724,25 +723,23 @@ def format_landmark_options(landmark_options_wid, container_padding='6px', landmark_options_wid.children[2].children[1].children[1].add_class('hbox') # align labels buttons with text - landmark_options_wid.children[2].children[1].children[0].set_css( - 'margin-right', '5px') + landmark_options_wid.children[2].children[1].children[0].margin_right = '5px' landmark_options_wid.children[2].children[1].remove_class('vbox') landmark_options_wid.children[2].children[1].add_class('hbox') landmark_options_wid.children[2].children[1].add_class('align-center') # align group drop down menu with labels toggle buttons - landmark_options_wid.children[2].children[1].set_css('margin-top', '10px') + landmark_options_wid.children[2].children[1].margin_top = '10px' landmark_options_wid.children[2].add_class('align-start') # set toggle button font bold - landmark_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + landmark_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - landmark_options_wid.set_css('padding', container_padding) - landmark_options_wid.set_css('margin', container_margin) + landmark_options_wid.padding = container_padding + landmark_options_wid.margin = container_margin if border_visible: - landmark_options_wid.set_css('border', container_border) + landmark_options_wid.border = container_border def update_landmark_options(landmark_options_wid, group_keys, labels_keys, @@ -989,22 +986,22 @@ def format_info_print(info_wid, font_size_in_pt='9pt', container_padding='6px', Defines whether to draw the border line around the widget. """ # text widget formatting - info_wid.children[1].set_css({'border': container_border, - 'padding': '4px', - 'margin-top': '1px'}) + info_wid.children[1].border = container_border + info_wid.children[1].padding = '4px' + info_wid.children[1].margin_top = '1px' # set font size for w in info_wid.children[1].children: - w.set_css({'font-size': font_size_in_pt}) + w.font_size = font_size_in_pt # set toggle button font bold - info_wid.children[0].set_css('font-weight', toggle_button_font_weight) + info_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - info_wid.set_css('padding', container_padding) - info_wid.set_css('margin', container_margin) + info_wid.padding = container_padding + info_wid.margin = container_margin if border_visible: - info_wid.set_css('border', container_border) + info_wid.border = container_border def animation_options(index_selection_default, plot_function=None, @@ -1284,8 +1281,8 @@ def format_animation_options(animation_options_wid, index_text_width='0.5cm', animation_options_wid.children[1].children[1].add_class('align-end') # add margin on the right of the play button - animation_options_wid.children[1].children[1].children[0].children[1]. \ - set_css('margin-right', container_margin) + animation_options_wid.children[1].children[1]. \ + children[0].children[1].margin_right = container_margin if animation_options_wid.index_style == 'slider': # align animation on the right of slider @@ -1295,22 +1292,20 @@ def format_animation_options(animation_options_wid, index_text_width='0.5cm', animation_options_wid.children[1].remove_class('vbox') animation_options_wid.children[1].add_class('hbox') animation_options_wid.children[1].add_class('align-center') - animation_options_wid.children[1].children[0].set_css('margin-right', - '1cm') + animation_options_wid.children[1].children[0].margin_right = '1cm' # set interval width animation_options_wid.children[1].children[1].children[1].children[0]. \ - set_css('width', '20px') + width = '20px' # set toggle button font bold - animation_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + animation_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - animation_options_wid.set_css('padding', container_padding) - animation_options_wid.set_css('margin', container_margin) + animation_options_wid.padding = container_padding + animation_options_wid.margin = container_margin if border_visible: - animation_options_wid.set_css('border', container_border) + animation_options_wid.border = container_border def update_animation_options(animation_options_wid, index_selection_default, @@ -1707,14 +1702,13 @@ def format_viewer_options(viewer_options_wid, container_padding='6px', viewer_options_wid.children[1].children[1].set_title(k, tl) # set toggle button font bold - viewer_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + viewer_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - viewer_options_wid.set_css('padding', container_padding) - viewer_options_wid.set_css('margin', container_margin) + viewer_options_wid.padding = container_padding + viewer_options_wid.margin = container_margin if border_visible: - viewer_options_wid.set_css('border', container_border) + viewer_options_wid.border = container_border def update_viewer_options(viewer_options_wid, viewer_options_default, @@ -1991,7 +1985,7 @@ def format_save_figure_options(save_figure_wid, container_padding='6px', Defines whether to draw the border line around the widget. """ # add margin on top of tabs widget - save_figure_wid.children[1].set_css('margin-top', tab_top_margin) + save_figure_wid.children[1].margin_top = tab_top_margin # align path options to the right save_figure_wid.children[1].children[0].add_class('align-end') @@ -1999,8 +1993,8 @@ def format_save_figure_options(save_figure_wid, container_padding='6px', # align save button and error message horizontally save_figure_wid.children[2].remove_class('vbox') save_figure_wid.children[2].add_class('hbox') - save_figure_wid.children[2].children[1].set_css({'margin-left': '0.5cm', - 'background-color': 'red'}) + save_figure_wid.children[2].children[1].margin_left = '0.5cm' + save_figure_wid.children[2].children[1].background_color = 'red' # set final tab titles tab_titles = ['Path', 'Page setup', 'Image colour'] @@ -2009,18 +2003,17 @@ def format_save_figure_options(save_figure_wid, container_padding='6px', format_colour_selection(save_figure_wid.children[1].children[2].children[0]) format_colour_selection(save_figure_wid.children[1].children[2].children[1]) - save_figure_wid.children[1].children[0].children[0].set_css('width', '6cm') - save_figure_wid.children[1].children[0].children[1].set_css('width', '6cm') + save_figure_wid.children[1].children[0].children[0].width = '6cm' + save_figure_wid.children[1].children[0].children[1].width = '6cm' # set toggle button font bold - save_figure_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + save_figure_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - save_figure_wid.set_css('padding', container_padding) - save_figure_wid.set_css('margin', container_margin) + save_figure_wid.padding = container_padding + save_figure_wid.margin = container_margin if border_visible: - save_figure_wid.set_css('border', container_border) + save_figure_wid.border = container_border def features_options(toggle_show_default=True, toggle_show_visible=True): @@ -2279,17 +2272,16 @@ def format_features_options(features_options_wid, container_padding='6px', features_options_wid.children[1].set_title(k, tl) # set margin above tab widget - features_options_wid.children[1].set_css('margin', '10px') + features_options_wid.children[1].margin = '10px' # set toggle button font bold - features_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + features_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - features_options_wid.set_css('padding', container_padding) - features_options_wid.set_css('margin', container_margin) + features_options_wid.padding = container_padding + features_options_wid.margin = container_margin if border_visible: - features_options_wid.set_css('border', container_border) + features_options_wid.border = container_border def _compare_groups_and_labels(groups1, labels1, groups2, labels2): diff --git a/menpo/visualize/widgets/tools.py b/menpo/visualize/widgets/tools.py index c1168c339..52dba0ac2 100644 --- a/menpo/visualize/widgets/tools.py +++ b/menpo/visualize/widgets/tools.py @@ -58,7 +58,7 @@ def format_logo(logo_wid, container_border='1px solid black', Defines whether to draw the border line around the widget. """ if border_visible: - logo_wid.set_css('border', container_border) + logo_wid.border = container_border def index_selection_slider(index_selection_default, plot_function=None, @@ -253,11 +253,11 @@ def format_index_selection(index_wid, text_width='0.5cm'): index_wid.add_class('align-center') # set text width - index_wid.children[2].set_css('width', text_width) + index_wid.children[2].width = text_width index_wid.children[2].add_class('center') # set margins - index_wid.children[0].set_css('margin-right', '6px') + index_wid.children[0].margin_right = '6px' def update_index_selection(index_wid, index_selection_default, @@ -521,9 +521,9 @@ def format_colour_selection(colour_selection_wid): colour_selection_wid.children[2].add_class('align-start') # set width of r, g, b - colour_selection_wid.children[2].children[0].set_css('width', '0.5cm') - colour_selection_wid.children[2].children[1].set_css('width', '0.5cm') - colour_selection_wid.children[2].children[2].set_css('width', '0.5cm') + colour_selection_wid.children[2].children[0].width = '0.5cm' + colour_selection_wid.children[2].children[1].width = '0.5cm' + colour_selection_wid.children[2].children[2].width = '0.5cm' # align label selection and apply to all button colour_selection_wid.children[0].add_class('align-end') @@ -731,17 +731,16 @@ def format_image_options(image_options_wid, container_padding='6px', Defines whether to draw the border line around the widget. """ # fix alpha slider width - image_options_wid.children[1].children[1].set_css('width', '3cm') + image_options_wid.children[1].children[1].width = '3cm' # set toggle button font bold - image_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + image_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - image_options_wid.set_css('padding', container_padding) - image_options_wid.set_css('margin', container_margin) + image_options_wid.padding = container_padding + image_options_wid.margin = container_margin if border_visible: - image_options_wid.set_css('border', container_border) + image_options_wid.border = container_border def update_image_options(image_options_wid, image_options_dict): @@ -943,25 +942,23 @@ def format_line_options(line_options_wid, container_padding='6px', line_options_wid.children[1].add_class('align-end') # set linewidth text box width - line_options_wid.children[1].children[1].children[1].set_css('width', '1cm') + line_options_wid.children[1].children[1].children[1].width = '1cm' # format colour options format_colour_selection(line_options_wid.children[1].children[1].children[2]) # border around options if suboptions_border_visible: - line_options_wid.children[1].children[1].set_css('border', - container_border) + line_options_wid.children[1].children[1].border = container_border # set toggle button font bold - line_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + line_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - line_options_wid.set_css('padding', container_padding) - line_options_wid.set_css('margin', container_margin) + line_options_wid.padding = container_padding + line_options_wid.margin = container_margin if border_visible: - line_options_wid.set_css('border', container_border) + line_options_wid.border = container_border def update_line_options(line_options_wid, line_options_dict, labels=None): @@ -1226,15 +1223,12 @@ def format_marker_options(marker_options_wid, container_padding='6px', marker_options_wid.children[1].add_class('align-end') # set text boxes width - marker_options_wid.children[1].children[1].children[1].set_css('width', - '1cm') - marker_options_wid.children[1].children[1].children[2].set_css('width', - '1cm') + marker_options_wid.children[1].children[1].children[1].width = '1cm' + marker_options_wid.children[1].children[1].children[2].width = '1cm' # border around options if suboptions_border_visible: - marker_options_wid.children[1].children[1].set_css('border', - container_border) + marker_options_wid.children[1].children[1].border = container_border # format colour options format_colour_selection( @@ -1243,14 +1237,13 @@ def format_marker_options(marker_options_wid, container_padding='6px', marker_options_wid.children[1].children[1].children[4]) # set toggle button font bold - marker_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + marker_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - marker_options_wid.set_css('padding', container_padding) - marker_options_wid.set_css('margin', container_margin) + marker_options_wid.padding = container_padding + marker_options_wid.margin = container_margin if border_visible: - marker_options_wid.set_css('border', container_border) + marker_options_wid.border = container_border def update_marker_options(marker_options_wid, marker_options_dict): @@ -1570,8 +1563,7 @@ def format_numbering_options(numbering_options_wid, container_padding='6px', numbering_options_wid.children[1].add_class('align-end') # set fontsize text box width - numbering_options_wid.children[1].children[1].children[1].set_css('width', - '1cm') + numbering_options_wid.children[1].children[1].children[1].width = '1cm' # format colour options format_colour_selection( @@ -1579,18 +1571,16 @@ def format_numbering_options(numbering_options_wid, container_padding='6px', # border around options if suboptions_border_visible: - numbering_options_wid.children[1].children[1].set_css('border', - container_border) + numbering_options_wid.children[1].children[1].border = container_border # set toggle button font bold - numbering_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + numbering_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - numbering_options_wid.set_css('padding', container_padding) - numbering_options_wid.set_css('margin', container_margin) + numbering_options_wid.padding = container_padding + numbering_options_wid.margin = container_margin if border_visible: - numbering_options_wid.set_css('border', container_border) + numbering_options_wid.border = container_border def update_numbering_options(numbering_options_wid, numbering_options_dict): @@ -1976,32 +1966,31 @@ def format_figure_options(figure_options_wid, container_padding='6px', Defines whether to draw the border line around the widget. """ # fix figure scale slider width - figure_options_wid.children[1].set_css('width', '3cm') + figure_options_wid.children[1].width = '3cm' # fix font size width - figure_options_wid.children[4].set_css('width', '1cm') + figure_options_wid.children[4].width = '1cm' # align and set width of axes_x_limits figure_options_wid.children[7].remove_class('vbox') figure_options_wid.children[7].add_class('hbox') - figure_options_wid.children[7].children[1].set_css('width', '1cm') - figure_options_wid.children[7].children[2].set_css('width', '1cm') + figure_options_wid.children[7].children[1].width = '1cm' + figure_options_wid.children[7].children[2].width = '1cm' # align and set width of axes_y_limits figure_options_wid.children[8].remove_class('vbox') figure_options_wid.children[8].add_class('hbox') - figure_options_wid.children[8].children[1].set_css('width', '1cm') - figure_options_wid.children[8].children[2].set_css('width', '1cm') + figure_options_wid.children[8].children[1].width = '1cm' + figure_options_wid.children[8].children[2].width = '1cm' # set toggle button font bold - figure_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + figure_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - figure_options_wid.set_css('padding', container_padding) - figure_options_wid.set_css('margin', container_margin) + figure_options_wid.padding = container_padding + figure_options_wid.margin = container_margin if border_visible: - figure_options_wid.set_css('border', container_border) + figure_options_wid.border = container_border def update_figure_options(figure_options_wid, figure_options_dict): @@ -2429,33 +2418,32 @@ def format_figure_options_two_scales(figure_options_wid, figure_options_wid.children[1].add_class('align-end') # fix figure scale sliders width - figure_options_wid.children[1].children[0].set_css('width', '3cm') - figure_options_wid.children[1].children[1].set_css('width', '3cm') + figure_options_wid.children[1].children[0].width = '3cm' + figure_options_wid.children[1].children[1].width = '3cm' # fix font size width - figure_options_wid.children[4].set_css('width', '1cm') + figure_options_wid.children[4].width = '1cm' # align and set width of axes_x_limits figure_options_wid.children[7].remove_class('vbox') figure_options_wid.children[7].add_class('hbox') - figure_options_wid.children[7].children[1].set_css('width', '1cm') - figure_options_wid.children[7].children[2].set_css('width', '1cm') + figure_options_wid.children[7].children[1].width = '1cm' + figure_options_wid.children[7].children[2].width = '1cm' # align and set width of axes_y_limits figure_options_wid.children[8].remove_class('vbox') figure_options_wid.children[8].add_class('hbox') - figure_options_wid.children[8].children[1].set_css('width', '1cm') - figure_options_wid.children[8].children[2].set_css('width', '1cm') + figure_options_wid.children[8].children[1].width = '1cm' + figure_options_wid.children[8].children[2].width = '1cm' # set toggle button font bold - figure_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + figure_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - figure_options_wid.set_css('padding', container_padding) - figure_options_wid.set_css('margin', container_margin) + figure_options_wid.padding = container_padding + figure_options_wid.margin = container_margin if border_visible: - figure_options_wid.set_css('border', container_border) + figure_options_wid.border = container_border def update_figure_options_two_scales(figure_options_wid, figure_options_dict): @@ -2968,17 +2956,11 @@ def format_legend_options(legend_options_wid, container_padding='6px', for (k, tl) in enumerate(tab_titles): legend_options_wid.children[1].children[1].set_title(k, tl) - # align font-related options - # legend_options_wid.children[1].children[1].children[1].children[1].\ - # remove_class('vbox') - # legend_options_wid.children[1].children[1].children[1].children[1].\ - # add_class('hbox') - # set fontsize and title text box width legend_options_wid.children[1].children[1].children[1].children[1].children[ - 0].children[1].set_css('width', '1cm') + 0].children[1].width = '1cm' legend_options_wid.children[1].children[1].children[1].children[0]. \ - set_css('width', '4cm') + width = '4cm' # align and set width of bbox_to_anchor legend_options_wid.children[1].children[1].children[0].children[1]. \ @@ -2987,14 +2969,14 @@ def format_legend_options(legend_options_wid, container_padding='6px', add_class('hbox') legend_options_wid.children[1].children[1].children[0].children[1].children[ 1]. \ - set_css('width', '1cm') + width = '1cm' legend_options_wid.children[1].children[1].children[0].children[1].children[ 2]. \ - set_css('width', '1cm') + width = '1cm' # set distance to axes (borderaxespad) text box width legend_options_wid.children[1].children[1].children[0].children[2]. \ - set_css('width', '1cm') + width = '1cm' # align and set width of border options legend_options_wid.children[1].children[1].children[2].children[1]. \ @@ -3003,10 +2985,10 @@ def format_legend_options(legend_options_wid, container_padding='6px', add_class('hbox') legend_options_wid.children[1].children[1].children[2].children[1].children[ 0]. \ - set_css('width', '1cm') + width = '1cm' legend_options_wid.children[1].children[1].children[2].children[1].children[ 1]. \ - set_css('width', '1cm') + width = '1cm' # align shadow and fancy checkboxes legend_options_wid.children[1].children[1].children[2].children[2]. \ @@ -3019,18 +3001,18 @@ def format_legend_options(legend_options_wid, container_padding='6px', 1]. \ add_class('align-end') legend_options_wid.children[1].children[1].children[2].children[0].children[ - 1].children[0].set_css('width', '1cm') + 1].children[0].width = '1cm' legend_options_wid.children[1].children[1].children[2].children[0].children[ - 1].children[1].set_css('width', '1cm') + 1].children[1].width = '1cm' # set width of n_columns and markerspace legend_options_wid.children[1].children[1].children[2].children[0].children[ 0]. \ add_class('align-end') legend_options_wid.children[1].children[1].children[2].children[0].children[ - 0].children[0].set_css('width', '1cm') + 0].children[0].width = '1cm' legend_options_wid.children[1].children[1].children[2].children[0].children[ - 0].children[1].set_css('width', '1cm') + 0].children[1].width = '1cm' # align n_columns with spacing legend_options_wid.children[1].children[1].children[2].children[0]. \ @@ -3040,18 +3022,16 @@ def format_legend_options(legend_options_wid, container_padding='6px', # border around options if suboptions_border_visible: - legend_options_wid.children[1].children[1].set_css('border', - container_border) + legend_options_wid.children[1].children[1].border = container_border # set toggle button font bold - legend_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + legend_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - legend_options_wid.set_css('padding', container_padding) - legend_options_wid.set_css('margin', container_margin) + legend_options_wid.padding = container_padding + legend_options_wid.margin = container_margin if border_visible: - legend_options_wid.set_css('border', container_border) + legend_options_wid.border = container_border def update_legend_options(legend_options_wid, legend_options_dict): @@ -3382,22 +3362,20 @@ def format_grid_options(grid_options_wid, container_padding='6px', grid_options_wid.children[1].add_class('align-end') # set gridlinewidth text box width - grid_options_wid.children[1].children[1].children[1].set_css('width', '1cm') + grid_options_wid.children[1].children[1].children[1].width = '1cm' # border around options if suboptions_border_visible: - grid_options_wid.children[1].children[1].set_css('border', - container_border) + grid_options_wid.children[1].children[1].border = container_border # set toggle button font bold - grid_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + grid_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - grid_options_wid.set_css('padding', container_padding) - grid_options_wid.set_css('margin', container_margin) + grid_options_wid.padding = container_padding + grid_options_wid.margin = container_margin if border_visible: - grid_options_wid.set_css('border', container_border) + grid_options_wid.border = container_border def update_grid_options(grid_options_wid, grid_options_dict): @@ -3677,23 +3655,23 @@ def format_hog_options(hog_options_wid, container_padding='6px', # set width of height, width, step x , step y textboxes hog_options_wid.children[1].children[0].children[1].children[0].children[0]. \ - set_css('width', '40px') + width = '40px' hog_options_wid.children[1].children[0].children[1].children[0].children[1]. \ - set_css('width', '40px') + width = '40px' hog_options_wid.children[1].children[0].children[1].children[1].children[0]. \ - set_css('width', '40px') + width = '40px' hog_options_wid.children[1].children[0].children[1].children[1].children[1]. \ - set_css('width', '40px') + width = '40px' # set margin and border around the window size and step options - hog_options_wid.children[1].children[0].children[1].children[0].set_css( - 'margin', container_margin) - hog_options_wid.children[1].children[0].children[1].children[1].set_css( - 'margin', container_margin) - hog_options_wid.children[1].children[0].children[1].children[0].set_css( - 'border', '1px solid gray') - hog_options_wid.children[1].children[0].children[1].children[1].set_css( - 'border', '1px solid gray') + hog_options_wid.children[1].children[0].children[1].children[0]. \ + margin = container_margin + hog_options_wid.children[1].children[0].children[1].children[1]. \ + margin = container_margin + hog_options_wid.children[1].children[0].children[1].children[0]. \ + border = '1px solid gray' + hog_options_wid.children[1].children[0].children[1].children[1]. \ + border = '1px solid gray' # align mode and padding hog_options_wid.children[1].children[0].children[0].remove_class('vbox') @@ -3701,25 +3679,25 @@ def format_hog_options(hog_options_wid, container_padding='6px', # set width of algorithm textboxes hog_options_wid.children[1].children[1].children[1].children[0].children[0]. \ - set_css('width', '40px') + width = '40px' hog_options_wid.children[1].children[1].children[1].children[0].children[1]. \ - set_css('width', '40px') + width = '40px' hog_options_wid.children[1].children[1].children[1].children[0].children[2]. \ - set_css('width', '40px') + width = '40px' hog_options_wid.children[1].children[1].children[1].children[1].children[1]. \ - set_css('width', '40px') + width = '40px' # align algorithm options hog_options_wid.children[1].children[1].children[1].remove_class('vbox') hog_options_wid.children[1].children[1].children[1].add_class('hbox') # set margin and border around the algorithm options - hog_options_wid.children[1].children[1].children[1].set_css( - 'margin', container_margin) - hog_options_wid.children[1].children[1].children[1].set_css( - 'border', '1px solid gray') + hog_options_wid.children[1].children[1].children[1]. \ + margin = container_margin + hog_options_wid.children[1].children[1].children[1]. \ + border = '1px solid gray' - hog_options_wid.children[1].set_css('margin-top', '6px') + hog_options_wid.children[1].margin_top = '6px' hog_options_wid.children[1].children[0].add_class('align-center') hog_options_wid.children[1].children[1].add_class('align-center') @@ -3729,14 +3707,13 @@ def format_hog_options(hog_options_wid, container_padding='6px', hog_options_wid.children[1].set_title(k, tl) # set toggle button font bold - hog_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + hog_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - hog_options_wid.set_css('padding', container_padding) - hog_options_wid.set_css('margin', container_margin) + hog_options_wid.padding = container_padding + hog_options_wid.margin = container_margin if border_visible: - hog_options_wid.set_css('border', container_border) + hog_options_wid.border = container_border def daisy_options(toggle_show_default=True, toggle_show_visible=True): @@ -3889,34 +3866,26 @@ def format_daisy_options(daisy_options_wid, container_padding='6px', Defines whether to draw the border line around the widget. """ # align window options - daisy_options_wid.children[1].remove_class('vbox') - daisy_options_wid.children[1].add_class('hbox') + daisy_options_wid.children[1]._dom_classes.remove('vbox') + daisy_options_wid.children[1]._dom_classes.append('hbox') # set textboxes length - daisy_options_wid.children[1].children[0].children[0].set_css('width', - '40px') - daisy_options_wid.children[1].children[0].children[1].set_css('width', - '40px') - daisy_options_wid.children[1].children[0].children[2].set_css('width', - '40px') - daisy_options_wid.children[1].children[0].children[3].set_css('width', - '40px') - daisy_options_wid.children[1].children[1].children[0].set_css('width', - '40px') - daisy_options_wid.children[1].children[1].children[2].set_css('width', - '80px') - daisy_options_wid.children[1].children[1].children[3].set_css('width', - '80px') + daisy_options_wid.children[1].children[0].children[0].width = '40px' + daisy_options_wid.children[1].children[0].children[1].width = '40px' + daisy_options_wid.children[1].children[0].children[2].width = '40px' + daisy_options_wid.children[1].children[0].children[3].width = '40px' + daisy_options_wid.children[1].children[1].children[0].width = '40px' + daisy_options_wid.children[1].children[1].children[2].width = '80px' + daisy_options_wid.children[1].children[1].children[3].width = '80px' # set toggle button font bold - daisy_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + daisy_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - daisy_options_wid.set_css('padding', container_padding) - daisy_options_wid.set_css('margin', container_margin) + daisy_options_wid.padding = container_padding + daisy_options_wid.margin = container_margin if border_visible: - daisy_options_wid.set_css('border', container_border) + daisy_options_wid.border = container_border def lbp_options(toggle_show_default=True, toggle_show_visible=True): @@ -4060,24 +4029,19 @@ def format_lbp_options(lbp_options_wid, container_padding='6px', lbp_options_wid.children[1].add_class('hbox') # set textboxes length - lbp_options_wid.children[1].children[0].children[0].set_css('width', - '40px') - lbp_options_wid.children[1].children[0].children[1].set_css('width', - '40px') - lbp_options_wid.children[1].children[1].children[0].set_css('width', - '80px') - lbp_options_wid.children[1].children[1].children[1].set_css('width', - '80px') + lbp_options_wid.children[1].children[0].children[0].width = '40px' + lbp_options_wid.children[1].children[0].children[1].width = '40px' + lbp_options_wid.children[1].children[1].children[0].width = '80px' + lbp_options_wid.children[1].children[1].children[1].width = '80px' # set toggle button font bold - lbp_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + lbp_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - lbp_options_wid.set_css('padding', container_padding) - lbp_options_wid.set_css('margin', container_margin) + lbp_options_wid.padding = container_padding + lbp_options_wid.margin = container_margin if border_visible: - lbp_options_wid.set_css('border', container_border) + lbp_options_wid.border = container_border def igo_options(toggle_show_default=True, toggle_show_visible=True): @@ -4156,14 +4120,13 @@ def format_igo_options(igo_options_wid, container_padding='6px', Defines whether to draw the border line around the widget. """ # set toggle button font bold - igo_options_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + igo_options_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - igo_options_wid.set_css('padding', container_padding) - igo_options_wid.set_css('margin', container_margin) + igo_options_wid.padding = container_padding + igo_options_wid.margin = container_margin if border_visible: - igo_options_wid.set_css('border', container_border) + igo_options_wid.border = container_border def function_definition(default_function='def my_function():\n pass', @@ -4263,25 +4226,22 @@ def format_function_definition(function_definition_wid, container_padding='6px', function_definition_wid.children[1].children[1].add_class('hbox') # set margin between message and button - function_definition_wid.children[1].children[1].children[0].set_css( - 'margin-right', '0.5cm') + function_definition_wid.children[1].children[1].children[0].margin_right = '0.5cm' # align code textarea and button to the right function_definition_wid.children[1].add_class('align-end') # set error message background to red - function_definition_wid.children[1].children[1].children[0].set_css( - 'background', 'red') + function_definition_wid.children[1].children[1].children[0].background = 'red' # set toggle button font bold - function_definition_wid.children[0].set_css('font-weight', - toggle_button_font_weight) + function_definition_wid.children[0].font_weight = toggle_button_font_weight # margin and border around container widget - function_definition_wid.set_css('padding', container_padding) - function_definition_wid.set_css('margin', container_margin) + function_definition_wid.padding = container_padding + function_definition_wid.margin = container_margin if border_visible: - function_definition_wid.set_css('border', container_border) + function_definition_wid.border = container_border class IntListText(): From e00f3f6f46dcf37e6b7fe89ca6ae9a3cd7e04cbf Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 4 Mar 2015 15:50:33 +0000 Subject: [PATCH 4/8] Fix add_class and remove_class They don't exist so add a compatibility module that replicates their functionality. This should mostly be replaced by using the flex box model at some later point. --- menpo/visualize/widgets/base.py | 30 +++--- menpo/visualize/widgets/compatibility.py | 9 ++ menpo/visualize/widgets/options.py | 56 +++++------ menpo/visualize/widgets/tools.py | 115 ++++++++++------------- 4 files changed, 104 insertions(+), 106 deletions(-) create mode 100644 menpo/visualize/widgets/compatibility.py diff --git a/menpo/visualize/widgets/base.py b/menpo/visualize/widgets/base.py index 476ac8c54..47a8b5a16 100644 --- a/menpo/visualize/widgets/base.py +++ b/menpo/visualize/widgets/base.py @@ -13,6 +13,8 @@ features_options, format_features_options, viewer_options, format_viewer_options) from .tools import logo, format_logo +from .compatibility import add_class, remove_class + # This glyph import is called frequently during visualisation, so we ensure # that we only import it once @@ -200,12 +202,12 @@ def update_info(pointcloud): # align-start the pointcloud number widget and the rest if n_pointclouds > 1: - wid.add_class('align-start') + add_class(wid, 'align-start') # format options' widgets if n_pointclouds > 1: - wid.children[0].remove_class('vbox') - wid.children[0].add_class('hbox') + remove_class(wid.children[0], 'vbox') + add_class(wid.children[0], 'hbox') format_animation_options(pointcloud_number_wid, index_text_width='1.0cm', container_padding='6px', @@ -541,12 +543,12 @@ def update_widgets(name, value): # align-start the image number widget and the rest if n_landmarkgroups > 1: - wid.add_class('align-start') + add_class(wid, 'align-start') # format options' widgets if n_landmarkgroups > 1: - wid.children[0].remove_class('vbox') - wid.children[0].add_class('hbox') + remove_class(wid.children[0], 'vbox') + add_class(wid.children[0], 'hbox') format_animation_options(landmark_number_wid, index_text_width='1.0cm', container_padding='6px', container_margin='6px', @@ -907,7 +909,7 @@ def update_widgets(name, value): # align-start the image number widget and the rest if n_landmarks > 1: - wid.add_class('align-start') + add_class(wid, 'align-start') # update viewer options def update_viewer_options(name, value): @@ -919,8 +921,8 @@ def update_viewer_options(name, value): # format options' widgets if n_landmarks > 1: - wid.children[0].remove_class('vbox') - wid.children[0].add_class('hbox') + remove_class(wid.children[0], 'vbox') + add_class(wid.children[0], 'hbox') format_animation_options(landmark_number_wid, index_text_width='1.0cm', container_padding='6px', container_margin='6px', @@ -1312,12 +1314,12 @@ def update_viewer_options(name, value): # align-start the image number widget and the rest if n_images > 1: - wid.add_class('align-start') + add_class(wid, 'align-start') # format options' widgets if n_images > 1: - wid.children[0].remove_class('vbox') - wid.children[0].add_class('hbox') + remove_class(wid.children[0], 'vbox') + add_class(wid.children[0], 'hbox') format_animation_options(image_number_wid, index_text_width='1.0cm', container_padding='6px', container_margin='6px', @@ -1431,9 +1433,9 @@ def select_function(name): format_features_options(features_options_wid, border_visible=True) format_logo(logo_wid, border_visible=False) # align logo at the end - features_wid.add_class('align-end') + add_class(features_wid, 'align-end') # align select button at the centre - wid.add_class('align-center') + add_class(wid, 'align-center') # Initialize output with empty list. It needs to be a list so that # it's mutable and synchronizes with frontend. diff --git a/menpo/visualize/widgets/compatibility.py b/menpo/visualize/widgets/compatibility.py new file mode 100644 index 000000000..73030859e --- /dev/null +++ b/menpo/visualize/widgets/compatibility.py @@ -0,0 +1,9 @@ +def add_class(widget, class_name): + widget._dom_classes += (class_name,) + + +def remove_class(widget, class_name): + new_class_list = list(widget._dom_classes) + if class_name in new_class_list: + new_class_list.remove(class_name) + widget._dom_classes = tuple(new_class_list) diff --git a/menpo/visualize/widgets/options.py b/menpo/visualize/widgets/options.py index 0ff007fc9..0e64313c5 100644 --- a/menpo/visualize/widgets/options.py +++ b/menpo/visualize/widgets/options.py @@ -23,6 +23,7 @@ legend_options, format_legend_options, update_legend_options, image_options, format_image_options, update_image_options) +from .compatibility import add_class, remove_class def channel_options(channels_options_default, plot_function=None, @@ -374,21 +375,21 @@ def format_channel_options(channel_options_wid, container_padding='6px', Defines whether to draw the border line around the widget. """ # align glyph options - channel_options_wid.children[1].children[1].children[1].children[ - 1].children[1].remove_class('vbox') - channel_options_wid.children[1].children[1].children[1].children[ - 1].children[1].add_class('hbox') + remove_class(channel_options_wid.children[1]. + children[1].children[1].children[1].children[1], 'vbox') + add_class(channel_options_wid.children[1]. + children[1].children[1].children[1].children[1], 'hbox') channel_options_wid.children[1].children[1].children[1].children[ 1].children[1].children[0].width = '0.8cm' # align sum and glyph checkboxes - channel_options_wid.children[1].children[1].children[1].remove_class('vbox') - channel_options_wid.children[1].children[1].children[1].add_class('hbox') + remove_class(channel_options_wid.children[1].children[1].children[1], 'vbox') + add_class(channel_options_wid.children[1].children[1].children[1], 'hbox') # align radio buttons with the rest - channel_options_wid.children[1].remove_class('vbox') - channel_options_wid.children[1].add_class('hbox') - channel_options_wid.children[1].add_class('align-start') + remove_class(channel_options_wid.children[1], 'vbox') + add_class(channel_options_wid.children[1], 'hbox') + add_class(channel_options_wid.children[1], 'align-start') # set toggle button font bold channel_options_wid.children[0].font_weight = toggle_button_font_weight @@ -719,18 +720,18 @@ def format_landmark_options(landmark_options_wid, container_padding='6px', Defines whether to draw the border line around the widget. """ # align labels toggle buttons - landmark_options_wid.children[2].children[1].children[1].remove_class('vbox') - landmark_options_wid.children[2].children[1].children[1].add_class('hbox') + remove_class(landmark_options_wid.children[2].children[1].children[1], 'vbox') + add_class(landmark_options_wid.children[2].children[1].children[1], 'hbox') # align labels buttons with text landmark_options_wid.children[2].children[1].children[0].margin_right = '5px' - landmark_options_wid.children[2].children[1].remove_class('vbox') - landmark_options_wid.children[2].children[1].add_class('hbox') - landmark_options_wid.children[2].children[1].add_class('align-center') + remove_class(landmark_options_wid.children[2].children[1], 'vbox') + add_class(landmark_options_wid.children[2].children[1], 'hbox') + add_class(landmark_options_wid.children[2].children[1], 'align-center') # align group drop down menu with labels toggle buttons landmark_options_wid.children[2].children[1].margin_top = '10px' - landmark_options_wid.children[2].add_class('align-start') + add_class(landmark_options_wid.children[2], 'align-start') # set toggle button font bold landmark_options_wid.children[0].font_weight = toggle_button_font_weight @@ -1275,10 +1276,9 @@ def format_animation_options(animation_options_wid, index_text_width='0.5cm', text_width=index_text_width) # align play/stop button with animation options button - animation_options_wid.children[1].children[1].children[0].remove_class( - 'vbox') - animation_options_wid.children[1].children[1].children[0].add_class('hbox') - animation_options_wid.children[1].children[1].add_class('align-end') + remove_class(animation_options_wid.children[1].children[1].children[0], 'vbox') + add_class(animation_options_wid.children[1].children[1].children[0], 'hbox') + add_class(animation_options_wid.children[1].children[1], 'align-end') # add margin on the right of the play button animation_options_wid.children[1].children[1]. \ @@ -1286,12 +1286,12 @@ def format_animation_options(animation_options_wid, index_text_width='0.5cm', if animation_options_wid.index_style == 'slider': # align animation on the right of slider - animation_options_wid.children[1].add_class('align-end') + add_class(animation_options_wid.children[1], 'align-end') else: # align animation and index buttons - animation_options_wid.children[1].remove_class('vbox') - animation_options_wid.children[1].add_class('hbox') - animation_options_wid.children[1].add_class('align-center') + remove_class(animation_options_wid.children[1], 'vbox') + add_class(animation_options_wid.children[1], 'hbox') + add_class(animation_options_wid.children[1], 'align-center') animation_options_wid.children[1].children[0].margin_right = '1cm' # set interval width @@ -1472,8 +1472,8 @@ def viewer_options(viewer_options_default, options_tabs, objects_names=None, # Create widgets # toggle button but = ipywidgets.ToggleButton(description='Viewer Options', - value=toggle_show_default, - visible=toggle_show_visible) + value=toggle_show_default, + visible=toggle_show_visible) # select object drop down menu objects_dict = OrderedDict() @@ -1988,11 +1988,11 @@ def format_save_figure_options(save_figure_wid, container_padding='6px', save_figure_wid.children[1].margin_top = tab_top_margin # align path options to the right - save_figure_wid.children[1].children[0].add_class('align-end') + add_class(save_figure_wid.children[1].children[0], 'align-end') # align save button and error message horizontally - save_figure_wid.children[2].remove_class('vbox') - save_figure_wid.children[2].add_class('hbox') + remove_class(save_figure_wid.children[2], 'vbox') + add_class(save_figure_wid.children[2], 'hbox') save_figure_wid.children[2].children[1].margin_left = '0.5cm' save_figure_wid.children[2].children[1].background_color = 'red' diff --git a/menpo/visualize/widgets/tools.py b/menpo/visualize/widgets/tools.py index 52dba0ac2..b339542e7 100644 --- a/menpo/visualize/widgets/tools.py +++ b/menpo/visualize/widgets/tools.py @@ -4,6 +4,8 @@ except ImportError: from io import StringIO +from .compatibility import add_class, remove_class + # Global variables to try and reduce overhead of loading the logo MENPO_LOGO = None @@ -248,13 +250,13 @@ def format_index_selection(index_wid, text_width='0.5cm'): if not isinstance(index_wid, ipywidgets.IntSlider): # align all widgets - index_wid.remove_class('vbox') - index_wid.add_class('hbox') - index_wid.add_class('align-center') + remove_class(index_wid, 'vbox') + add_class(index_wid, 'hbox') + add_class(index_wid, 'align-center') # set text width index_wid.children[2].width = text_width - index_wid.children[2].add_class('center') + add_class(index_wid.children[2], 'center') # set margins index_wid.children[0].margin_right = '6px' @@ -513,12 +515,12 @@ def format_colour_selection(colour_selection_wid): The widget object generated by the `colour_selection()` function. """ # align selection container and colour - colour_selection_wid.add_class('align-end') + add_class(colour_selection_wid, 'align-end') # align r, g, b values - colour_selection_wid.children[2].remove_class('vbox') - colour_selection_wid.children[2].add_class('hbox') - colour_selection_wid.children[2].add_class('align-start') + remove_class(colour_selection_wid.children[2], 'vbox') + add_class(colour_selection_wid.children[2], 'hbox') + add_class(colour_selection_wid.children[2], 'align-start') # set width of r, g, b colour_selection_wid.children[2].children[0].width = '0.5cm' @@ -526,7 +528,7 @@ def format_colour_selection(colour_selection_wid): colour_selection_wid.children[2].children[2].width = '0.5cm' # align label selection and apply to all button - colour_selection_wid.children[0].add_class('align-end') + add_class(colour_selection_wid.children[0], 'align-end') def update_colour_selection(colour_selection_wid, default_colour_list, @@ -939,7 +941,7 @@ def format_line_options(line_options_wid, container_padding='6px', the show line checkbox. """ # align line options with checkbox - line_options_wid.children[1].add_class('align-end') + add_class(line_options_wid.children[1], 'align-end') # set linewidth text box width line_options_wid.children[1].children[1].children[1].width = '1cm' @@ -1220,7 +1222,7 @@ def format_marker_options(marker_options_wid, container_padding='6px', the show marker checkbox. """ # align marker options with checkbox - marker_options_wid.children[1].add_class('align-end') + add_class(marker_options_wid.children[1], 'align-end') # set text boxes width marker_options_wid.children[1].children[1].children[1].width = '1cm' @@ -1560,7 +1562,7 @@ def format_numbering_options(numbering_options_wid, container_padding='6px', the show font checkbox. """ # align font options with checkbox - numbering_options_wid.children[1].add_class('align-end') + add_class(numbering_options_wid.children[1], 'align-end') # set fontsize text box width numbering_options_wid.children[1].children[1].children[1].width = '1cm' @@ -1972,14 +1974,14 @@ def format_figure_options(figure_options_wid, container_padding='6px', figure_options_wid.children[4].width = '1cm' # align and set width of axes_x_limits - figure_options_wid.children[7].remove_class('vbox') - figure_options_wid.children[7].add_class('hbox') + remove_class(figure_options_wid.children[7], 'vbox') + add_class(figure_options_wid.children[7], 'hbox') figure_options_wid.children[7].children[1].width = '1cm' figure_options_wid.children[7].children[2].width = '1cm' # align and set width of axes_y_limits - figure_options_wid.children[8].remove_class('vbox') - figure_options_wid.children[8].add_class('hbox') + remove_class(figure_options_wid.children[8], 'vbox') + add_class(figure_options_wid.children[8], 'hbox') figure_options_wid.children[8].children[1].width = '1cm' figure_options_wid.children[8].children[2].width = '1cm' @@ -2414,8 +2416,8 @@ def format_figure_options_two_scales(figure_options_wid, """ # align figure scale sliders and checkbox # figure_options_wid.children[1].remove_class('vbox') - # figure_options_wid.children[1].add_class('hbox') - figure_options_wid.children[1].add_class('align-end') + # add_class(figure_options_wid.children[1], 'hbox') + add_class(figure_options_wid.children[1], 'align-end') # fix figure scale sliders width figure_options_wid.children[1].children[0].width = '3cm' @@ -2425,14 +2427,14 @@ def format_figure_options_two_scales(figure_options_wid, figure_options_wid.children[4].width = '1cm' # align and set width of axes_x_limits - figure_options_wid.children[7].remove_class('vbox') - figure_options_wid.children[7].add_class('hbox') + remove_class(figure_options_wid.children[7], 'vbox') + add_class(figure_options_wid.children[7], 'hbox') figure_options_wid.children[7].children[1].width = '1cm' figure_options_wid.children[7].children[2].width = '1cm' # align and set width of axes_y_limits - figure_options_wid.children[8].remove_class('vbox') - figure_options_wid.children[8].add_class('hbox') + remove_class(figure_options_wid.children[8], 'vbox') + add_class(figure_options_wid.children[8], 'hbox') figure_options_wid.children[8].children[1].width = '1cm' figure_options_wid.children[8].children[2].width = '1cm' @@ -2957,21 +2959,16 @@ def format_legend_options(legend_options_wid, container_padding='6px', legend_options_wid.children[1].children[1].set_title(k, tl) # set fontsize and title text box width - legend_options_wid.children[1].children[1].children[1].children[1].children[ - 0].children[1].width = '1cm' + legend_options_wid.children[1].children[1].children[1].children[1].children[0].children[1].width = '1cm' legend_options_wid.children[1].children[1].children[1].children[0]. \ width = '4cm' # align and set width of bbox_to_anchor - legend_options_wid.children[1].children[1].children[0].children[1]. \ - remove_class('vbox') - legend_options_wid.children[1].children[1].children[0].children[1]. \ - add_class('hbox') - legend_options_wid.children[1].children[1].children[0].children[1].children[ - 1]. \ + remove_class(legend_options_wid.children[1].children[1].children[0].children[1], 'vbox') + add_class(legend_options_wid.children[1].children[1].children[0].children[1], 'hbox') + legend_options_wid.children[1].children[1].children[0].children[1].children[1]. \ width = '1cm' - legend_options_wid.children[1].children[1].children[0].children[1].children[ - 2]. \ + legend_options_wid.children[1].children[1].children[0].children[1].children[2]. \ width = '1cm' # set distance to axes (borderaxespad) text box width @@ -2979,10 +2976,8 @@ def format_legend_options(legend_options_wid, container_padding='6px', width = '1cm' # align and set width of border options - legend_options_wid.children[1].children[1].children[2].children[1]. \ - remove_class('vbox') - legend_options_wid.children[1].children[1].children[2].children[1]. \ - add_class('hbox') + remove_class(legend_options_wid.children[1].children[1].children[2].children[1], 'vbox') + add_class(legend_options_wid.children[1].children[1].children[2].children[1], 'hbox') legend_options_wid.children[1].children[1].children[2].children[1].children[ 0]. \ width = '1cm' @@ -2991,34 +2986,26 @@ def format_legend_options(legend_options_wid, container_padding='6px', width = '1cm' # align shadow and fancy checkboxes - legend_options_wid.children[1].children[1].children[2].children[2]. \ - remove_class('vbox') - legend_options_wid.children[1].children[1].children[2].children[2]. \ - add_class('hbox') + remove_class(legend_options_wid.children[1].children[1].children[2].children[2], 'vbox') + add_class(legend_options_wid.children[1].children[1].children[2].children[2], 'hbox') # align and set width of spacing options - legend_options_wid.children[1].children[1].children[2].children[0].children[ - 1]. \ - add_class('align-end') + add_class(legend_options_wid.children[1].children[1].children[2].children[0].children[1], 'align-end') legend_options_wid.children[1].children[1].children[2].children[0].children[ 1].children[0].width = '1cm' legend_options_wid.children[1].children[1].children[2].children[0].children[ 1].children[1].width = '1cm' # set width of n_columns and markerspace - legend_options_wid.children[1].children[1].children[2].children[0].children[ - 0]. \ - add_class('align-end') + add_class(legend_options_wid.children[1].children[1].children[2].children[0].children[0], 'align-end') legend_options_wid.children[1].children[1].children[2].children[0].children[ 0].children[0].width = '1cm' legend_options_wid.children[1].children[1].children[2].children[0].children[ 0].children[1].width = '1cm' # align n_columns with spacing - legend_options_wid.children[1].children[1].children[2].children[0]. \ - remove_class('vbox') - legend_options_wid.children[1].children[1].children[2].children[0]. \ - add_class('hbox') + remove_class(legend_options_wid.children[1].children[1].children[2].children[0], 'vbox') + add_class(legend_options_wid.children[1].children[1].children[2].children[0], 'hbox') # border around options if suboptions_border_visible: @@ -3359,7 +3346,7 @@ def format_grid_options(grid_options_wid, container_padding='6px', the show line checkbox. """ # align grid options with checkbox - grid_options_wid.children[1].add_class('align-end') + add_class(grid_options_wid.children[1], 'align-end') # set gridlinewidth text box width grid_options_wid.children[1].children[1].children[1].width = '1cm' @@ -3650,8 +3637,8 @@ def format_hog_options(hog_options_wid, container_padding='6px', Defines whether to draw the border line around the widget. """ # align window options - hog_options_wid.children[1].children[0].children[1].remove_class('vbox') - hog_options_wid.children[1].children[0].children[1].add_class('hbox') + remove_class(hog_options_wid.children[1].children[0].children[1], 'vbox') + add_class(hog_options_wid.children[1].children[0].children[1], 'hbox') # set width of height, width, step x , step y textboxes hog_options_wid.children[1].children[0].children[1].children[0].children[0]. \ @@ -3674,8 +3661,8 @@ def format_hog_options(hog_options_wid, container_padding='6px', border = '1px solid gray' # align mode and padding - hog_options_wid.children[1].children[0].children[0].remove_class('vbox') - hog_options_wid.children[1].children[0].children[0].add_class('hbox') + remove_class(hog_options_wid.children[1].children[0].children[0], 'vbox') + add_class(hog_options_wid.children[1].children[0].children[0], 'hbox') # set width of algorithm textboxes hog_options_wid.children[1].children[1].children[1].children[0].children[0]. \ @@ -3688,8 +3675,8 @@ def format_hog_options(hog_options_wid, container_padding='6px', width = '40px' # align algorithm options - hog_options_wid.children[1].children[1].children[1].remove_class('vbox') - hog_options_wid.children[1].children[1].children[1].add_class('hbox') + remove_class(hog_options_wid.children[1].children[1].children[1], 'vbox') + add_class(hog_options_wid.children[1].children[1].children[1], 'hbox') # set margin and border around the algorithm options hog_options_wid.children[1].children[1].children[1]. \ @@ -3698,8 +3685,8 @@ def format_hog_options(hog_options_wid, container_padding='6px', border = '1px solid gray' hog_options_wid.children[1].margin_top = '6px' - hog_options_wid.children[1].children[0].add_class('align-center') - hog_options_wid.children[1].children[1].add_class('align-center') + add_class(hog_options_wid.children[1].children[0], 'align-center') + add_class(hog_options_wid.children[1].children[1], 'align-center') # set final tab titles tab_titles = ['Window', 'Algorithm'] @@ -4025,8 +4012,8 @@ def format_lbp_options(lbp_options_wid, container_padding='6px', Defines whether to draw the border line around the widget. """ # align window options - lbp_options_wid.children[1].remove_class('vbox') - lbp_options_wid.children[1].add_class('hbox') + remove_class(lbp_options_wid.children[1], 'vbox') + add_class(lbp_options_wid.children[1], 'hbox') # set textboxes length lbp_options_wid.children[1].children[0].children[0].width = '40px' @@ -4222,14 +4209,14 @@ def format_function_definition(function_definition_wid, container_padding='6px', Defines whether to draw the border line around the widget. """ # align message text and button horizontally - function_definition_wid.children[1].children[1].remove_class('vbox') - function_definition_wid.children[1].children[1].add_class('hbox') + remove_class(function_definition_wid.children[1].children[1], 'vbox') + add_class(function_definition_wid.children[1].children[1], 'hbox') # set margin between message and button function_definition_wid.children[1].children[1].children[0].margin_right = '0.5cm' # align code textarea and button to the right - function_definition_wid.children[1].add_class('align-end') + add_class(function_definition_wid.children[1], 'align-end') # set error message background to red function_definition_wid.children[1].children[1].children[0].background = 'red' From 289efce019de55138840b5bb6f38a2a17a32f588 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 4 Mar 2015 16:11:13 +0000 Subject: [PATCH 5/8] default_value wasn't the problem Change back to value --- menpo/visualize/widgets/base.py | 6 ++-- menpo/visualize/widgets/options.py | 14 ++++----- menpo/visualize/widgets/tools.py | 46 +++++++++++++++--------------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/menpo/visualize/widgets/base.py b/menpo/visualize/widgets/base.py index 47a8b5a16..d6613a0d0 100644 --- a/menpo/visualize/widgets/base.py +++ b/menpo/visualize/widgets/base.py @@ -148,7 +148,7 @@ def update_info(pointcloud): # viewer options widget axes_mode_wid = ipywidgets.RadioButtons( values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', - default_value=2) + value=2) axes_mode_wid.on_trait_change(plot_function, 'value') viewer_options_wid = viewer_options(viewer_options_default, ['lines', 'markers', 'figure_one'], @@ -460,7 +460,7 @@ def update_info(landmarkgroup): # viewer options widget axes_mode_wid = ipywidgets.RadioButtons( values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', - default_value=2) + value=2) axes_mode_wid.on_trait_change(plot_function, 'value') viewer_options_wid = viewer_options(viewer_options_default, ['lines', 'markers', 'numbering', @@ -828,7 +828,7 @@ def update_info(landmarks, group): # viewer options widget axes_mode_wid = ipywidgets.RadioButtons( values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', - default_value=2) + value=2) axes_mode_wid.on_trait_change(plot_function, 'value') viewer_options_wid = viewer_options(viewer_options_default, ['lines', 'markers', 'numbering', diff --git a/menpo/visualize/widgets/options.py b/menpo/visualize/widgets/options.py index 0e64313c5..c348eb2c6 100644 --- a/menpo/visualize/widgets/options.py +++ b/menpo/visualize/widgets/options.py @@ -115,10 +115,10 @@ def channel_options(channels_options_default, plot_function=None, # Create all necessary widgets # If single channel, disable all options apart from masked but = ipywidgets.ToggleButton(description='Channels Options', - default_value=toggle_show_default, + value=toggle_show_default, visible=toggle_show_visible) mode = ipywidgets.RadioButtons( - values=["Single", "Multiple"], default_value=mode_default, + values=["Single", "Multiple"], value=mode_default, description='Mode:', visible=toggle_show_default, disabled=channels_options_default['n_channels'] == 1) @@ -1483,7 +1483,7 @@ def viewer_options(viewer_options_default, options_tabs, objects_names=None, else: for k, g in enumerate(objects_names): objects_dict[g] = k - selection = ipywidgets.Dropdown(values=objects_dict, default_value=0, + selection = ipywidgets.Dropdown(values=objects_dict, value=0, description='Select', visible=(selection_visible and toggle_show_default)) @@ -1818,7 +1818,7 @@ def save_figure_options(renderer, format_default='png', dpi_default=None, format_dict['postscript'] = 'ps' format_dict['svg'] = 'svg' format_wid = ipywidgets.Select(values=format_dict, - default_value=format_default, + value=format_default, description='Format') def papertype_visibility(name, value): @@ -1838,7 +1838,7 @@ def set_extension(name, value): orientation_dict['portrait'] = 'portrait' orientation_dict['landscape'] = 'landscape' orientation_wid = ipywidgets.Dropdown(values=orientation_dict, - default_value=orientation_default, + value=orientation_default, description='Orientation') papertype_dict = OrderedDict() papertype_dict['letter'] = 'letter' @@ -1869,7 +1869,7 @@ def set_extension(name, value): papertype_dict['b10'] = 'b10' is_ps_type = not format_default == 'ps' papertype_wid = ipywidgets.Dropdown(values=papertype_dict, - default_value=papertype_default, + value=papertype_default, description='Paper type', disabled=is_ps_type) transparent_wid = ipywidgets.Checkbox(description='Transparent', @@ -2062,7 +2062,7 @@ def features_options(toggle_show_default=True, toggle_show_visible=True): tmp['LBP'] = lbp tmp['Gradient'] = gradient tmp['None'] = no_op - feature = ipywidgets.RadioButtons(default_value=no_op, values=tmp, + feature = ipywidgets.RadioButtons(value=no_op, values=tmp, description='Feature type:') # feature-related options diff --git a/menpo/visualize/widgets/tools.py b/menpo/visualize/widgets/tools.py index b339542e7..2e0b663d6 100644 --- a/menpo/visualize/widgets/tools.py +++ b/menpo/visualize/widgets/tools.py @@ -408,7 +408,7 @@ def colour_selection(default_colour_list, plot_function=None, title='Colour', else: for k, l in enumerate(labels): labels_dict[l] = k - selection = ipywidgets.Dropdown(values=labels_dict, default_value=0) + selection = ipywidgets.Dropdown(values=labels_dict, value=0) apply_to_all = ipywidgets.Button(description='apply to all labels') labels_wid = ipywidgets.Box(children=[selection, apply_to_all], visible=multiple) @@ -422,7 +422,7 @@ def colour_selection(default_colour_list, plot_function=None, title='Colour', max=1.0) g_wid = ipywidgets.BoundedFloatText(value=g_val, min=0.0, max=1.0) b_wid = ipywidgets.BoundedFloatText(value=b_val, min=0.0, max=1.0) - menu = ipywidgets.Dropdown(values=colour_dict, default_value=default_colour, + menu = ipywidgets.Dropdown(values=colour_dict, value=default_colour, description='') rgb = ipywidgets.Box(children=[r_wid, g_wid, b_wid]) @@ -847,7 +847,7 @@ def line_options(line_options_default, plot_function=None, line_style_dict['dash-dot'] = '-.' line_style_dict['dotted'] = ':' line_style = ipywidgets.Dropdown(values=line_style_dict, - default_value=line_options_default['line_style'], + value=line_options_default['line_style'], description='Style') line_colour = colour_selection(line_options_default['line_colour'], title='Colour', labels=labels, @@ -1108,7 +1108,7 @@ def marker_options(marker_options_default, plot_function=None, marker_style_dict['diamond'] = 'D' marker_style_dict['thin diamond'] = 'd' marker_style = ipywidgets.Dropdown(values=marker_style_dict, - default_value=marker_options_default[ + value=marker_options_default[ 'marker_style'], description='Style') marker_face_colour = colour_selection( @@ -1392,7 +1392,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_font_name_dict['monospace'] = 'monospace' numbers_font_name = ipywidgets.Dropdown( values=numbers_font_name_dict, - default_value=numbers_options_default['numbers_font_name'], + value=numbers_options_default['numbers_font_name'], description='Font') numbers_font_size = ipywidgets.BoundedIntText( description='Size', value=numbers_options_default['numbers_font_size'], @@ -1403,7 +1403,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_font_style_dict['oblique'] = 'oblique' numbers_font_style = ipywidgets.Dropdown( values=numbers_font_style_dict, - default_value=numbers_options_default['numbers_font_style'], + value=numbers_options_default['numbers_font_style'], description='Style') numbers_font_weight_dict = OrderedDict() numbers_font_weight_dict['normal'] = 'normal' @@ -1422,7 +1422,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_font_weight_dict['black'] = 'black' numbers_font_weight = ipywidgets.Dropdown( values=numbers_font_weight_dict, - default_value=numbers_options_default['numbers_font_weight'], + value=numbers_options_default['numbers_font_weight'], description='Weight') numbers_font_colour = colour_selection( numbers_options_default['numbers_font_colour'], title='Colour', @@ -1433,7 +1433,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_horizontal_align_dict['left'] = 'left' numbers_horizontal_align = ipywidgets.Dropdown( values=numbers_horizontal_align_dict, - default_value=numbers_options_default['numbers_horizontal_align'], + value=numbers_options_default['numbers_horizontal_align'], description='Align hor.') numbers_vertical_align_dict = OrderedDict() numbers_vertical_align_dict['center'] = 'center' @@ -1442,7 +1442,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_vertical_align_dict['baseline'] = 'baseline' numbers_vertical_align = ipywidgets.Dropdown( values=numbers_vertical_align_dict, - default_value=numbers_options_default['numbers_vertical_align'], + value=numbers_options_default['numbers_vertical_align'], description='Align ver.') # Options widget @@ -1753,7 +1753,7 @@ def figure_options(figure_options_default, plot_function=None, axes_font_name_dict['monospace'] = 'monospace' axes_font_name = ipywidgets.Dropdown( values=axes_font_name_dict, - default_value=figure_options_default['axes_font_name'], + value=figure_options_default['axes_font_name'], description='Font', visible=axes_visible) axes_font_size = ipywidgets.BoundedIntText( @@ -1765,7 +1765,7 @@ def figure_options(figure_options_default, plot_function=None, axes_font_style_dict['oblique'] = 'oblique' axes_font_style = ipywidgets.Dropdown( values=axes_font_style_dict, - default_value=figure_options_default['axes_font_style'], + value=figure_options_default['axes_font_style'], description='Style', visible=axes_visible) axes_font_weight_dict = OrderedDict() axes_font_weight_dict['normal'] = 'normal' @@ -1784,7 +1784,7 @@ def figure_options(figure_options_default, plot_function=None, axes_font_weight_dict['black'] = 'black' axes_font_weight = ipywidgets.Dropdown( values=axes_font_weight_dict, - default_value=figure_options_default['axes_font_weight'], + value=figure_options_default['axes_font_weight'], description='Weight', visible=axes_visible) if figure_options_default['axes_x_limits'] is None: tmp1 = False @@ -2197,7 +2197,7 @@ def figure_options_two_scales(figure_options_default, plot_function=None, axes_font_name_dict['monospace'] = 'monospace' axes_font_name = ipywidgets.Dropdown( values=axes_font_name_dict, - default_value=figure_options_default['axes_font_name'], + value=figure_options_default['axes_font_name'], description='Font', visible=axes_visible) axes_font_size = ipywidgets.BoundedIntText( @@ -2209,7 +2209,7 @@ def figure_options_two_scales(figure_options_default, plot_function=None, axes_font_style_dict['oblique'] = 'oblique' axes_font_style = ipywidgets.Dropdown( values=axes_font_style_dict, - default_value=figure_options_default['axes_font_style'], + value=figure_options_default['axes_font_style'], description='Style', visible=axes_visible) axes_font_weight_dict = OrderedDict() axes_font_weight_dict['normal'] = 'normal' @@ -2228,7 +2228,7 @@ def figure_options_two_scales(figure_options_default, plot_function=None, axes_font_weight_dict['black'] = 'black' axes_font_weight = ipywidgets.Dropdown( values=axes_font_weight_dict, - default_value=figure_options_default['axes_font_weight'], + value=figure_options_default['axes_font_weight'], description='Weight', visible=axes_visible) if figure_options_default['axes_x_limits'] is None: tmp1 = False @@ -2648,7 +2648,7 @@ def legend_options(legend_options_default, plot_function=None, legend_font_name_dict['monospace'] = 'monospace' legend_font_name = ipywidgets.Dropdown( values=legend_font_name_dict, - default_value=legend_options_default['legend_font_name'], + value=legend_options_default['legend_font_name'], description='Font') legend_font_size = ipywidgets.BoundedIntText( description='Size', value=legend_options_default['legend_font_size'], @@ -2659,7 +2659,7 @@ def legend_options(legend_options_default, plot_function=None, legend_font_style_dict['oblique'] = 'oblique' legend_font_style = ipywidgets.Dropdown( values=legend_font_style_dict, - default_value=legend_options_default['legend_font_style'], + value=legend_options_default['legend_font_style'], description='Style') legend_font_weight_dict = OrderedDict() legend_font_weight_dict['normal'] = 'normal' @@ -2678,7 +2678,7 @@ def legend_options(legend_options_default, plot_function=None, legend_font_weight_dict['black'] = 'black' legend_font_weight = ipywidgets.Dropdown( values=legend_font_weight_dict, - default_value=legend_options_default['legend_font_weight'], + value=legend_options_default['legend_font_weight'], description='Weight') legend_title = ipywidgets.Text(description='Title', value=legend_options_default[ @@ -2706,7 +2706,7 @@ def legend_options(legend_options_default, plot_function=None, legend_location_dict['center'] = 10 legend_location = ipywidgets.Dropdown( values=legend_location_dict, - default_value=legend_options_default['legend_location'], + value=legend_options_default['legend_location'], description='Predefined location') if legend_options_default['legend_bbox_to_anchor'] is None: tmp1 = False @@ -3265,7 +3265,7 @@ def grid_options(grid_options_default, plot_function=None, grid_line_style_dict['dotted'] = ':' grid_line_style = ipywidgets.Dropdown( values=grid_line_style_dict, - default_value=grid_options_default['grid_line_style'], + value=grid_options_default['grid_line_style'], description='Style') # Options widget @@ -3485,7 +3485,7 @@ def hog_options(toggle_show_default=True, toggle_show_visible=True): tmp = OrderedDict() tmp['Dalal & Triggs'] = 'dalaltriggs' tmp['Zhu & Ramanan'] = 'zhuramanan' - algorithm = ipywidgets.RadioButtons(values=tmp, default_value='dalaltriggs', + algorithm = ipywidgets.RadioButtons(values=tmp, value='dalaltriggs', description='Algorithm') cell_size = ipywidgets.BoundedIntText( value='8', description='Cell size (in pixels)', min=1) @@ -3747,7 +3747,7 @@ def daisy_options(toggle_show_default=True, toggle_show_visible=True): tmp['L2'] = 'l2' tmp['Daisy'] = 'daisy' tmp['None'] = None - normalization = ipywidgets.Dropdown(default_value='l1', values=tmp, + normalization = ipywidgets.Dropdown(value='l1', values=tmp, description='Normalization') sigmas = ipywidgets.Text(description='Sigmas') ring_radii = ipywidgets.Text(description='Ring radii') @@ -3908,7 +3908,7 @@ def lbp_options(toggle_show_default=True, toggle_show_visible=True): tmp['Rotation-Invariant'] = 'ri' tmp['Both'] = 'riu2' tmp['None'] = 'none' - mapping_type = ipywidgets.Dropdown(default_value='u2', values=tmp, + mapping_type = ipywidgets.Dropdown(value='u2', values=tmp, description='Mapping') radius = ipywidgets.Text(value='1, 2, 3, 4', description='Radius') samples = ipywidgets.Text(value='8, 8, 8, 8', description='Samples') From fb63aedabba87835a448b4e2c0c68928f2a59906 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 4 Mar 2015 16:27:42 +0000 Subject: [PATCH 6/8] values has been renamed to options Applies to dropdowns, radios and selections. --- menpo/visualize/widgets/base.py | 6 ++-- menpo/visualize/widgets/options.py | 16 ++++----- menpo/visualize/widgets/tools.py | 54 +++++++++++++++--------------- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/menpo/visualize/widgets/base.py b/menpo/visualize/widgets/base.py index d6613a0d0..c67103f5e 100644 --- a/menpo/visualize/widgets/base.py +++ b/menpo/visualize/widgets/base.py @@ -147,7 +147,7 @@ def update_info(pointcloud): # viewer options widget axes_mode_wid = ipywidgets.RadioButtons( - values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', + options={'Image': 1, 'Point cloud': 2}, description='Axes mode:', value=2) axes_mode_wid.on_trait_change(plot_function, 'value') viewer_options_wid = viewer_options(viewer_options_default, @@ -459,7 +459,7 @@ def update_info(landmarkgroup): # viewer options widget axes_mode_wid = ipywidgets.RadioButtons( - values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', + options={'Image': 1, 'Point cloud': 2}, description='Axes mode:', value=2) axes_mode_wid.on_trait_change(plot_function, 'value') viewer_options_wid = viewer_options(viewer_options_default, @@ -827,7 +827,7 @@ def update_info(landmarks, group): # viewer options widget axes_mode_wid = ipywidgets.RadioButtons( - values={'Image': 1, 'Point cloud': 2}, description='Axes mode:', + options={'Image': 1, 'Point cloud': 2}, description='Axes mode:', value=2) axes_mode_wid.on_trait_change(plot_function, 'value') viewer_options_wid = viewer_options(viewer_options_default, diff --git a/menpo/visualize/widgets/options.py b/menpo/visualize/widgets/options.py index c348eb2c6..206d85570 100644 --- a/menpo/visualize/widgets/options.py +++ b/menpo/visualize/widgets/options.py @@ -118,7 +118,7 @@ def channel_options(channels_options_default, plot_function=None, value=toggle_show_default, visible=toggle_show_visible) mode = ipywidgets.RadioButtons( - values=["Single", "Multiple"], value=mode_default, + options=["Single", "Multiple"], value=mode_default, description='Mode:', visible=toggle_show_default, disabled=channels_options_default['n_channels'] == 1) @@ -584,7 +584,7 @@ def landmark_options(landmark_options_default, plot_function=None, landmarks = ipywidgets.Checkbox(description='Render landmarks', value=landmark_options_default['render_landmarks']) group = ipywidgets.Dropdown( - values=landmark_options_default['group_keys'], + options=landmark_options_default['group_keys'], description='Group') labels_toggles = [[ipywidgets.ToggleButton(description=k, value=True) for k in s_keys] @@ -786,7 +786,7 @@ def update_landmark_options(landmark_options_wid, group_keys, labels_keys, landmark_options_wid.selected_values['group_keys'], landmark_options_wid.selected_values['labels_keys']): # Create all necessary widgets - group = ipywidgets.Dropdown(values=group_keys, + group = ipywidgets.Dropdown(options=group_keys, description='Group') labels_toggles = [ [ipywidgets.ToggleButton(description=k, value=True) @@ -1483,7 +1483,7 @@ def viewer_options(viewer_options_default, options_tabs, objects_names=None, else: for k, g in enumerate(objects_names): objects_dict[g] = k - selection = ipywidgets.Dropdown(values=objects_dict, value=0, + selection = ipywidgets.Dropdown(options=objects_dict, value=0, description='Select', visible=(selection_visible and toggle_show_default)) @@ -1817,7 +1817,7 @@ def save_figure_options(renderer, format_default='png', dpi_default=None, format_dict['eps'] = 'eps' format_dict['postscript'] = 'ps' format_dict['svg'] = 'svg' - format_wid = ipywidgets.Select(values=format_dict, + format_wid = ipywidgets.Select(options=format_dict, value=format_default, description='Format') @@ -1837,7 +1837,7 @@ def set_extension(name, value): orientation_dict = OrderedDict() orientation_dict['portrait'] = 'portrait' orientation_dict['landscape'] = 'landscape' - orientation_wid = ipywidgets.Dropdown(values=orientation_dict, + orientation_wid = ipywidgets.Dropdown(options=orientation_dict, value=orientation_default, description='Orientation') papertype_dict = OrderedDict() @@ -1868,7 +1868,7 @@ def set_extension(name, value): papertype_dict['b9'] = 'b9' papertype_dict['b10'] = 'b10' is_ps_type = not format_default == 'ps' - papertype_wid = ipywidgets.Dropdown(values=papertype_dict, + papertype_wid = ipywidgets.Dropdown(options=papertype_dict, value=papertype_default, description='Paper type', disabled=is_ps_type) @@ -2062,7 +2062,7 @@ def features_options(toggle_show_default=True, toggle_show_visible=True): tmp['LBP'] = lbp tmp['Gradient'] = gradient tmp['None'] = no_op - feature = ipywidgets.RadioButtons(value=no_op, values=tmp, + feature = ipywidgets.RadioButtons(value=no_op, options=tmp, description='Feature type:') # feature-related options diff --git a/menpo/visualize/widgets/tools.py b/menpo/visualize/widgets/tools.py index 2e0b663d6..74df719ea 100644 --- a/menpo/visualize/widgets/tools.py +++ b/menpo/visualize/widgets/tools.py @@ -408,7 +408,7 @@ def colour_selection(default_colour_list, plot_function=None, title='Colour', else: for k, l in enumerate(labels): labels_dict[l] = k - selection = ipywidgets.Dropdown(values=labels_dict, value=0) + selection = ipywidgets.Dropdown(options=labels_dict, value=0) apply_to_all = ipywidgets.Button(description='apply to all labels') labels_wid = ipywidgets.Box(children=[selection, apply_to_all], visible=multiple) @@ -422,7 +422,7 @@ def colour_selection(default_colour_list, plot_function=None, title='Colour', max=1.0) g_wid = ipywidgets.BoundedFloatText(value=g_val, min=0.0, max=1.0) b_wid = ipywidgets.BoundedFloatText(value=b_val, min=0.0, max=1.0) - menu = ipywidgets.Dropdown(values=colour_dict, value=default_colour, + menu = ipywidgets.Dropdown(options=colour_dict, value=default_colour, description='') rgb = ipywidgets.Box(children=[r_wid, g_wid, b_wid]) @@ -846,7 +846,7 @@ def line_options(line_options_default, plot_function=None, line_style_dict['dashed'] = '--' line_style_dict['dash-dot'] = '-.' line_style_dict['dotted'] = ':' - line_style = ipywidgets.Dropdown(values=line_style_dict, + line_style = ipywidgets.Dropdown(options=line_style_dict, value=line_options_default['line_style'], description='Style') line_colour = colour_selection(line_options_default['line_colour'], @@ -1107,7 +1107,7 @@ def marker_options(marker_options_default, plot_function=None, marker_style_dict['x'] = 'x' marker_style_dict['diamond'] = 'D' marker_style_dict['thin diamond'] = 'd' - marker_style = ipywidgets.Dropdown(values=marker_style_dict, + marker_style = ipywidgets.Dropdown(options=marker_style_dict, value=marker_options_default[ 'marker_style'], description='Style') @@ -1391,7 +1391,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_font_name_dict['fantasy'] = 'fantasy' numbers_font_name_dict['monospace'] = 'monospace' numbers_font_name = ipywidgets.Dropdown( - values=numbers_font_name_dict, + options=numbers_font_name_dict, value=numbers_options_default['numbers_font_name'], description='Font') numbers_font_size = ipywidgets.BoundedIntText( @@ -1402,7 +1402,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_font_style_dict['italic'] = 'italic' numbers_font_style_dict['oblique'] = 'oblique' numbers_font_style = ipywidgets.Dropdown( - values=numbers_font_style_dict, + options=numbers_font_style_dict, value=numbers_options_default['numbers_font_style'], description='Style') numbers_font_weight_dict = OrderedDict() @@ -1421,7 +1421,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_font_weight_dict['extra bold'] = 'extra bold' numbers_font_weight_dict['black'] = 'black' numbers_font_weight = ipywidgets.Dropdown( - values=numbers_font_weight_dict, + options=numbers_font_weight_dict, value=numbers_options_default['numbers_font_weight'], description='Weight') numbers_font_colour = colour_selection( @@ -1432,7 +1432,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_horizontal_align_dict['right'] = 'right' numbers_horizontal_align_dict['left'] = 'left' numbers_horizontal_align = ipywidgets.Dropdown( - values=numbers_horizontal_align_dict, + options=numbers_horizontal_align_dict, value=numbers_options_default['numbers_horizontal_align'], description='Align hor.') numbers_vertical_align_dict = OrderedDict() @@ -1441,7 +1441,7 @@ def numbering_options(numbers_options_default, plot_function=None, numbers_vertical_align_dict['bottom'] = 'bottom' numbers_vertical_align_dict['baseline'] = 'baseline' numbers_vertical_align = ipywidgets.Dropdown( - values=numbers_vertical_align_dict, + options=numbers_vertical_align_dict, value=numbers_options_default['numbers_vertical_align'], description='Align ver.') @@ -1752,7 +1752,7 @@ def figure_options(figure_options_default, plot_function=None, axes_font_name_dict['fantasy'] = 'fantasy' axes_font_name_dict['monospace'] = 'monospace' axes_font_name = ipywidgets.Dropdown( - values=axes_font_name_dict, + options=axes_font_name_dict, value=figure_options_default['axes_font_name'], description='Font', visible=axes_visible) @@ -1764,7 +1764,7 @@ def figure_options(figure_options_default, plot_function=None, axes_font_style_dict['italic'] = 'italic' axes_font_style_dict['oblique'] = 'oblique' axes_font_style = ipywidgets.Dropdown( - values=axes_font_style_dict, + options=axes_font_style_dict, value=figure_options_default['axes_font_style'], description='Style', visible=axes_visible) axes_font_weight_dict = OrderedDict() @@ -1783,7 +1783,7 @@ def figure_options(figure_options_default, plot_function=None, axes_font_weight_dict['extra bold'] = 'extra bold' axes_font_weight_dict['black'] = 'black' axes_font_weight = ipywidgets.Dropdown( - values=axes_font_weight_dict, + options=axes_font_weight_dict, value=figure_options_default['axes_font_weight'], description='Weight', visible=axes_visible) if figure_options_default['axes_x_limits'] is None: @@ -2196,7 +2196,7 @@ def figure_options_two_scales(figure_options_default, plot_function=None, axes_font_name_dict['fantasy'] = 'fantasy' axes_font_name_dict['monospace'] = 'monospace' axes_font_name = ipywidgets.Dropdown( - values=axes_font_name_dict, + options=axes_font_name_dict, value=figure_options_default['axes_font_name'], description='Font', visible=axes_visible) @@ -2208,7 +2208,7 @@ def figure_options_two_scales(figure_options_default, plot_function=None, axes_font_style_dict['italic'] = 'italic' axes_font_style_dict['oblique'] = 'oblique' axes_font_style = ipywidgets.Dropdown( - values=axes_font_style_dict, + options=axes_font_style_dict, value=figure_options_default['axes_font_style'], description='Style', visible=axes_visible) axes_font_weight_dict = OrderedDict() @@ -2227,7 +2227,7 @@ def figure_options_two_scales(figure_options_default, plot_function=None, axes_font_weight_dict['extra bold'] = 'extra bold' axes_font_weight_dict['black'] = 'black' axes_font_weight = ipywidgets.Dropdown( - values=axes_font_weight_dict, + options=axes_font_weight_dict, value=figure_options_default['axes_font_weight'], description='Weight', visible=axes_visible) if figure_options_default['axes_x_limits'] is None: @@ -2647,7 +2647,7 @@ def legend_options(legend_options_default, plot_function=None, legend_font_name_dict['fantasy'] = 'fantasy' legend_font_name_dict['monospace'] = 'monospace' legend_font_name = ipywidgets.Dropdown( - values=legend_font_name_dict, + options=legend_font_name_dict, value=legend_options_default['legend_font_name'], description='Font') legend_font_size = ipywidgets.BoundedIntText( @@ -2658,7 +2658,7 @@ def legend_options(legend_options_default, plot_function=None, legend_font_style_dict['italic'] = 'italic' legend_font_style_dict['oblique'] = 'oblique' legend_font_style = ipywidgets.Dropdown( - values=legend_font_style_dict, + options=legend_font_style_dict, value=legend_options_default['legend_font_style'], description='Style') legend_font_weight_dict = OrderedDict() @@ -2677,7 +2677,7 @@ def legend_options(legend_options_default, plot_function=None, legend_font_weight_dict['extra bold'] = 'extra bold' legend_font_weight_dict['black'] = 'black' legend_font_weight = ipywidgets.Dropdown( - values=legend_font_weight_dict, + options=legend_font_weight_dict, value=legend_options_default['legend_font_weight'], description='Weight') legend_title = ipywidgets.Text(description='Title', @@ -2705,7 +2705,7 @@ def legend_options(legend_options_default, plot_function=None, legend_location_dict['upper center'] = 9 legend_location_dict['center'] = 10 legend_location = ipywidgets.Dropdown( - values=legend_location_dict, + options=legend_location_dict, value=legend_options_default['legend_location'], description='Predefined location') if legend_options_default['legend_bbox_to_anchor'] is None: @@ -3264,7 +3264,7 @@ def grid_options(grid_options_default, plot_function=None, grid_line_style_dict['dash-dot'] = '-.' grid_line_style_dict['dotted'] = ':' grid_line_style = ipywidgets.Dropdown( - values=grid_line_style_dict, + options=grid_line_style_dict, value=grid_options_default['grid_line_style'], description='Style') @@ -3448,7 +3448,7 @@ def hog_options(toggle_show_default=True, toggle_show_visible=True): tmp = OrderedDict() tmp['Dense'] = 'dense' tmp['Sparse'] = 'sparse' - mode = ipywidgets.RadioButtons(values=tmp, description='Mode') + mode = ipywidgets.RadioButtons(options=tmp, description='Mode') padding = ipywidgets.Checkbox(value=True, description='Padding') mode_wid = ipywidgets.Box(children=[mode, padding]) window_height = ipywidgets.BoundedIntText(value='1', @@ -3458,7 +3458,7 @@ def hog_options(toggle_show_default=True, toggle_show_visible=True): tmp = OrderedDict() tmp['Blocks'] = 'blocks' tmp['Pixels'] = 'pixels' - window_size_unit = ipywidgets.RadioButtons(values=tmp, + window_size_unit = ipywidgets.RadioButtons(options=tmp, description=' Size unit') window_size_wid = ipywidgets.Box( children=[window_height, window_width, @@ -3472,7 +3472,7 @@ def hog_options(toggle_show_default=True, toggle_show_visible=True): tmp = OrderedDict() tmp['Pixels'] = 'pixels' tmp['Cells'] = 'cells' - window_step_unit = ipywidgets.RadioButtons(values=tmp, + window_step_unit = ipywidgets.RadioButtons(options=tmp, description='Step unit') window_step_wid = ipywidgets.Box(children=[window_vertical, window_horizontal, @@ -3485,7 +3485,7 @@ def hog_options(toggle_show_default=True, toggle_show_visible=True): tmp = OrderedDict() tmp['Dalal & Triggs'] = 'dalaltriggs' tmp['Zhu & Ramanan'] = 'zhuramanan' - algorithm = ipywidgets.RadioButtons(values=tmp, value='dalaltriggs', + algorithm = ipywidgets.RadioButtons(options=tmp, value='dalaltriggs', description='Algorithm') cell_size = ipywidgets.BoundedIntText( value='8', description='Cell size (in pixels)', min=1) @@ -3747,7 +3747,7 @@ def daisy_options(toggle_show_default=True, toggle_show_visible=True): tmp['L2'] = 'l2' tmp['Daisy'] = 'daisy' tmp['None'] = None - normalization = ipywidgets.Dropdown(value='l1', values=tmp, + normalization = ipywidgets.Dropdown(value='l1', options=tmp, description='Normalization') sigmas = ipywidgets.Text(description='Sigmas') ring_radii = ipywidgets.Text(description='Ring radii') @@ -3908,7 +3908,7 @@ def lbp_options(toggle_show_default=True, toggle_show_visible=True): tmp['Rotation-Invariant'] = 'ri' tmp['Both'] = 'riu2' tmp['None'] = 'none' - mapping_type = ipywidgets.Dropdown(value='u2', values=tmp, + mapping_type = ipywidgets.Dropdown(value='u2', options=tmp, description='Mapping') radius = ipywidgets.Text(value='1, 2, 3, 4', description='Radius') samples = ipywidgets.Text(value='8, 8, 8, 8', description='Samples') @@ -3924,7 +3924,7 @@ def lbp_options(toggle_show_default=True, toggle_show_visible=True): tmp = OrderedDict() tmp['Pixels'] = 'pixels' tmp['Windows'] = 'cells' - window_step_unit = ipywidgets.RadioButtons(values=tmp, + window_step_unit = ipywidgets.RadioButtons(options=tmp, description='Step unit') padding = ipywidgets.Checkbox(value=True, description='Padding') window_wid = ipywidgets.Box(children=[window_vertical, window_horizontal, From a015cc3686c70647b317acaddc5f178499889c92 Mon Sep 17 00:00:00 2001 From: Joan Alabort Date: Thu, 5 Mar 2015 11:11:14 +0000 Subject: [PATCH 7/8] Update channel_options - visualize_images was not rendering greyscale images. --- menpo/visualize/widgets/options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menpo/visualize/widgets/options.py b/menpo/visualize/widgets/options.py index 206d85570..cc6776251 100644 --- a/menpo/visualize/widgets/options.py +++ b/menpo/visualize/widgets/options.py @@ -132,7 +132,7 @@ def channel_options(channels_options_default, plot_function=None, visible=toggle_show_default, disabled=channels_options_default['n_channels'] == 1) second_slider_wid = ipywidgets.IntSlider( - min=1, max=channels_options_default['n_channels'] - 1, step=1, + min=1, max=max(channels_options_default['n_channels'] - 1, 1), step=1, value=second_slider_default, description='To', visible=mode_default == "Multiple") rgb_wid = ipywidgets.Checkbox( From 58367df60639232aabc0c8a525bcc86657939b76 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Thu, 5 Mar 2015 18:05:09 +0000 Subject: [PATCH 8/8] Formatting --- menpo/visualize/widgets/tools.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/menpo/visualize/widgets/tools.py b/menpo/visualize/widgets/tools.py index 74df719ea..29b998d31 100644 --- a/menpo/visualize/widgets/tools.py +++ b/menpo/visualize/widgets/tools.py @@ -830,17 +830,17 @@ def line_options(line_options_default, plot_function=None, # Create widgets # toggle button but = ipywidgets.ToggleButton(description=toggle_title, - value=toggle_show_default, - visible=toggle_show_visible) + value=toggle_show_default, + visible=toggle_show_visible) # line_style, line_width, line_colour render_lines = ipywidgets.Checkbox(description=show_checkbox_title, - value=line_options_default[ + value=line_options_default[ 'render_lines']) line_width = ipywidgets.BoundedFloatText(description='Width', - value=line_options_default[ - 'line_width'], - min=0.) + value=line_options_default[ + 'line_width'], + min=0.) line_style_dict = OrderedDict() line_style_dict['solid'] = '-' line_style_dict['dashed'] = '--'