traits_futures.wx.event_loop_helper module¶
Test support, providing the ability to run the event loop from tests.
- class traits_futures.wx.event_loop_helper.AppForTesting(*args: Any, **kwargs: Any)[source]¶
Bases:
App
Subclass of wx.App used for testing.
- class traits_futures.wx.event_loop_helper.AttributeSetter(*args: Any, **kwargs: Any)[source]¶
Bases:
EvtHandler
Event handler that allows us to set object attributes from with a running event loop.
- class traits_futures.wx.event_loop_helper.EventLoopHelper[source]¶
Bases:
object
Support for running the wx event loop in unit tests.
- run_until(object, trait, condition, timeout)[source]¶
Run event loop until the given condition holds true, or until timeout.
The condition is re-evaluated, with the object as argument, every time the trait changes.
- Parameters:
object (
traits.has_traits.HasTraits
) – Object whose trait we monitor.trait (
str
) – Name of the trait to monitor for changes.condition – Single-argument callable, returning a boolean. This will be called with object as the only input.
timeout (
float
) – Number of seconds to allow before timing out with an exception.
- Raises:
RuntimeError – If timeout is reached, regardless of whether the condition is true or not at that point.
- class traits_futures.wx.event_loop_helper.TimeoutTimer(*args: Any, **kwargs: Any)[source]¶
Bases:
Timer
Single-shot timer that executes a given callback on completion.
- Parameters:
timeout (
float
) – Timeout in seconds.callback – Callable taking no arguments, to be executed when the timer times out.
args (
tuple
, optional) – Tuple of positional arguments to pass to the callable. If not provided, no positional arguments are passed.kwargs (
dict
, optional) – Dictionary of keyword arguments to pass to the callable. If not provided, no keyword arguments are passed.