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>.MockClass
FSLeyes-specific sub-class of
wx.App
.- ModalHook = <MagicMock spec='str' id='140112345211584'>
- property modals
Returns a list of all currently open modal windows.
- SetOverlayListAndDisplayContext(overlayList, displayCtx)[source]
References to the
OverlayList
and masterDisplayContext
must be passed to theFSLeyesApp
via 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
FSLeyesSplash
screen, 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 aFSLeyesFrame
is not created. If you set this toFalse
, you must ensure that awx.App
object exists before calling this function.- Returns
A tuple containing:
The
OverlayList
The master
DisplayContext
The
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
callback
function is asynchronously called when the initialisation is complete.- Parameters
splash – The
FSLeyesSplash
screen.namespace – The
argparse.Namespace
object 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
ev
arguments, but ignores its value.
- fsleyes.main.parseArgs(argv)[source]
Parses the given
fsleyes
command line arguments. See theparseargs
module for details on thefsleyes
command line interface.- Parameters
argv – command line arguments for
fsleyes
.
- fsleyes.main.makeDisplayContext(namespace, splash)[source]
Creates the top-level FSLeyes
DisplayContext
andOverlayList
.This function does the following:
Creates the
OverlayList
and 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
FSLeyesSplash
frame, 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
FSLeyesFrame
the 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
FSLeyesSplash
frame.closeHandlers – List of event handlers to be called when the
FSLeyesFrame
closes.
- Returns
the
FSLeyesFrame
that was created.