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
69297c6f
Commit
69297c6f
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: New idle.block function
parent
e1254a9f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/idle.py
+25
-1
25 additions, 1 deletion
fsl/utils/idle.py
with
25 additions
and
1 deletion
fsl/utils/idle.py
+
25
−
1
View file @
69297c6f
...
@@ -19,6 +19,7 @@ Idle tasks
...
@@ -19,6 +19,7 @@ Idle tasks
.. autosummary::
.. autosummary::
:nosignatures:
:nosignatures:
block
idle
idle
idleWhen
idleWhen
inIdle
inIdle
...
@@ -377,6 +378,29 @@ def cancelIdle(taskName):
...
@@ -377,6 +378,29 @@ def cancelIdle(taskName):
_idleQueueDict
[
taskName
].
timeout
=
-
1
_idleQueueDict
[
taskName
].
timeout
=
-
1
def
block
(
secs
,
delta
=
0.01
):
"""
Blocks for the specified number of seconds, yielding to the main ``wx``
loop.
If ``wx`` is not available, or a ``wx`` application is not running, this
function is equivalent to ``time.sleep(secs)``.
:arg secs: Time in seconds to block
:arg delta: Time in seconds to sleep between successive yields to ``wx``.
"""
from
fsl.utils.platform
import
platform
as
fslplatform
if
not
fslplatform
.
haveGui
:
time
.
sleep
(
secs
)
else
:
import
wx
start
=
time
.
time
()
while
(
time
.
time
()
-
start
)
<
secs
:
wx
.
YieldIfNeeded
()
time
.
sleep
(
delta
)
def
idle
(
task
,
*
args
,
**
kwargs
):
def
idle
(
task
,
*
args
,
**
kwargs
):
"""
Run the given task on a ``wx.EVT_IDLE`` event.
"""
Run the given task on a ``wx.EVT_IDLE`` event.
...
@@ -556,7 +580,7 @@ def idleWhen(func, condition, *args, **kwargs):
...
@@ -556,7 +580,7 @@ def idleWhen(func, condition, *args, **kwargs):
def
wait
(
threads
,
task
,
*
args
,
**
kwargs
):
def
wait
(
threads
,
task
,
*
args
,
**
kwargs
):
"""
Creates and starts a new ``Thread`` which waits for all of the ``Thread``
"""
Creates and starts a new ``Thread`` which waits for all of the ``Thread``
instances to fin
s
ih (by ``join``ing them), and then runs the given
instances to fini
s
h (by ``join``ing them), and then runs the given
``task`` via :func:`idle`.
``task`` via :func:`idle`.
If the ``direct`` parameter is ``True``, or a ``wx.App`` is not running,
If the ``direct`` parameter is ``True``, or a ``wx.App`` is not running,
...
...
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