fsleyes_widgets.utils

This package contains a collection of small utility modules for doing random things. A few functions are also defined at the package level:

wxVersion

Return a string containing the "major.minor.patch" version of wxPython that is installed, or None if wxPython is not installed, or its version cannot be determined.

wxFlavour

Determines the version of wxPython being used.

wxPlatform

Returns one of WX_UNKNOWN WX_MAC_COCOA, WX_MAC_CARBON, WX_GTK2, or WX_GTK3, indicating the wx platform, or None if wxPython does not appear to be installed.

frozen

True if we are running in a compiled/frozen application (e.g. pyinstaller, py2app), False otherwise.

canHaveGui

Return True if a display is available, False otherwise.

haveGui

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

inSSHSession

Return True if this application appears to be running over an SSH session, False otherwise.

inVNCSession

Returns True if this application appears to be running over a VNC (or similar) session, False otherwise.

isalive

Returns True if the given wx.Window object is "alive" (i.e. has not been destroyed), False otherwise.

This package can be imported, and all of its functions called (with the exception of isalive()), without wx being installed.

fsleyes_widgets.utils.WX_PYTHON = 1

Constant returned by the wxFlavour() function, indicating that wxPython 3.0.2.0 or older is being used.

fsleyes_widgets.utils.WX_PHOENIX = 2

Constant returned by the wxFlavour() function, indicating that wxPython/Phoenix (>= 3.0.3) is being used.

fsleyes_widgets.utils.WX_UNKNOWN = 0

Constant returned by the wxPlatform() function, indicating that an unknown wx version is being used.

fsleyes_widgets.utils.WX_MAC_COCOA = 1

Constant returned by the wxPlatform() function, indicating that an OSX cocoa wx version is being used.

fsleyes_widgets.utils.WX_MAC_CARBON = 2

Constant returned by the wxPlatform() function, indicating that an OSX carbon wx version is being used.

fsleyes_widgets.utils.WX_GTK = 3

Alias for WX_GTK2 - will be removed in a future version of fsleyes-widgets.

fsleyes_widgets.utils.WX_GTK2 = 3

Constant returned by the wxPlatform() function, indicating that a Linux/GTK3 wx version is being used.

fsleyes_widgets.utils.WX_GTK3 = 4

Constant returned by the wxPlatform() function, indicating that a Linux/GTK3 wx version is being used.

fsleyes_widgets.utils.wxVersion()[source]

Return a string containing the “major.minor.patch” version of wxPython that is installed, or None if wxPython is not installed, or its version cannot be determined.

fsleyes_widgets.utils.wxFlavour()[source]

Determines the version of wxPython being used. Returns WX_PYTHON, WX_PHOENIX, or ``None if wxPython does not appear to be installed.

fsleyes_widgets.utils.wxversion()[source]

Deprecated - use wxFlavour instead.

fsleyes_widgets.utils.wxPlatform()[source]

Returns one of WX_UNKNOWN WX_MAC_COCOA, WX_MAC_CARBON, WX_GTK2, or WX_GTK3, indicating the wx platform, or None if wxPython does not appear to be installed.

fsleyes_widgets.utils.frozen()[source]

True if we are running in a compiled/frozen application (e.g. pyinstaller, py2app), False otherwise.

fsleyes_widgets.utils.canHaveGui()[source]

Return True if a display is available, False otherwise.

fsleyes_widgets.utils.haveGui()[source]

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

This currently equates to testing whether a display is available (see canHaveGui()) and whether a wx.App exists. It previously also tested whether an event loop was running, but this is not compatible with execution from IPython/Jupyter notebook, where the event loop is called periodically, and so is not always running.

fsleyes_widgets.utils.inSSHSession()[source]

Return True if this application appears to be running over an SSH session, False otherwise.

fsleyes_widgets.utils.inVNCSession()[source]

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

  • VNC

  • x2go

  • NoMachine

fsleyes_widgets.utils.isalive(widget)[source]

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.