예제 #1
0
    def __init__(self, plugin, title, text=None):
        """
        Creates a modal window. The return code is the button number that was
          last pressed before closing the window.
        plugin (Plugin): The plugin creating this dialog
        title (str): The title of the window
        text (None or str): If provided, it is displayed at the top of the window
        """
        super(AcquisitionDialog, self).__init__(plugin.main_app.main_frame)

        logging.debug("Creating acquisition dialog for %s",
                      plugin.__class__.__name__)
        self.plugin = plugin

        self.SetTitle(title)

        if text is not None:
            self.lbl_description = AutoWrapStaticText(self.pnl_desc, "")
            self.lbl_description.SetBackgroundColour(
                self.pnl_desc.GetBackgroundColour())
            self.lbl_description.SetForegroundColour(gui.FG_COLOUR_MAIN)
            self.pnl_desc.GetSizer().Add(self.lbl_description,
                                         flag=wx.EXPAND | wx.ALL,
                                         border=10)
            self.lbl_description.SetLabel(text)

        self._acq_future_connector = None
        self.buttons = []  # The buttons
        self.current_future = None
        self.btn_cancel.Bind(wx.EVT_BUTTON, self._cancel_future)

        self.setting_controller = SettingsController(self.fp_settings,
                                                     "No settings defined")

        # Create a minimal model for use in the streambar controller

        self._dmodel = MicroscopyGUIData(plugin.main_app.main_data)
        self.hidden_view = StreamView("Plugin View Hidden")
        self.view = MicroscopeView("Plugin View left")
        self.viewport_l.setView(self.view, self._dmodel)
        self.view_r = MicroscopeView("Plugin View right")
        self.viewport_r.setView(self.view_r, self._dmodel)
        self.spectrum_view = MicroscopeView("Plugin View spectrum")
        self.spectrum_viewport.setView(self.spectrum_view, self._dmodel)
        self._dmodel.focussedView.value = self.view
        self._dmodel.views.value = [self.view, self.view_r, self.spectrum_view]
        self._viewports = (self.viewport_l, self.viewport_r,
                           self.spectrum_viewport)

        self.streambar_controller = StreamBarController(self._dmodel,
                                                        self.pnl_streams,
                                                        ignore_view=True)

        self.Fit()
예제 #2
0
    def __init__(self, plugin, title, text=None):
        """
        Creates a modal window. The return code is the button number that was
          last pressed before closing the window.
        title (str): The title of the window
        text (None or str): If provided, it is displayed at the top of the window
        """

        super(AcquisitionDialog, self).__init__(plugin.main_app.main_frame)

        self.plugin = plugin

        self.SetTitle(title)

        if text is not None:
            self.lbl_description = AutoWrapStaticText(self.pnl_desc, "")
            self.lbl_description.SetBackgroundColour(
                self.pnl_desc.GetBackgroundColour())
            self.pnl_desc.GetSizer().Add(self.lbl_description,
                                         flag=wx.EXPAND | wx.ALL,
                                         border=10)
            self.lbl_description.SetLabel(text)

        self.entries = []  # Setting entries
        self._acq_future_connector = None
        self.canvas = None
        self.buttons = []  # The buttons
        self.current_future = None
        self.btn_cancel.Bind(wx.EVT_BUTTON, self._cancel_future)

        self.setting_controller = SettingsController(self.fp_settings,
                                                     "No settings defined")

        # Create a minimal model for use in the streambar controller

        data_model = MicroscopyGUIData(plugin.main_app.main_data)
        self.microscope_view = MicroscopeView("Plugin View")
        data_model.focussedView = VigilantAttribute(self.microscope_view)
        self.viewport.setView(self.microscope_view, data_model)

        self.streambar_controller = StreamBarController(data_model,
                                                        self.pnl_streams,
                                                        ignore_view=True)

        self.Refresh()
        self.Fit()
    def createPluginForms(self):
        for plugin in self.plugins:
            pluginVariables = plugin.PLUGIN_SETTINGS.get("VARIABLES")
            # completely main sizer, holds absolutely everything
            scrollPanel = scrolled.ScrolledPanel(parent=self.mainPanel)
            scrollPanel.SetAutoLayout(1)
            scrollPanel.SetupScrolling(scroll_x=False)

            mainPluginSizer = wx.BoxSizer(wx.VERTICAL)
            # start plugin as an instance
            startButton = wx.Button(parent=scrollPanel, label="Start")
            startButton.Bind(wx.EVT_BUTTON,
                             lambda event: self.startPluginInstance(plugin))
            mainPluginSizer.Add(startButton, 0, wx.EXPAND)
            # end plugin instance
            endButton = wx.Button(parent=scrollPanel, label="End")
            endButton.Bind(wx.EVT_BUTTON,
                           lambda event: self.endPluginInstance())
            mainPluginSizer.Add(endButton, 0, wx.EXPAND)
            # a fold panel, looks pretty
            if pluginVariables:
                for variableName in pluginVariables:
                    variable = pluginVariables[variableName]
                    variableName = variable.get("NAME") or variableName
                    variableDescription = variable.get(
                        "DESCRIPTION") or NO_DESCRIPTION_LABEL_TEXT

                    # the sizer (which has a static box in it) to add
                    contentPanel = wx.Panel(parent=scrollPanel)
                    contentSizer = wx.StaticBoxSizer(wx.VERTICAL, contentPanel,
                                                     variableName)
                    # set background color
                    contentSizer.GetStaticBox().SetBackgroundColour(
                        SETTINGS.theme.plugin_variable_background)

                    variableDescription = AutoWrapStaticText(
                        parent=contentPanel, label=variableDescription)
                    contentSizer.Add(variableDescription, 1,
                                     wx.ALIGN_CENTER | wx.EXPAND)

                    variableControl = self.processArgumentNotation(
                        variable, contentPanel)
                    contentSizer.Add(variableControl, 1,
                                     wx.ALIGN_CENTER | wx.EXPAND)

                    setButton = coolButtons.GenButton(parent=contentPanel,
                                                      label="Set")
                    # gets theme color and sets the button to have that color
                    setButton.SetBackgroundColour(SETTINGS.theme.set_button)
                    setButton.Bind(
                        wx.EVT_BUTTON, lambda event: self.setVariable(
                            variableName, variableControl))
                    contentSizer.Add(setButton, 1, wx.ALIGN_CENTER | wx.EXPAND)

                    contentPanel.SetSizer(contentSizer)

                    mainPluginSizer.Add(contentPanel, 1,
                                        wx.ALIGN_CENTER | wx.EXPAND)
            scrollPanel.SetSizer(mainPluginSizer)
            plugin.__ADDED_TO_GUI = False
            plugin.__PLUGIN_GUI = scrollPanel  # shouldn't be accesed by the plugin