Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
1f0f36db
Commit
1f0f36db
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Async.run does not create a separate thread if wx is not
running. GLModel has to implement GLObject.ready() method.
parent
952e6cae
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fsl/__init__.py
+4
-1
4 additions, 1 deletion
fsl/__init__.py
fsl/fsleyes/gl/glmodel.py
+6
-0
6 additions, 0 deletions
fsl/fsleyes/gl/glmodel.py
fsl/utils/async.py
+23
-16
23 additions, 16 deletions
fsl/utils/async.py
with
33 additions
and
17 deletions
fsl/__init__.py
+
4
−
1
View file @
1f0f36db
...
@@ -165,7 +165,10 @@ def runTool(toolName, args, **kwargs):
...
@@ -165,7 +165,10 @@ def runTool(toolName, args, **kwargs):
"""
"""
args
=
[
toolName
]
+
args
args
=
[
toolName
]
+
args
if
log
.
getEffectiveLevel
()
==
logging
.
DEBUG
:
args
=
[
'
-vvv
'
]
+
args
# If we are running from a compiled fsleyes
# If we are running from a compiled fsleyes
# executable, we need to prepend command line
# executable, we need to prepend command line
# arguments with 'cmd' - see the wrapper script
# arguments with 'cmd' - see the wrapper script
...
...
This diff is collapsed.
Click to expand it.
fsl/fsleyes/gl/glmodel.py
+
6
−
0
View file @
1f0f36db
...
@@ -106,6 +106,12 @@ class GLModel(globject.GLObject):
...
@@ -106,6 +106,12 @@ class GLModel(globject.GLObject):
self
.
opts
=
None
self
.
opts
=
None
def
ready
(
self
):
"""
Overrides :meth:`.GLObject.ready`. Always returns ``True``.
"""
return
True
def
addListeners
(
self
):
def
addListeners
(
self
):
"""
Called by :meth:`__init__`. Adds some property listeners to the
"""
Called by :meth:`__init__`. Adds some property listeners to the
:class:`.Display` and :class:`.ModelOpts` instances so the OpenGL
:class:`.Display` and :class:`.ModelOpts` instances so the OpenGL
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/async.py
+
23
−
16
View file @
1f0f36db
...
@@ -59,13 +59,18 @@ def run(task, onFinish=None, name=None):
...
@@ -59,13 +59,18 @@ def run(task, onFinish=None, name=None):
:arg name: An optional name to use for this task in log statements.
:arg name: An optional name to use for this task in log statements.
.. note:: If a ``wx`` application is not running, the ``onFinish``
:returns: A reference to the ``Thread`` that was created.
function is called directly from the task thread.
.. note:: If a ``wx`` application is not running, the ``task`` and
``onFinish`` functions will simply be called directly, and
the return value will be ``None``.
"""
"""
if
name
is
None
:
if
name
is
None
:
name
=
'
async task
'
name
=
'
async task
'
haveWX
=
_haveWX
()
def
wrapper
():
def
wrapper
():
log
.
debug
(
'
Running task
"
{}
"
...
'
.
format
(
name
))
log
.
debug
(
'
Running task
"
{}
"
...
'
.
format
(
name
))
...
@@ -73,24 +78,26 @@ def run(task, onFinish=None, name=None):
...
@@ -73,24 +78,26 @@ def run(task, onFinish=None, name=None):
log
.
debug
(
'
Task
"
{}
"
finished
'
.
format
(
name
))
log
.
debug
(
'
Task
"
{}
"
finished
'
.
format
(
name
))
if
onFinish
is
not
None
:
if
(
onFinish
is
not
None
):
if
_haveWX
():
import
wx
log
.
debug
(
'
Scheduling task
"
{}
"
finish handler
'
import
wx
'
on wx.MainLoop
'
.
format
(
name
))
wx
.
CallAfter
(
onFinish
)
log
.
debug
(
'
Scheduling task
"
{}
"
finish handler
'
else
:
'
on wx.MainLoop
'
.
format
(
name
))
log
.
debug
(
'
Running task
"
{}
"
finish handler
'
.
format
(
name
))
onFinish
()
thread
=
threading
.
Thread
(
target
=
wrapper
)
wx
.
CallAfter
(
onFinish
)
thread
.
start
()
return
thread
if
haveWX
:
thread
=
threading
.
Thread
(
target
=
wrapper
)
thread
.
start
()
return
thread
else
:
log
.
debug
(
'
Running task
"
{}
"
directly
'
.
format
(
name
))
task
()
log
.
debug
(
'
Running task
"
{}
"
finish handler
'
.
format
(
name
))
onFinish
()
return
None
_idleRegistered
=
False
_idleRegistered
=
False
...
...
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