Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Evan Edmond
fslpy
Commits
59f253e7
Commit
59f253e7
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Open standard action enables itself when the FSLDIR changes.
parent
ea86c585
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/__init__.py
+6
-3
6 additions, 3 deletions
fsl/__init__.py
fsl/fsleyes/actions/openstandard.py
+32
-7
32 additions, 7 deletions
fsl/fsleyes/actions/openstandard.py
with
38 additions
and
10 deletions
fsl/__init__.py
+
6
−
3
View file @
59f253e7
...
@@ -62,6 +62,7 @@ import subprocess
...
@@ -62,6 +62,7 @@ import subprocess
import
fsl.tools
as
tools
import
fsl.tools
as
tools
import
fsl.utils.settings
as
fslsettings
import
fsl.utils.settings
as
fslsettings
import
fsl.utils.platform
as
fslplatform
import
fsl.version
import
fsl.version
...
@@ -566,7 +567,8 @@ def _fslDirWarning(parent, toolName, fslEnvActive):
...
@@ -566,7 +567,8 @@ def _fslDirWarning(parent, toolName, fslEnvActive):
fsldir
=
fslsettings
.
read
(
'
fsldir
'
)
fsldir
=
fslsettings
.
read
(
'
fsldir
'
)
if
fsldir
is
not
None
:
if
fsldir
is
not
None
:
os
.
environ
[
'
FSLDIR
'
]
=
fsldir
os
.
environ
[
'
FSLDIR
'
]
=
fsldir
fslplatform
.
platform
.
fsldir
=
fsldir
return
return
if
haveGui
:
if
haveGui
:
...
@@ -581,8 +583,9 @@ def _fslDirWarning(parent, toolName, fslEnvActive):
...
@@ -581,8 +583,9 @@ def _fslDirWarning(parent, toolName, fslEnvActive):
log
.
debug
(
'
Setting $FSLDIR to {} (specified
'
log
.
debug
(
'
Setting $FSLDIR to {} (specified
'
'
by user)
'
.
format
(
fsldir
))
'
by user)
'
.
format
(
fsldir
))
os
.
environ
[
'
FSLDIR
'
]
=
fsldir
fslplatform
.
platform
.
fsldir
=
fsldir
fslsettings
.
write
(
'
fsldir
'
,
fsldir
)
os
.
environ
[
'
FSLDIR
'
]
=
fsldir
fslsettings
.
write
(
'
fsldir
'
,
fsldir
)
wx
.
CallLater
(
500
,
warn
)
wx
.
CallLater
(
500
,
warn
)
...
...
This diff is collapsed.
Click to expand it.
fsl/fsleyes/actions/openstandard.py
+
32
−
7
View file @
59f253e7
...
@@ -9,10 +9,11 @@ to load in standard space images from the ``$FSLDIR/data/standard/`` directory.
...
@@ -9,10 +9,11 @@ to load in standard space images from the ``$FSLDIR/data/standard/`` directory.
"""
"""
import
os
import
os.path
as
op
import
os.path
as
op
import
action
from
.
import
action
import
fsl.utils.platform
as
fslplatform
class
OpenStandardAction
(
action
.
Action
):
class
OpenStandardAction
(
action
.
Action
):
...
@@ -33,16 +34,40 @@ class OpenStandardAction(action.Action):
...
@@ -33,16 +34,40 @@ class OpenStandardAction(action.Action):
self
.
__overlayList
=
overlayList
self
.
__overlayList
=
overlayList
self
.
__displayCtx
=
displayCtx
self
.
__displayCtx
=
displayCtx
# disable this action
self
.
__setStandardDir
()
# if $FSLDIR is not set
fsldir
=
os
.
environ
.
get
(
'
FSLDIR
'
,
None
)
# If FSLDIR is not set, the setStandardDir
# disables this action. But we'll listen
# for changes to FSLDIR, in case it gets
# set later on.
fslplatform
.
platform
.
register
(
'
{}_{}
'
.
format
(
type
(
self
).
__name__
,
id
(
self
)),
self
.
__setStandardDir
)
def
destroy
(
self
):
"""
Must be called when this ``OpenStandardAction`` is no longer
needed. Performs some clean-up.
"""
fslplatform
.
platform
.
deregister
(
'
{}_{}
'
.
format
(
type
(
self
).
__name__
,
id
(
self
)))
def
__setStandardDir
(
self
,
*
a
):
"""
Called by :meth:`__init__`, and when the
:attr:`~fsl.utils.Platform.fsldir` property is changed. Updates
the path to the FSLDIR standard directory.
"""
fsldir
=
fslplatform
.
platform
.
fsldir
if
fsldir
is
not
None
:
if
fsldir
is
not
None
:
self
.
__stddir
=
op
.
join
(
fsldir
,
'
data
'
,
'
standard
'
)
self
.
__stddir
=
op
.
join
(
fsldir
,
'
data
'
,
'
standard
'
)
else
:
else
:
self
.
__stddir
=
None
self
.
__stddir
=
None
self
.
enabled
=
False
self
.
enabled
=
self
.
__stddir
is
not
None
def
__openStandard
(
self
):
def
__openStandard
(
self
):
"""
Calls the :meth:`.OverlayList.addOverlays` method. If the user
"""
Calls the :meth:`.OverlayList.addOverlays` method. If the user
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment