Skip to content
Snippets Groups Projects
Commit ae3bd438 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Platform.haveGui is only true if a wx.App is running. New

Platform.canHaveGui, can be used to tell whether we are able to create a
GUI. Async modified to use platform.haveGui instead of performing its
own test.
parent 0d8b518d
No related branches found
No related tags found
No related merge requests found
......@@ -88,13 +88,8 @@ def _haveWX():
"""Returns ``True`` if we are running within a ``wx`` application,
``False`` otherwise.
"""
try:
import wx
return wx.GetApp() is not None
except ImportError:
return False
import fsl.utils.platform as fslplatform
return fslplatform.platform.haveGui
def run(task, onFinish=None, onError=None, name=None):
......
......@@ -79,6 +79,7 @@ class Platform(notifier.Notifier):
frozen
fsldir
haveGui
canHaveGui
inSSHSession
wxPlatform
wxFlavour
......@@ -100,6 +101,7 @@ class Platform(notifier.Notifier):
self.__fsldir = os.environ.get('FSLDIR', None)
self.__haveGui = False
self.__canHaveGui = False
self.__inSSHSession = False
self.__wxFlavour = None
self.__wxPlatform = None
......@@ -107,8 +109,13 @@ class Platform(notifier.Notifier):
self.__glRenderer = None
try:
import wx
self.__haveGui = True
self.__canHaveGui = True
if wx.GetApp() is not None:
self.__haveGui = True
except ImportError:
pass
......@@ -168,6 +175,12 @@ class Platform(notifier.Notifier):
return self.__haveGui
@property
def canHaveGui(self):
"""``True`` if it is possible to create a GUI, ``False`` otherwise. """
return self.__canHaveGui
@property
def inSSHSession(self):
"""``True`` if this application is running over an SSH session,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment