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

Merge branch 'master' into oxford

parents beccc8aa 44ad40d5
No related branches found
No related tags found
No related merge requests found
...@@ -289,7 +289,7 @@ def _loadFSLTool(moduleName): ...@@ -289,7 +289,7 @@ def _loadFSLTool(moduleName):
# Each FSL tool module may specify several things # Each FSL tool module may specify several things
toolName = getattr(module, 'FSL_TOOLNAME', None) toolName = getattr(module, 'FSL_TOOLNAME', None)
helpPage = getattr(module, 'FSL_HELPPAGE', 'index') helpPage = getattr(module, 'FSL_HELPPAGE', None)
init = getattr(module, 'FSL_INIT', None) init = getattr(module, 'FSL_INIT', None)
parseArgs = getattr(module, 'FSL_PARSEARGS', None) parseArgs = getattr(module, 'FSL_PARSEARGS', None)
context = getattr(module, 'FSL_CONTEXT', None) context = getattr(module, 'FSL_CONTEXT', None)
...@@ -600,10 +600,16 @@ def _buildGUI(args, fslTool, toolCtx): ...@@ -600,10 +600,16 @@ def _buildGUI(args, fslTool, toolCtx):
actions = [] actions = []
def help(ev):
if fslTool.helpPage is not None:
webpage.openPage(fslTool.helpPage)
else:
webpage.openLocalHelp(fslTool.toolName)
actions.append(( actions.append((
wx.ID_HELP, wx.ID_HELP,
'{} Help'.format(fslTool.toolName), '{} Help'.format(fslTool.toolName),
lambda *ev: webpage.openFSLHelp(fslTool.helpPage))) help))
for (name, func) in fslTool.actions: for (name, func) in fslTool.actions:
actions.append((wx.ID_ANY, name, lambda ev, f=func: f(frame, toolCtx))) actions.append((wx.ID_ANY, name, lambda ev, f=func: f(frame, toolCtx)))
......
...@@ -336,7 +336,6 @@ def runBet(parent, opts): ...@@ -336,7 +336,6 @@ def runBet(parent, opts):
FSL_TOOLNAME = 'BET' FSL_TOOLNAME = 'BET'
FSL_HELPPAGE = 'bet'
FSL_CONTEXT = lambda *a: Options() FSL_CONTEXT = lambda *a: Options()
FSL_INTERFACE = interface FSL_INTERFACE = interface
FSL_ACTIONS = [('Run BET', runBet)] FSL_ACTIONS = [('Run BET', runBet)]
...@@ -551,6 +551,5 @@ def interface(parent, args, featOpts): ...@@ -551,6 +551,5 @@ def interface(parent, args, featOpts):
FSL_TOOLNAME = 'FEAT' FSL_TOOLNAME = 'FEAT'
FSL_HELPPAGE = 'feat'
FSL_CONTEXT = lambda *a: Options() FSL_CONTEXT = lambda *a: Options()
FSL_INTERFACE = interface FSL_INTERFACE = interface
...@@ -195,7 +195,6 @@ def interface(parent, args, opts): ...@@ -195,7 +195,6 @@ def interface(parent, args, opts):
FSL_TOOLNAME = 'FLIRT' FSL_TOOLNAME = 'FLIRT'
FSL_HELPPAGE = 'flirt'
FSL_CONTEXT = lambda *a: Options() FSL_CONTEXT = lambda *a: Options()
FSL_INTERFACE = interface FSL_INTERFACE = interface
FSL_ACTIONS = [('Run FLIRT', runFlirt)] FSL_ACTIONS = [('Run FLIRT', runFlirt)]
...@@ -13,38 +13,50 @@ The following functions are provided: ...@@ -13,38 +13,50 @@ The following functions are provided:
:nosignatures: :nosignatures:
openPage openPage
openFSLHelp localHelpUrl
openLocalHelp
""" """
import os import os
import webbrowser import os.path as op
import webbrowser
def openPage(url): def openPage(url):
"""Opens the given URL in the system-default web browser.""" """Opens the given URL in the system-default web browser."""
webbrowser.open(url) webbrowser.open(url)
def openFSLHelp(toolName): def localHelpUrl(toolName):
"""Attempts to open the FSL help documentation for the given FSL tool. """Checks the ``$FSLDIR`` to see if a local help page exists for the
If the ``$FSLDIR`` environment variable is not set, pops up a warning FSL tool with the specified name.
message instead.
""" """
fsldir = os.environ.get('FSLDIR', None)
import wx if fsldir is None:
return None
fsldir = os.environ.get('FSLDIR', None) toolName = toolName.lower()
url = 'file://{}/doc/redirects/{}.html'.format(fsldir, toolName) localUrl = op.join(fsldir, 'doc', 'redirects', '{}.html'.format(toolName))
if op.exists(localUrl):
import urlparse
import urllib
return urlparse.urljoin(
'file:', urllib.pathname2url(localUrl))
if fsldir is not None: return None
openPage(url)
def openLocalHelp(toolName):
"""Attempts to open the locally hosted FSL help documentation
for the given FSL tool. If there is no help page for the
given tool, attempts to open the FSL wiki.
"""
else: localUrl = localHelpUrl(toolName)
msg = 'The FSLDIR environment variable is not set - I don\'t '\ if localUrl is None:
'know where to find the FSL documentation.' localUrl = "http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/"
wx.MessageDialog( openPage(localUrl)
None,
message=msg,
style=wx.OK | wx.ICON_ERROR).ShowModal()
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