Ejemplo n.º 1
0
 def _generate_presenter(self, view=None, fig=None):
     if not view:
         view = Mock(get_selected_image_name=lambda: 'Second Axes: (1, 1) - {}'
                                                     ''.format(self.img1_label))
     if not fig:
         fig = self.fig
     return ImagesTabWidgetPresenter(view=view, fig=fig)
Ejemplo n.º 2
0
    def __init__(self, fig, view=None, parent=None):
        self.fig = fig
        if view:
            self.view = view
        else:
            self.view = PlotConfigDialogView(parent)
        self.view.show()

        self.tab_widget_presenters = [None, None, None]
        self.tab_widget_views = [None, None, None]
        # Axes tab
        if len(self.fig.get_axes()) > 0:
            axes_tab = AxesTabWidgetPresenter(self.fig, parent=self.view)
            self.tab_widget_presenters[0] = axes_tab
            self.tab_widget_views[0] = (axes_tab.view, "Axes")
        # Curves tab
        if curve_in_figure(self.fig):
            curves_tab = CurvesTabWidgetPresenter(self.fig, parent=self.view)
            self.tab_widget_presenters[1] = curves_tab
            self.tab_widget_views[1] = (curves_tab.view, "Curves")
        # Images tab
        if image_in_figure(self.fig):
            images_tab = ImagesTabWidgetPresenter(self.fig, parent=self.view)
            self.tab_widget_presenters[2] = images_tab
            self.tab_widget_views[2] = (images_tab.view, "Images")

        self._add_tab_widget_views()

        # Signals
        self.view.ok_button.clicked.connect(self.apply_properties_and_exit)
        self.view.apply_button.clicked.connect(self.apply_properties)
        self.view.cancel_button.clicked.connect(self.exit)
Ejemplo n.º 3
0
    def __init__(self, fig, view=None, parent=None):
        self.fig = fig
        if view:
            self.view = view
        else:
            self.view = PlotConfigDialogView(parent)
        self.view.show()

        self.tab_widget_presenters = [None, None, None, None]
        self.tab_widget_views = [None, None, None, None]
        legend_tab = None
        # Axes tab
        if len(self.fig.get_axes()) > 0:
            axes_tab = AxesTabWidgetPresenter(
                self.fig,
                parent=self.view,
                success_callback=self.success_callback,
                error_callback=self.error_callback)
            self.tab_widget_presenters[1] = axes_tab
            self.tab_widget_views[0] = (axes_tab.view, "Axes")
        # Legend tab
        if legend_in_figure(self.fig):
            legend_tab = LegendTabWidgetPresenter(self.fig,
                                                  parent_view=self.view,
                                                  parent_presenter=self)
            self.tab_widget_presenters[0] = legend_tab
            self.tab_widget_views[3] = (legend_tab.view, "Legend")
        # Curves tab
        if curve_in_figure(self.fig):
            curves_tab = CurvesTabWidgetPresenter(self.fig,
                                                  parent_view=self.view,
                                                  parent_presenter=self,
                                                  legend_tab=legend_tab)
            self.tab_widget_presenters[2] = curves_tab
            self.tab_widget_views[1] = (curves_tab.view, "Curves")
        # Images tab
        if image_in_figure(self.fig):
            images_tab = ImagesTabWidgetPresenter(self.fig, parent=self.view)
            self.tab_widget_presenters[3] = images_tab
            self.tab_widget_views[2] = (images_tab.view, "Images")

        self._add_tab_widget_views()

        # Signals
        self.view.ok_button.clicked.connect(self.apply_properties_and_exit)
        self.view.apply_button.clicked.connect(self.apply_properties)
        self.view.cancel_button.clicked.connect(self.exit)
        self.view.help_button.clicked.connect(self.open_help_window)

        self.error_state = False
 def test_set_name_in_names_dict_increments_name_if_duplicated(self):
     names_dict = {'name0': None, 'name1': None, 'name2': None}
     new_names_dict = ImagesTabWidgetPresenter.set_name_in_names_dict(
         'name0', 1, names_dict)
     names_dict.update({'name0 (1)': 1})
     self.assertEqual(names_dict, new_names_dict)
 def test_generate_image_name(self):
     generated_name = ImagesTabWidgetPresenter.generate_image_name(
         self.img0)
     expected_name = '(0, 1) - {}'.format(self.img0.get_label())
     self.assertEqual(generated_name, expected_name)