Skip to content

Commit 7c1bcf4

Browse files
committed
Merge pull request #72 from dengemann/fix_bin
FIX: Increase backend flexibility in pysurfer command line interface
2 parents 5b6b177 + f4b7889 commit 7c1bcf4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

bin/pysurfer

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ IPython on itself to then drop the user into an IPython environment.
77
import os
88
import sys
99
from surfer._commandline import parser
10+
from distutils.version import LooseVersion
11+
import importlib
12+
1013

1114
if __name__ == '__main__':
1215
is_ipython = False
@@ -49,12 +52,18 @@ if __name__ == '__main__':
4952
path = os.path.split(__file__)[0]
5053
load_file = __file__
5154
import IPython
52-
if IPython.__version__ < '0.11':
55+
if LooseVersion(IPython.__version__) < '0.11':
5356
flag = '-nobanner '
5457
flag += '-wthread '
5558
else:
5659
flag = '--no-banner '
57-
flag += '--gui=wx -i '
60+
try:
61+
gui = 'wx'
62+
importlib.import_module(gui)
63+
except ImportError:
64+
pass
65+
gui = 'qt'
66+
flag += '--gui={gui} -i '.format(gui=gui)
5867
cmd = 'ipython %s ' % (flag + __file__ +
5968
' "%s"' % ' '.join(sys.argv[1:]))
6069
os.system(cmd)
@@ -67,7 +76,7 @@ if __name__ == '__main__':
6776
confkeys = ["size", "background", "cortex"]
6877
argdict = args.__dict__
6978
config_opts = dict([(k, v) for k, v in argdict.items()
70-
if k in confkeys and v])
79+
if k in confkeys and v])
7180
views = args.views
7281

7382
# Load up the figure and underlying brain object

0 commit comments

Comments
 (0)