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='140735754811904'>
__init__()[source]

Create a FSLeyesApp.

property modals

Returns a list of all currently open modal windows.

SetOverlayListAndDisplayContext(overlayList, displayCtx)[source]

References to the OverlayList and master DisplayContext must be passed to the FSLeyesApp 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.

MacOpenURL(url)[source]

On OSX, support opening files via a fsleyes:// url.

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 a FSLeyesFrame. 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. If False, FSLeyes is initialised, but a FSLeyesFrame is not created. If you set this to False, you must ensure that a wx.App object exists before calling this function.

Returns

A tuple containing:

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 the parseargs module for details on the fsleyes command line interface.

Parameters

argv – command line arguments for fsleyes.

fsleyes.main.makeDisplayContext(namespace, splash)[source]

Creates the top-level FSLeyes DisplayContext and OverlayList .

This function does the following:

  1. Creates the OverlayList and the top level DisplayContext.

  2. Loads and configures all of the overlays which were passed in on the command line.

Parameters
Returns

a tuple containing: - the OverlayList - the master DisplayContext

fsleyes.main.makeFrame(namespace, displayCtx, overlayList, splash, closeHandlers)[source]

Creates the FSLeyes interface.

This function does the following:

  1. Creates the 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 context() function.

Parameters
Returns

the FSLeyesFrame that was created.

fsleyes.main.fslDirWarning(parent)[source]

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 a FSLDirDialog.

Parameters

parent – A wx parent object.