def OnInit(self): """ Initialize the GUI This method is automatically called from the :wx:`App` constructor """ gui.legend_logo = "legend_logo_delmic.png" if self._is_standalone: microscope = None gui.icon = img.getIcon("icon/ico_gui_viewer_256.png") gui.name = odemis.__shortname__ + " Viewer" if "delphi" == self._is_standalone: gui.logo = img.getBitmap("logo_delphi.png") gui.legend_logo = "legend_logo_delphi.png" else: gui.icon = img.getIcon("icon/ico_gui_full_256.png") gui.name = odemis.__shortname__ try: microscope = model.getMicroscope() except (IOError, Pyro4.errors.CommunicationError) as e: logging.exception("Failed to connect to back-end") msg = ("The Odemis GUI could not connect to the Odemis back-end:" "\n\n{0}\n\n" "Launch user interface anyway?").format(e) answer = wx.MessageBox(msg, "Connection error", style=wx.YES | wx.NO | wx.ICON_ERROR) if answer == wx.NO: sys.exit(1) microscope = None else: if microscope.role == "delphi": gui.logo = img.getBitmap("logo_delphi.png") gui.legend_logo = "legend_logo_delphi.png" # TODO: if microscope.ghost is not empty => wait and/or display a special # "hardware status" tab. if microscope and microscope.role == "mbsem": self.main_data = guimodel.FastEMMainGUIData(microscope) else: self.main_data = guimodel.MainGUIData(microscope) # Load the main frame self.main_frame = main_xrc.xrcfr_main(None) self.init_gui() try: from odemis.gui.dev.powermate import Powermate self.dev_powermate = Powermate(self.main_data) except (LookupError, NotImplementedError) as ex: logging.debug("Not using Powermate: %s", ex) except Exception: logging.exception("Failed to load Powermate support") # Application successfully launched return True
def create_simple_tab_model(self): main = gmodel.MainGUIData(None) # no microscope backend tab = gmodel.MicroscopyGUIData(main) # Add one view fview = gmodel.MicroscopeView("fakeview") tab.views.value.append(fview) tab.focussedView.value = fview return tab
def create_cryo_tab_model(self): main = gmodel.MainGUIData(None) # no microscope backend # add role, features and currentFeature directly main.role = "cryo" main.features = omodel.ListVA() main.currentFeature = omodel.VigilantAttribute(None) tab = gmodel.CryoGUIData(main) # Add one view fview = gmodel.MicroscopeView("fakeview") tab.views.value.append(fview) tab.focussedView.value = fview return tab
class OdemisGUIApp(wx.App): """ This is Odemis' main GUI application class """ def __init__(self, standalone=False): """ standalone (boolean): do not try to connect to the backend """ # Replace the standard 'get_resources' with our augmented one, that # can handle more control types. See the xhandler package for more info. main_xrc.get_resources = odemis_get_resources # Declare attributes BEFORE calling the super class constructor # because it will call 'OnInit' which uses them. # HTTP documentation http server process self.http_proc = None self.main_data = None self.main_frame = None self._tab_controller = None self._is_standalone = standalone if not standalone: try: driver.speedUpPyroConnect(model.getMicroscope()) except Exception: logging.exception("Failed to speed up start up") # Output catcher using a helper class wx.App.outputWindowClass = OdemisOutputWindow # Constructor of the parent class # ONLY CALL IT AT THE END OF :py:method:`__init__` BECAUSE OnInit will # be called # and it needs the attributes defined in this constructor! wx.App.__init__(self, redirect=True) def OnInit(self): """ Application initialization, automatically run from the :wx:`App` constructor. """ if self._is_standalone: microscope = None else: try: microscope = model.getMicroscope() except (IOError, Pyro4.errors.CommunicationError), e: logging.exception("Failed to connect to back-end") msg = ("The Odemis GUI could not connect to the Odemis back-end:" "\n\n{0}\n\n" "Launch user interface anyway?").format(e) answer = wx.MessageBox(msg, "Connection error", style=wx.YES | wx.NO | wx.ICON_ERROR) if answer == wx.NO: sys.exit(1) microscope = None self.main_data = guimodel.MainGUIData(microscope) # Load the main frame self.main_frame = main_xrc.xrcfr_main(None) #self.main_frame.Bind(wx.EVT_CHAR, self.on_key) log.create_gui_logger(self.main_frame.txt_log, self.main_data.debug) logging.info("\n\n************ Starting Odemis GUI ************\n") logging.info(wx.version()) self.init_gui() # Application successfully launched return True