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__.MockClass
FSLeyes-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
OverlayList
and masterDisplayContext
must be passed to theFSLeyesApp
via 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
FSLeyesSplash
screen, 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 –
wx
parent 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
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.
- 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
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)¶ 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
- Creates the
-
fsleyes.main.
makeFrame
(namespace, displayCtx, overlayList, splash)¶ 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.
Returns: the
FSLeyesFrame
that was created.- Creates the
-
fsleyes.main.
fslDirWarning
(parent)¶ Checks to see if the
$FSLDIR
environment variable is set, or if a FSL installation directory has been saved previously. If not, displays a warning via aFSLDirDialog
.Parameters: parent – A wx
parent object.