Ejemplo n.º 1
0
    def __init__(
        self,
        ws,
        parent=None,
        window_flags=Qt.Window,
        plot=None,
        model=None,
        view=None,
        name=None,
        ads_observer=None,
        container=None,
        window_width=600,
        window_height=400,
        batch=False,
    ):
        """
        Creates a display for the provided workspace.

        :param ws: Workspace to be displayed
        :param parent: Parent of the widget
        :param window_flags: An optional set of window flags
        :param plot: Plotting function that will be used to plot workspaces. This requires Matplotlib directly.
                     Passed in as parameter to allow mocking
        :param model: Model to be used by the widget. Passed in as parameter to allow mocking
        :param view: View to be used by the widget. Passed in as parameter to allow mocking
        :param name: Custom name for the window
        :param ads_observer: ADS observer to be used by the presenter. If not provided the default
                             one is used. Mainly intended for testing.
        """
        view, model = self.create_table(ws, parent, window_flags, model, view,
                                        batch)
        self.view = view
        self.model = model
        self.name = name if name else model.get_name()
        self.container = (container if container else StatusBarView(
            parent,
            view,
            self.name,
            window_width=window_width,
            window_height=window_height,
            window_flags=window_flags,
            presenter=self,
        ))

        DataCopier.__init__(self, self.container.status_bar)

        self.parent = parent
        self.plot = plot

        self.ads_observer = (ads_observer if ads_observer else
                             WorkspaceDisplayADSObserver(self))

        self.presenter.refresh()
Ejemplo n.º 2
0
    def __init__(self,
                 ws,
                 plot=None,
                 parent=None,
                 model=None,
                 view=None,
                 name=None,
                 ads_observer=None,
                 container=None,
                 window_width=600,
                 window_height=400):
        """
        Creates a display for the provided workspace.

        :param ws: Workspace to be displayed
        :param parent: Parent of the widget
        :param plot: Plotting function that will be used to plot workspaces. This requires Matplotlib directly.
                     Passed in as parameter to allow mocking
        :param model: Model to be used by the widget. Passed in as parameter to allow mocking
        :param view: View to be used by the widget. Passed in as parameter to allow mocking
        :param name: Custom name for the window
        :param ads_observer: ADS observer to be used by the presenter. If not provided the default
                             one is used. Mainly intended for testing.
        """
        model = model if model is not None else TableWorkspaceDisplayModel(ws)
        view = view if view else TableWorkspaceDisplayView(self, parent)
        TableWorkspaceDataPresenter.__init__(self, model, view)

        self.name = name if name else self.model.get_name()
        self.container = container if container else StatusBarView(
            parent,
            self.view,
            self.name,
            window_width=window_width,
            window_height=window_height,
            presenter=self)

        DataCopier.__init__(self, self.container.status_bar)

        self.parent = parent
        self.plot = plot
        self.view.set_context_menu_actions(self.view)

        self.ads_observer = ads_observer if ads_observer else WorkspaceDisplayADSObserver(
            self)

        self.refresh()

        # connect to cellChanged signal after the data has been loaded
        self.view.itemChanged.connect(self.handleItemChanged)