fsl.utils.platform

This module provides the Platform class, which is a container of information about the current platform we are running on. A single Platform instance is created when this module is first imported, and is available as a module attribute called platform.

fsl.utils.platform.WX_UNKNOWN = 0

Identifier for the Platform.wxFlavour and Platform.wxPlatform properties indicating an unknown/undetermined flavour/platform.

fsl.utils.platform.WX_PYTHON = 1

Identifier for the Platform.wxFlavour property, indicating that we are running standard wx Python.

fsl.utils.platform.WX_PHOENIX = 2

Identifier for the Platform.wxFlavour property, indicating that we are running wx Python/Phoenix.

fsl.utils.platform.WX_MAC_COCOA = 1

Identifier for the Platform.wxPlatform property, indicating that we are running the OSX cocoa wx build.

fsl.utils.platform.WX_MAC_CARBON = 2

Identifier for the Platform.wxPlatform property, indicating that we are running the OSX carbon wx build.

fsl.utils.platform.WX_GTK = 3

Identifier for the Platform.wxPlatform property, indicating that we are running the Linux/GTK wx build.

fsl.utils.platform.isWidgetAlive(widget)
Returns True if the given wx.Window object is “alive” (i.e.

has not been destroyed), False otherwise. Works in both wxPython and wxPython/Phoenix.

Warning

Don’t try to test whether a wx.MenuItem has been destroyed, as it will probably result in segmentation faults. Check the parent wx.Menu instead.

Deprecated in 1.2.2, to be removed in 2.0.0. Use fsleyes_widgets.isalive instead

class fsl.utils.platform.Platform

Bases: fsl.utils.notifier.Notifier

The Platform class contains a handful of properties which contain information about the platform we are running on.

Note

The values of the glVersion and glRenderer properties are not automatically set - they will only contain a value if one is assigned to them. FSLeyes does this during startup, in the fsleyes.gl.bootstrap() function.

os The operating system name.
frozen True if we are running in a compiled/frozen application, False otherwise.
fsldir The FSL installation location.
fsldevdir The FSL development directory location.
haveGui True if we are running with a GUI, False otherwise.
canHaveGui True if it is possible to create a GUI, False otherwise.
inSSHSession True if this application is running over an SSH session, False otherwise.
wxPlatform One of WX_UNKNOWN, WX_MAC_COCOA, WX_MAC_CARBON, or WX_GTK, indicating the wx platform.
wxFlavour One of WX_UNKNOWN, WX_PYTHON or WX_PHOENIX, indicating the wx flavour.
glVersion Returns the available OpenGL version, or None if it has not been set.
glRenderer Returns the available OpenGL renderer, or None if it has not been set.
glIsSoftwareRenderer Returns True if the OpenGL renderer is software based, False otherwise, or None if the renderer has not yet been set.
os

The operating system name. Whatever is returned by the built-in platform.system function.

frozen

True if we are running in a compiled/frozen application, False otherwise.

haveGui

True if we are running with a GUI, False otherwise.

canHaveGui

True if it is possible to create a GUI, False otherwise.

inSSHSession

True if this application is running over an SSH session, False otherwise.

inVNCSession

True if this application is running over a VNC (or similar) session, False otherwise. Currently, the following remote desktop environments are detected:

  • VNC
  • x2go
  • NoMachine
wxPlatform

One of WX_UNKNOWN, WX_MAC_COCOA, WX_MAC_CARBON, or WX_GTK, indicating the wx platform.

wxFlavour

One of WX_UNKNOWN, WX_PYTHON or WX_PHOENIX, indicating the wx flavour.

fsldir

The FSL installation location.

Note

The fsldir property can be updated - when it is changed, any registered listeners are notified via the Notifier interface.

fsldevdir

The FSL development directory location.

fslVersion

Returns the FSL version as a string, e.g. '5.0.9'. Returns None if a FSL installation could not be found.

glVersion

Returns the available OpenGL version, or None if it has not been set.

glRenderer

Returns the available OpenGL renderer, or None if it has not been set.

glIsSoftwareRenderer

Returns True if the OpenGL renderer is software based, False otherwise, or None if the renderer has not yet been set.

Note

This check is based on heuristics, ans is not guaranteed to be correct.

fsl.utils.platform.platform = <fsl.utils.platform.Platform object>

An instance of the Platform class. Feel free to create your own instance, but be aware that if you do so you will not be updated of changes to the Platform.fsldir property.