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[source]
Bases:
__main__.docbuilder.run.<locals>.MockClassFSLeyes-specific sub-class of
wx.App.- ModalHook = <MagicMock spec='str' id='139881573613920'>
- property modals
Returns a list of all currently open modal windows.
- SetOverlayListAndDisplayContext(overlayList, displayCtx)[source]
References to the
OverlayListand masterDisplayContextmust be passed to theFSLeyesAppvia this method.
- MacReopenApp()[source]
On OSX, make sure that the FSLeyes frame is restored if it is minimised, and (e.g.) the dock icon is clicked.
- MacOpenFile(filename)[source]
On OSX, support opening files via context menu, and files dropped on the application icon.
- MacOpenFiles(filenames)[source]
On OSX, support opening files via context menu, and files dropped on the application icon.
- __module__ = 'fsleyes.main'
- fsleyes.main.main(args=None)[source]
FSLeyes entry point. Shows a
FSLeyesSplashscreen, parses command line arguments, and shows aFSLeyesFrame. Returns an exit code.
- fsleyes.main.embed(mkFrame=True, **kwargs)[source]
Initialise FSLeyes and create a
FSLeyesFrame, when running within another application.Note
In most cases, this function must be called from the
wx.MainLoop.- Parameters
mkFrame – Defaults to
True. IfFalse, FSLeyes is initialised, but aFSLeyesFrameis not created. If you set this toFalse, you must ensure that awx.Appobject exists before calling this function.- Returns
A tuple containing:
The
OverlayListThe master
DisplayContextThe
FSLeyesFrame(orNone, ifmakeFrame is False).
All other arguments are passed to
FSLeyesFrame.__init__().
- fsleyes.main.initialise(splash, namespace, callback)[source]
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.
- fsleyes.main.shutdown(ev=None)[source]
Called when FSLeyes exits normally (i.e. the user closes the window). Does some final clean-up before exiting.
This function is used as a wxpython event handler, so it accepts an
evarguments, but ignores its value.
- fsleyes.main.parseArgs(argv)[source]
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)[source]
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
- fsleyes.main.makeFrame(namespace, displayCtx, overlayList, splash, closeHandlers)[source]
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.closeHandlers – List of event handlers to be called when the
FSLeyesFramecloses.
- Returns
the
FSLeyesFramethat was created.