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
Model registry
Operate
Environments
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
FSL
fslpy
Commits
af99f14e
Commit
af99f14e
authored
3 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF: Only import wx on access, not when Platform obj is created
parent
f3d34686
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/platform.py
+29
-26
29 additions, 26 deletions
fsl/utils/platform.py
with
29 additions
and
26 deletions
fsl/utils/platform.py
+
29
−
26
View file @
af99f14e
...
...
@@ -111,26 +111,15 @@ class Platform(notifier.Notifier):
self
.
WX_MAC_CARBON
=
WX_MAC_CARBON
self
.
WX_GTK
=
WX_GTK
self
.
__inSSHSession
=
False
self
.
__inVNCSession
=
False
# initialise fsldir - see fsldir.setter
self
.
fsldir
=
self
.
fsldir
# These are all initialised on first access
self
.
__glVersion
=
None
self
.
__glRenderer
=
None
self
.
__glIsSoftware
=
None
self
.
__fslVersion
=
None
# initialise fsldir - see fsldir.setter
self
.
fsldir
=
self
.
fsldir
# Determine if a display is available. We do
# this once at init (instead of on-demand in
# the canHaveGui method) because calling the
# IsDisplayAvailable function will cause the
# application to steal focus under OSX!
try
:
import
wx
self
.
__canHaveGui
=
wx
.
App
.
IsDisplayAvailable
()
except
ImportError
:
self
.
__canHaveGui
=
False
self
.
__canHaveGui
=
None
# If one of the SSH_/VNC environment
# variables is set, then we're probably
...
...
@@ -177,7 +166,7 @@ class Platform(notifier.Notifier):
the event loop is called periodically, and so is not always running.
"""
try
:
import
wx
import
wx
# pylint: disable=import-outside-toplevel
app
=
wx
.
GetApp
()
# TODO Previously this conditional
...
...
@@ -216,6 +205,17 @@ class Platform(notifier.Notifier):
'
Equivalent functionality is available in fsleyes-widgets.
'
)
def
canHaveGui
(
self
):
"""
``True`` if it is possible to create a GUI, ``False`` otherwise.
"""
# Determine if a display is available. Note that
# calling the IsDisplayAvailable function will
# cause the application to steal focus under OSX!
if
self
.
__canHaveGui
is
None
:
try
:
import
wx
# pylint: disable=import-outside-toplevel
self
.
__canHaveGui
=
wx
.
App
.
IsDisplayAvailable
()
except
ImportError
:
self
.
__canHaveGui
=
False
return
self
.
__canHaveGui
...
...
@@ -261,14 +261,14 @@ class Platform(notifier.Notifier):
if
not
self
.
canHaveGui
:
return
WX_UNKNOWN
import
wx
import
wx
# pylint: disable=import-outside-toplevel
pi
=
[
t
.
lower
()
for
t
in
wx
.
PlatformInfo
]
if
any
(
[
'
cocoa
'
in
p
for
p
in
pi
]
):
plat
=
WX_MAC_COCOA
elif
any
(
[
'
carbon
'
in
p
for
p
in
pi
]
):
plat
=
WX_MAC_CARBON
elif
any
(
[
'
gtk
'
in
p
for
p
in
pi
]
):
plat
=
WX_GTK
else
:
plat
=
WX_UNKNOWN
if
any
(
'
cocoa
'
in
p
for
p
in
pi
):
plat
=
WX_MAC_COCOA
elif
any
(
'
carbon
'
in
p
for
p
in
pi
):
plat
=
WX_MAC_CARBON
elif
any
(
'
gtk
'
in
p
for
p
in
pi
):
plat
=
WX_GTK
else
:
plat
=
WX_UNKNOWN
if
plat
is
WX_UNKNOWN
:
log
.
warning
(
'
Could not determine wx platform from
'
...
...
@@ -290,7 +290,7 @@ class Platform(notifier.Notifier):
if
not
self
.
canHaveGui
:
return
WX_UNKNOWN
import
wx
import
wx
# pylint: disable=import-outside-toplevel
pi
=
[
t
.
lower
()
for
t
in
wx
.
PlatformInfo
]
isPhoenix
=
False
...
...
@@ -323,7 +323,9 @@ class Platform(notifier.Notifier):
@property
def
fslwsl
(
self
):
"""
Boolean flag indicating whether FSL is installed in Windows Subsystem for Linux
"""
"""
Boolean flag indicating whether FSL is installed in Windows
Subsystem for Linux
"""
return
self
.
fsldir
is
not
None
and
self
.
fsldir
.
startswith
(
"
\\\\
wsl$
"
)
...
...
@@ -352,8 +354,9 @@ class Platform(notifier.Notifier):
if
op
.
exists
(
versionFile
):
with
open
(
versionFile
,
'
rt
'
)
as
f
:
# split string at colon for new hash style versions
# first object in list is the non-hashed version string (e.g. 6.0.2)
# if no ":hash:" then standard FSL version string is still returned
# first object in list is the non-hashed version string
# (e.g. 6.0.2) if no ":hash:" then standard FSL version
# string is still returned
self
.
__fslVersion
=
f
.
read
().
strip
().
split
(
"
:
"
)[
0
]
self
.
notify
(
value
=
value
)
...
...
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