fsleyes.main¶
This module provides the entry point to FSLeyes, the FSL image viewer.
Call the main() function to start the main FSLeyes application.
The embed() function can be called to open a FSLeyesFrame
within an existing application.
See the fsleyes package documentation for more details on fsleyes.
Note
Even though fsleyes (this module) and fsleyes.render (the
off-screen renderer) are intended to be separate applications, the
current version of PyInstaller (3.x) does not support bundling of
multiple executables
(https://github.com/pyinstaller/pyinstaller/issues/1527).
So at this point in time, fsleyes.render can be invoked via
fsleyes.main by passing 'render' as the first argument,
e.g.:
python -m fsleyes.main render ...
-
class
fsleyes.main.FSLeyesApp¶ Bases:
__main__.MockClassFSLeyes-specific sub-class of
wx.App.-
ModalHook= <MagicMock spec='str' id='139845834161064'>¶
-
__init__()¶ Create a
FSLeyesApp.
-
modals¶ Returns a list of all currently open modal windows.
-
SetOverlayListAndDisplayContext(overlayList, displayCtx)¶ References to the
OverlayListand masterDisplayContextmust be passed to theFSLeyesAppvia this method.
-
MacReopenApp()¶ On OSX, make sure that the FSLeyes frame is restored if it is minimised, and (e.g.) the dock icon is clicked.
-
MacOpenFile(filename)¶ On OSX, support opening files via context menu, and files dropped on the application icon.
-
MacOpenURL(url)¶ On OSX, support opening files via a
fsleyes://url.
-
MacOpenFiles(filenames)¶ On OSX, support opening files via context menu, and files dropped on the application icon.
-
__module__= 'fsleyes.main'¶
-
-
fsleyes.main.main(args=None)¶ FSLeyes entry point. Shows a
FSLeyesSplashscreen, parses command line arguments, and shows aFSLeyesFrame. Returns an exit code.
-
fsleyes.main.embed(parent, callback=None, **kwargs)¶ Initialise FSLeyes and create a
FSLeyesFrame, when running within another application.Parameters: - parent –
wxparent object - callback –
A function which will be called when FSLeyes is ready. Must accept three positional arguments:
- The
OverlayList - The master
DisplayContext - The
FSLeyesFrame
- The
All other arguments are passed to
FSLeyesFrame.__init__().- parent –
-
fsleyes.main.initialise(splash, namespace, callback)¶ Called by
main(). Bootstraps/Initialises various parts of FSLeyes.The
callbackfunction is asynchronously called when the initialisation is complete.Parameters: - splash – The
FSLeyesSplashscreen. - namespace – The
argparse.Namespaceobject containing parsed command line arguments. - callback – Function which is called when initialisation is done.
- splash – The
-
fsleyes.main.shutdown()¶ Called when FSLeyes exits normally (i.e. the user closes the window). Does some final clean-up before exiting.
-
fsleyes.main.parseArgs(argv)¶ Parses the given
fsleyescommand line arguments. See theparseargsmodule for details on thefsleyescommand line interface.Parameters: argv – command line arguments for fsleyes.
-
fsleyes.main.makeDisplayContext(namespace, splash)¶ Creates the top-level FSLeyes
DisplayContextandOverlayList.This function does the following:
- Creates the
OverlayListand the top levelDisplayContext. - Loads and configures all of the overlays which were passed in on the command line.
Parameters: - namesace – Parsed command line arguments (see
parseArgs()). - splash – The
FSLeyesSplashframe, created ininit().
Returns: a tuple containing: - the
OverlayList- the masterDisplayContext- Creates the
-
fsleyes.main.makeFrame(namespace, displayCtx, overlayList, splash)¶ Creates the FSLeyes interface.
This function does the following:
- Creates the
FSLeyesFramethe top-level frame forfsleyes. - Configures the frame according to the command line arguments (e.g. ortho or lightbox view).
- Destroys the splash screen that was created by the
context()function.
Parameters: - namespace – Parsed command line arguments, as returned by
parseArgs(). - displayCtx – The
DisplayContext, as created and returned bymakeDisplayContext(). - overlayList – The
OverlayList, as created and returned bymakeDisplayContext(). - splash – The
FSLeyesSplashframe.
Returns: the
FSLeyesFramethat was created.- Creates the
-
fsleyes.main.fslDirWarning(parent)¶ Checks to see if the
$FSLDIRenvironment variable is set, or if a FSL installation directory has been saved previously. If not, displays a warning via aFSLDirDialog.Parameters: parent – A wxparent object.