コード例 #1
0
    def OnInit(self):
        """Initialize CPA
        """

        """List of tables created by the user during this session"""
        self.user_tables = []

        # splashscreen
        splashimage = cpa.icons.cpa_splash.ConvertToBitmap()
        # If the splash image has alpha, it shows up transparently on
        # windows, so we blend it into a white background.
        splashbitmap = wx.EmptyBitmapRGBA(splashimage.GetWidth(), splashimage.GetHeight(), 255, 255, 255, 255)
        dc = wx.MemoryDC()
        dc.SelectObject(splashbitmap)
        dc.DrawBitmap(splashimage, 0, 0)
        dc.Destroy()  # necessary to avoid a crash in splashscreen
        splash = wx.SplashScreen(splashbitmap, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, 2000, None, -1)
        self.splash = splash

        p = Properties.getInstance()
        if not p.is_initialized():
            from cpa.guiutils import show_load_dialog

            splash.Destroy()
            if not show_load_dialog():
                logging.error("CellProfiler Analyst requires a properties file. Exiting.")
                return False
        self.frame = MainGUI(p, None, size=(860, -1))
        self.frame.Show(True)
        db = cpa.dbconnect.DBConnect.getInstance()
        # Black magic: Bus errors occur on Mac OS X if we wait until
        # the JVM or the wx event look has started to connect. But it
        # has to be done after we have read the properties file. So we
        # do it here.
        db.connect()
        db.register_gui_parent(self.frame)

        # The JVM has to be started after db.connect(), otherwise bus errors
        # occur on Mac OS X.
        javabridge.start_vm(class_path=bioformats.JARS, run_headless=False)
        javabridge.attach()
        javabridge.activate_awt()

        try:
            if __version__ != -1:
                import cellprofiler.utilities.check_for_updates as cfu

                cfu.check_for_updates(
                    "http://cellprofiler.org/CPAupdate.html",
                    max(__version__, cpaprefs.get_skip_version()),
                    new_version_cb,
                    user_agent="CPAnalyst/2.0.%d" % (__version__),
                )
        except ImportError:
            logging.warn(
                "CPA was unable to check for updates. Could not import cellprofiler.utilities.check_for_updates."
            )

        return True
コード例 #2
0
    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
コード例 #3
0
    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)
コード例 #4
0
    def Start(self):
        '''Initialize CPA
        '''

        '''List of tables created by the user during this session'''
        self.user_tables = []

        # splashscreen
        splashimage = cpa.icons.cpa_splash.ConvertToBitmap()
        # If the splash image has alpha, it shows up transparently on
        # windows, so we blend it into a white background.
        splashbitmap = wx.EmptyBitmapRGBA(splashimage.GetWidth(),
                                          splashimage.GetHeight(),
                                          255, 255, 255, 255)
        dc = wx.MemoryDC()
        dc.SelectObject(splashbitmap)
        dc.DrawBitmap(splashimage, 0, 0)
        dc.Destroy() # necessary to avoid a crash in splashscreen
        splash = wx.SplashScreen(splashbitmap, wx.SPLASH_CENTRE_ON_SCREEN |
                                wx.SPLASH_TIMEOUT, 2000, None, -1)
        self.splash = splash

        p = Properties.getInstance()
        if not p.is_initialized():
            from cpa.guiutils import show_load_dialog
            splash.Destroy()
            if not show_load_dialog():
                splash.Destroy()
                example_link_address = 'cellprofiler.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. Exiting.')
                return False

        self.frame = MainGUI(p, None, size=(1000,-1))

        db = DBConnect.getInstance()
        # Black magic: Bus errors occur on Mac OS X if we wait until
        # the JVM or the wx event look has started to connect. But it
        # has to be done after we have read the properties file. So we
        # do it here.
        db.connect()
        db.register_gui_parent(self.frame)

        # The JVM has to be started after db.connect(), otherwise bus errors
        # occur on Mac OS X.
        javabridge.start_vm(class_path=bioformats.JARS, run_headless=True)

        # removes the log4j warnings
        javabridge.attach()

        # TODO: check for updates
        try:
            if __version__ != -1:
                import cpa.util.check_for_updates as cfu
                cfu.check_for_updates('http://cellprofiler.org/updates/CPA.html',
                                      max(__version__, cpa.cpaprefs.get_skip_version()),
                                      new_version_cb,
                                      user_agent='CPAnalyst/%s'%(__version__))
        except ImportError:
            logging.warn("CPA was unable to check for updates. Could not import cpa.util.check_for_updates.")

        self.frame.Show() # Show frame
        return True
コード例 #5
0
    def Start(self):
        '''Initialize CPA
        '''

        '''List of tables created by the user during this session'''
        self.user_tables = []

        # splashscreen
        splashimage = cpa.icons.cpa_splash.ConvertToBitmap()
        # If the splash image has alpha, it shows up transparently on
        # windows, so we blend it into a white background.
        splashbitmap = wx.EmptyBitmapRGBA(splashimage.GetWidth(),
                                          splashimage.GetHeight(),
                                          255, 255, 255, 255)
        dc = wx.MemoryDC()
        dc.SelectObject(splashbitmap)
        dc.DrawBitmap(splashimage, 0, 0)
        dc.Destroy() # necessary to avoid a crash in splashscreen
        splash = wx.SplashScreen(splashbitmap, wx.SPLASH_CENTRE_ON_SCREEN |
                                wx.SPLASH_TIMEOUT, 2000, None, -1)
        self.splash = splash

        p = Properties.getInstance()
        if not p.is_initialized():
            from cpa.guiutils import show_load_dialog
            splash.Destroy()
            if not show_load_dialog():
                splash.Destroy()
                example_link_address = 'cellprofiler.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. Exiting.')
                return False

        self.frame = MainGUI(p, None, size=(1000,-1))
        # def show_frame():
        #     import time
        #     res = self.frame.Show()
        # wx.CallAfter(show_frame)
        db = cpa.dbconnect.DBConnect.getInstance()
        # Black magic: Bus errors occur on Mac OS X if we wait until
        # the JVM or the wx event look has started to connect. But it
        # has to be done after we have read the properties file. So we
        # do it here.
        db.connect()
        db.register_gui_parent(self.frame)

        # The JVM has to be started after db.connect(), otherwise bus errors
        # occur on Mac OS X.
        javabridge.start_vm(class_path=bioformats.JARS, run_headless=True)

        # removes the log4j warnings
        from bioformats import log4j
        log4j.basic_config()
        javabridge.attach()
        # javabridge.activate_awt()

        try:
            if __version__ != -1:
                import cpa.util.check_for_updates as cfu
                cfu.check_for_updates('http://cellprofiler.org/updates/CPA.html',
                                      max(__version__, cpa.cpaprefs.get_skip_version()),
                                      new_version_cb,
                                      user_agent='CPAnalyst/%s'%(__version__))
        except ImportError:
            logging.warn("CPA was unable to check for updates. Could not import cpa.util.check_for_updates.")
        
        self.frame.Show() # Show frame
        return True