def run(): overlayList = fsloverlay.OverlayList() displayCtx = dc.DisplayContext(overlayList) lockGroup = dc.OverlayGroup(displayCtx, overlayList) displayCtx.overlayGroups.append(lockGroup) frame[0] = fslframe.FSLeyesFrame(None, overlayList, displayCtx) app[0].SetOverlayListAndDisplayContext(overlayList, displayCtx) app[0].SetTopWindow(frame[0]) frame[0].Show() try: if func is not None: result[0] = func(frame[0], overlayList, displayCtx, *args, **kwargs) except Exception as e: traceback.print_exc() raised[0] = e finally: wx.CallLater(finishingDelay, finish)
def run(): overlayList = fsloverlay.OverlayList() displayCtx = dc.DisplayContext(overlayList) state.frame = fslframe.FSLeyesFrame(None, overlayList, displayCtx) state.app.SetOverlayListAndDisplayContext(overlayList, displayCtx) state.app.SetTopWindow(state.frame) state.frame.Show() try: if func is not None: state.result = func(state.frame, overlayList, displayCtx, *args, **kwargs) except Exception as e: traceback.print_exc() state.raised = e finally: wx.CallLater(finishingDelay, finish)
def ready(): fslgl.bootstrap() overlayList = fsloverlay.OverlayList() displayCtx = fsldc.DisplayContext(overlayList) frame = fslframe.FSLeyesFrame( parent, overlayList, displayCtx, **kwargs) if callback is not None: callback(overlayList, displayCtx, frame)
def ready(): frame = None fslgl.bootstrap() overlayList = fsloverlay.OverlayList() displayCtx = fsldc.DisplayContext(overlayList) if make_fsleyesframe: frame = fslframe.FSLeyesFrame(parent, overlayList, displayCtx, **kwargs) if ownapp: app.SetOverlayListAndDisplayContext(overlayList, displayCtx) # Keep a ref to prevent the app from being GC'd if make_fsleyesframe: frame._embed_app = app called[0] = True ret[0] = (overlayList, displayCtx, frame)
def makeFrame(namespace, displayCtx, overlayList, splash): """Creates the *FSLeyes* interface. This function does the following: 1. Creates the :class:`.FSLeyesFrame` the top-level frame for ``fsleyes``. 2. Configures the frame according to the command line arguments (e.g. ortho or lightbox view). 3. Destroys the splash screen that was created by the :func:`context` function. :arg namespace: Parsed command line arguments, as returned by :func:`parseArgs`. :arg displayCtx: The :class:`.DisplayContext`, as created and returned by :func:`makeDisplayContext`. :arg overlayList: The :class:`.OverlayList`, as created and returned by :func:`makeDisplayContext`. :arg splash: The :class:`.FSLeyesSplash` frame. :returns: the :class:`.FSLeyesFrame` that was created. """ import fsl.utils.idle as idle import fsleyes_widgets.utils.status as status import fsleyes.parseargs as parseargs import fsleyes.frame as fsleyesframe import fsleyes.displaycontext as fsldisplay import fsleyes.layouts as layouts import fsleyes.views.canvaspanel as canvaspanel # Set up the frame scene (a.k.a. layout) # The scene argument can be: # # - The name of a saved (or built-in) layout # # - None, in which case the default or previous # layout is restored, unless a custom script # has been provided. script = namespace.runscript scene = namespace.scene # If a scene/layout or custom script # has not been specified, the default # behaviour is to restore the previous # frame layout. restore = (scene is None) and (script is None) status.update('Creating FSLeyes interface...') frame = fsleyesframe.FSLeyesFrame(None, overlayList, displayCtx, restore, True, fontSize=namespace.fontSize) # Allow files to be dropped # onto FSLeyes to open them dt = fsleyesframe.OverlayDropTarget(overlayList, displayCtx) frame.SetDropTarget(dt) # Make sure the new frame is shown # before destroying the splash screen frame.Show(True) frame.Refresh() frame.Update() # In certain instances under Linux/GTK, # closing the splash screen will crash # the application. No idea why. So we # leave the splash screen hidden, but # not closed, and close it when the main # frame is closed. This also works under # OSX. splash.Hide() splash.Refresh() splash.Update() def onFrameDestroy(ev): ev.Skip() # splash screen may already # have been destroyed try: splash.Close() except Exception: pass frame.Bind(wx.EVT_WINDOW_DESTROY, onFrameDestroy) status.update('Setting up scene...') # Set the default SceneOpts.performance # level so that all created SceneOpts # instances will default to it if namespace.performance is not None: fsldisplay.SceneOpts.performance.setAttribute(None, 'default', namespace.performance) # If a layout has been specified, # we load the layout if namespace.scene is not None: layouts.loadLayout(frame, namespace.scene) # Apply any view-panel specific arguments viewPanels = frame.viewPanels for viewPanel in viewPanels: if not isinstance(viewPanel, canvaspanel.CanvasPanel): continue displayCtx = viewPanel.displayCtx viewOpts = viewPanel.sceneOpts parseargs.applySceneArgs(namespace, overlayList, displayCtx, viewOpts) # If a script has been specified, we run # the script. This has to be done on the # idle loop, because overlays specified # on the command line are loaded on the # idle loop. Therefore, if we schedule the # script on idle (which is a queue), the # script can assume that all overlays have # already been loaded. from fsleyes.actions.runscript import RunScriptAction if script is not None: idle.idle(frame.menuActions[RunScriptAction], script) return frame