diff --git a/fsl/utils/async.py b/fsl/utils/async.py index bddc86a288eb4972c583b47c4ccb7035cba7fbd4..8ab9a7b6a3c5bc200ddb77f41f81eb78afde77c4 100644 --- a/fsl/utils/async.py +++ b/fsl/utils/async.py @@ -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): diff --git a/fsl/utils/platform.py b/fsl/utils/platform.py index e0effb6999c7b2d938aaf537ed161c8b8c27870e..ad4fe6a516814b771565a275842435c16d456e4a 100644 --- a/fsl/utils/platform.py +++ b/fsl/utils/platform.py @@ -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,