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(): ...@@ -88,13 +88,8 @@ def _haveWX():
"""Returns ``True`` if we are running within a ``wx`` application, """Returns ``True`` if we are running within a ``wx`` application,
``False`` otherwise. ``False`` otherwise.
""" """
import fsl.utils.platform as fslplatform
try: return fslplatform.platform.haveGui
import wx
return wx.GetApp() is not None
except ImportError:
return False
def run(task, onFinish=None, onError=None, name=None): def run(task, onFinish=None, onError=None, name=None):
......
...@@ -79,6 +79,7 @@ class Platform(notifier.Notifier): ...@@ -79,6 +79,7 @@ class Platform(notifier.Notifier):
frozen frozen
fsldir fsldir
haveGui haveGui
canHaveGui
inSSHSession inSSHSession
wxPlatform wxPlatform
wxFlavour wxFlavour
...@@ -100,6 +101,7 @@ class Platform(notifier.Notifier): ...@@ -100,6 +101,7 @@ class Platform(notifier.Notifier):
self.__fsldir = os.environ.get('FSLDIR', None) self.__fsldir = os.environ.get('FSLDIR', None)
self.__haveGui = False self.__haveGui = False
self.__canHaveGui = False
self.__inSSHSession = False self.__inSSHSession = False
self.__wxFlavour = None self.__wxFlavour = None
self.__wxPlatform = None self.__wxPlatform = None
...@@ -107,8 +109,13 @@ class Platform(notifier.Notifier): ...@@ -107,8 +109,13 @@ class Platform(notifier.Notifier):
self.__glRenderer = None self.__glRenderer = None
try: try:
import wx import wx
self.__haveGui = True
self.__canHaveGui = True
if wx.GetApp() is not None:
self.__haveGui = True
except ImportError: except ImportError:
pass pass
...@@ -168,6 +175,12 @@ class Platform(notifier.Notifier): ...@@ -168,6 +175,12 @@ class Platform(notifier.Notifier):
return self.__haveGui return self.__haveGui
@property
def canHaveGui(self):
"""``True`` if it is possible to create a GUI, ``False`` otherwise. """
return self.__canHaveGui
@property @property
def inSSHSession(self): def inSSHSession(self):
"""``True`` if this application is running over an SSH session, """``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