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

FSLDIR was being set from fsl.utils.settings after AtlasPanel was

created, so AtlasPanel was not being initialised with atlas list.
Fixed, and also added some notes for possible future method to
keep track of changes to FSLDIR (and solve my disabled 'Add standsard'
menu item issue)..
parent f3a3bb25
No related branches found
No related tags found
No related merge requests found
...@@ -104,11 +104,16 @@ def _runGUITool(fslTool, toolArgv): ...@@ -104,11 +104,16 @@ def _runGUITool(fslTool, toolArgv):
""" """
import wx import wx
fslEnvActive = 'FSLDIR' in os.environ # Create the wx.App object befor fslTool.init,
# in case it does GUI stuff. Also create a dummy
# Create a wx.App before init(), # frame - if we don't create a dummy frame, the
# in case it does GUI stuff. # wx.MainLoop call below will just return
app = wx.App() # immediately.
#
# The buildGUI function below will kill the dummy
# frame when it has created the real interface.
app = wx.App()
dummyFrame = wx.Frame(None)
# Call the tool's init # Call the tool's init
# function if there is one # function if there is one
...@@ -144,29 +149,24 @@ def _runGUITool(fslTool, toolArgv): ...@@ -144,29 +149,24 @@ def _runGUITool(fslTool, toolArgv):
ctx = None ctx = None
# Build the GUI # Build the GUI
frame = _buildGUI(toolNamespace, fslTool, ctx, fslEnvActive) frame = _buildGUI(toolNamespace, fslTool, ctx)
frame.Show() frame.Show()
# See comment about the # See comment about the
# dummy frame below # dummy frame below
dummyFrame.Destroy() dummyFrame.Destroy()
_fslDirWarning(frame, fslTool.toolName, fslEnvActive) # Sleep a bit so the main thread (on
# which wx.MainLoop is running) can
time.sleep(0.1) # start.
time.sleep(0.01)
wx.CallAfter(_fslDirWarning,
None,
fslTool.toolName,
'FSLDIR' in os.environ)
wx.CallAfter(realBuild) wx.CallAfter(realBuild)
# Create the wx.App object, and create a dummy
# frame. If we don't create a dummy frame, the
# wx.MainLoop call will just return immediately.
# The buildGUI function above will kill the dummy
# frame when it has created the real interface.
dummyFrame = wx.Frame(None)
threading.Thread(target=buildGUI).start() threading.Thread(target=buildGUI).start()
# The wx.App was created above,
# before calling fslTool.init()
app.MainLoop() app.MainLoop()
...@@ -575,16 +575,13 @@ def _fslDirWarning(parent, toolName, fslEnvActive): ...@@ -575,16 +575,13 @@ def _fslDirWarning(parent, toolName, fslEnvActive):
log.warn(warnmsg) log.warn(warnmsg)
def _buildGUI(args, fslTool, toolCtx, fslEnvActive): def _buildGUI(args, fslTool, toolCtx):
"""Builds a :mod:`wx` GUI for the tool. """Builds a :mod:`wx` GUI for the tool.
:arg fslTool: The ``FSLTool`` instance (see :func:`_loadFSLTool`). :arg fslTool: The ``FSLTool`` instance (see :func:`_loadFSLTool`).
:arg toolCtx: The tool context, as returned by the :arg toolCtx: The tool context, as returned by the
``FSLTool.context`` function. ``FSLTool.context`` function.
:arg fslEnvActive: Set to ``True`` if ``$FSLDIR`` is set, ``False``
otherwise.
""" """
import wx import wx
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
# Author: Paul McCarthy <pauldmccarthy@gmail.com> # Author: Paul McCarthy <pauldmccarthy@gmail.com>
# #
import os
haveGui = False haveGui = False
wxFlavour = None wxFlavour = None
wxPlatform = None wxPlatform = None
...@@ -16,18 +18,28 @@ WX_PHOENIX = 2 ...@@ -16,18 +18,28 @@ WX_PHOENIX = 2
WX_MAC = 1 WX_MAC = 1
WX_GTK = 2 WX_GTK = 2
class Platform(object):
def __init__(self):
try: self.haveGui = False
import wx self.wxFlavour = None
haveGui = True self.wxPlatform = None
except ImportError:
haveGui = False
try:
import wx
self.haveGui = True
if 'phoenix' in wx.PlatformInformation: wxFlavour = WX_PHOENIX except ImportError:
else: wxFlavour = WX_PYTHON pass
if self.haveGui:
if 'phoenix' in wx.PlatformInformation:
self.wxFlavour = WX_PHOENIX
if 'MAC' in wx.Platform:
self.wxPlatform = WX_MAC
if 'MAC' in wx.Platform: wxPlatform = WX_MAC # TODO Make Platform a notifier, so
elif 'GTK' in wx.Platform: wxPlatform = WX_GTK # things can register to listen
# for changes to $FSLDIR
self.fsldir = os.environ['FSLDIR']
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