Exemplo n.º 1
0
    def OnInit(self):
        # The wx.StandardPaths aren't available until this is set.
        self.SetAppName('CellProfiler2.0')

        wx.InitAllImageHandlers()

        if self.show_splashbox:
            # If the splash image has alpha, it shows up transparently on
            # windows, so we blend it into a white background.
            splashbitmap = wx.EmptyBitmapRGBA(CellProfilerSplash.GetWidth(),
                                              CellProfilerSplash.GetHeight(),
                                              255, 255, 255, 255)
            dc = wx.MemoryDC()
            dc.SelectObject(splashbitmap)
            dc.DrawBitmap(wx.BitmapFromImage(CellProfilerSplash), 0, 0)
            dc.SelectObject(wx.NullBitmap)
            dc.Destroy()  # necessary to avoid a crash in splashscreen
            self.splash = wx.SplashScreen(
                splashbitmap,
                wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_NO_TIMEOUT, 2000, None,
                -1)
            self.splash_timer = wx.Timer()
            self.splash_timer.Bind(wx.EVT_TIMER, self.destroy_splash_screen)
            self.splash_timer.Start(milliseconds=2000, oneShot=True)
        else:
            self.splash = None

        if self.check_for_new_version:
            self.new_version_check()

        from cellprofiler.gui.cpframe import CPFrame
        self.frame = CPFrame(None, -1, "Cell Profiler")
        self.destroy_splash_screen()
        self.frame.start(self.workspace_path, self.pipeline_path)
        if self.abort_initialization:
            return 0

        # set up error dialog for uncaught exceptions
        def show_errordialog(type, exc, tb):
            def doit():
                cpp.cancel_progress()
                display_error_dialog(
                    self.frame,
                    exc,
                    None,
                    tb=tb,
                    continue_only=True,
                    message="Exception in CellProfiler core processing")
                # continue is really the only choice

            wx.CallAfter(doit)

        # replace default hook with error dialog
        self.orig_excepthook = sys.excepthook
        sys.excepthook = show_errordialog
        self.SetTopWindow(self.frame)
        self.frame.Show()
        if self.frame.startup_blurb_frame.IsShownOnScreen():
            self.frame.startup_blurb_frame.Raise()
        return 1
Exemplo n.º 2
0
 def set_pipeline(self, module):
     app = wx.GetApp()
     if app is None:
         app = wx.PySimpleApp(True)
     from cellprofiler.gui.cpframe import CPFrame
     app.frame = CPFrame(None)
     pipeline = app.frame.pipeline 
     while(len(pipeline.modules())):
         pipeline.remove_module(1)
     module.module_num = 1
     pipeline.add_module(module)
     app.frame.module_view.set_selection(1)
     app.ProcessPendingEvents()
     return app
Exemplo n.º 3
0
    def OnInit(self):
        # The wx.StandardPaths aren't available until this is set.
        self.SetAppName('CellProfiler2.0')

        wx.InitAllImageHandlers()

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

        if self.check_for_new_version:
            self.new_version_check()

        from cellprofiler.gui.cpframe import CPFrame
        self.frame = CPFrame(None, -1, "Cell Profiler")

        # set up error dialog for uncaught exceptions
        def show_errordialog(type, exc, tb):
            def doit():
                display_error_dialog(
                    self.frame,
                    exc,
                    None,
                    tb=tb,
                    continue_only=True,
                    message="Exception in CellProfiler core processing")
                # continue is really the only choice

            wx.CallAfter(doit)

        # replace default hook with error dialog
        self.orig_excepthook = sys.excepthook
        sys.excepthook = show_errordialog

        self.SetTopWindow(self.frame)
        self.frame.Show()
        return 1