def Start(self): '''Initialize CPA ''' if hasattr(sys, "frozen") and sys.platform == "darwin": # Some versions of Macos like to put CPA in a sandbox. If we're frozen Java should be packed in, # so let's just figure out the directory on run time. os.environ["CP_JAVA_HOME"] = os.path.abspath( os.path.join(sys.prefix, "..", "Resources/Home")) '''List of tables created by the user during this session''' self.user_tables = [] p = Properties() self.frame = MainGUI(p, None, size=(1000, -1)) self.frame.Show() # Show frame if not p.is_initialized(): from cpa.guiutils import show_load_dialog try: if not show_load_dialog(): example_link_address = 'cellprofileranalyst.org' dlg = wx.MessageDialog( None, 'CellProfiler Analyst requires a properties file. Download an example at %s' % (example_link_address), 'Properties file required', wx.OK) response = dlg.ShowModal() logging.error( 'CellProfiler Analyst requires a properties file.') return False else: db = DBConnect() db.connect() db.register_gui_parent(self.frame) except Exception as e: p._initialized = False # Fully raising the exception during this startup sequence will crash CPA. # So we'll display it manually. show_exception_as_dialog(type(e), e, e.__traceback__, raisefurther=False) logging.critical(e) try: from cpa.updatechecker import check_update check_update(self.frame, event=False) except: logging.warn("CPA was unable to check for updates.") return True
def on_load_properties(self, evt): # Show confirmation dialog. if self.properties.is_initialized(): dlg = wx.MessageDialog( None, "Loading a new file will close all windows and clear unsaved data. Proceed?", 'Load properties file', wx.OK | wx.CANCEL) response = dlg.ShowModal() if response != wx.ID_OK: return # Close all subwindows for window in self.GetChildren(): if isinstance(window, wx.Frame): window.Destroy() # Shut down existing connections and wipe properties. db = DBConnect() db.Disconnect() p = Properties() p.clear() self.console.Clear() if not p.is_initialized(): from cpa.guiutils import show_load_dialog if not show_load_dialog(): example_link_address = 'cellprofileranalyst.org' dlg = wx.MessageDialog( None, 'CellProfiler Analyst requires a properties file. Download an example at %s' % (example_link_address), 'Properties file required', wx.OK) response = dlg.ShowModal() logging.error( 'CellProfiler Analyst requires a properties file.') else: db.connect() db.register_gui_parent(self)