enaml.application
Functions
Invoke a callable on the next cycle of the main event loop thread. |
|
Indicates whether the caller is on the main gui thread. |
|
Schedule a callable to be executed on the event loop thread. |
|
Invoke a callable on the main event loop thread at a specified time in the future. |
Classes
The application object which manages the top-level communication protocol for serving Enaml views. |
|
An object which resolves requests for proxy objects. |
|
An object representing a task in the scheduler. |
- enaml.application.deferred_call(callback, *args, **kwargs)[source]
Invoke a callable on the next cycle of the main event loop thread.
This is a convenience function for invoking the same method on the current application instance. If an application instance does not exist, a RuntimeError will be raised.
- Parameters:
callback (callable) – The callable object to execute at some point in the future.
args – Any additional positional and keyword arguments to pass to the callback.
kwargs – Any additional positional and keyword arguments to pass to the callback.
- enaml.application.is_main_thread()[source]
Indicates whether the caller is on the main gui thread.
This is a convenience function for invoking the same method on the current application instance. If an application instance does not exist, a RuntimeError will be raised.
- Returns:
result – True if called from the main gui thread. False otherwise.
- Return type:
- enaml.application.schedule(callback, args=None, kwargs=None, priority=0)[source]
Schedule a callable to be executed on the event loop thread.
This call is thread-safe.
This is a convenience function for invoking the same method on the current application instance. If an application instance does not exist, a RuntimeError will be raised.
- Parameters:
callback (callable) – The callable object to be executed.
args (tuple, optional) – The positional arguments to pass to the callable.
kwargs (dict, optional) – The keyword arguments to pass to the callable.
priority (int, optional) – The queue priority for the callable. Smaller values indicate lower priority, larger values indicate higher priority. The default priority is zero.
- Returns:
result – A task object which can be used to unschedule the task or retrieve the results of the callback after the task has been executed.
- Return type:
- enaml.application.timed_call(ms, callback, *args, **kwargs)[source]
Invoke a callable on the main event loop thread at a specified time in the future.
This is a convenience function for invoking the same method on the current application instance. If an application instance does not exist, a RuntimeError will be raised.
- Parameters:
ms (int) – The time to delay, in milliseconds, before executing the callable.
callback (callable) – The callable object to execute at some point in the future.
args – Any additional positional and keyword arguments to pass to the callback.
kwargs – Any additional positional and keyword arguments to pass to the callback.
- class enaml.application.Application(*args, **kwargs)[source]
Bases:
Atom
The application object which manages the top-level communication protocol for serving Enaml views.
- resolver
The proxy resolver to use for the application. This will normally be supplied by application subclasses, but can also be supplied by the developer to supply custom proxy resolution behavior.
- style_sheet
The style sheet to apply to the entire application.
- static instance()[source]
Get the global Application instance.
- Returns:
result – The global application instance, or None if one has not yet been created.
- Return type:
Application or None
- static __new__(cls, *args, **kwargs)[source]
Create a new Enaml Application.
There may be only one application instance in existence at any point in time. Attempting to create a new Application when one exists will raise an exception.
- deferred_call(callback, *args, **kwargs)[source]
Invoke a callable on the next cycle of the main event loop thread.
- Parameters:
callback (callable) – The callable object to execute at some point in the future.
args – Any additional positional and keyword arguments to pass to the callback.
kwargs – Any additional positional and keyword arguments to pass to the callback.
- timed_call(ms, callback, *args, **kwargs)[source]
Invoke a callable on the main event loop thread at a specified time in the future.
- Parameters:
ms (int) – The time to delay, in milliseconds, before executing the callable.
callback (callable) – The callable object to execute at some point in the future.
args – Any additional positional and keyword arguments to pass to the callback.
kwargs – Any additional positional and keyword arguments to pass to the callback.
- is_main_thread()[source]
Indicates whether the caller is on the main gui thread.
- Returns:
result – True if called from the main gui thread. False otherwise.
- Return type:
- create_mime_data()[source]
Create a new mime data object to be filled by the user.
- Returns:
result – A concrete implementation of the MimeData class.
- Return type:
MimeData
- resolve_proxy_class(declaration_class)[source]
Resolve the proxy implementation class for a declaration.
This can be reimplemented by Application subclasses if more control is needed.
- create_proxy(declaration)[source]
Create the proxy object for the given declaration.
This can be reimplemented by Application subclasses if more control is needed.
- Parameters:
declaration (ToolkitObject) – The object for which a toolkit proxy should be created.
- Returns:
result – An appropriate toolkit proxy object, or None if one cannot be create for the given declaration object.
- Return type:
ProxyToolkitObject or None
- schedule(callback, args=None, kwargs=None, priority=0)[source]
Schedule a callable to be executed on the event loop thread.
This call is thread-safe.
- Parameters:
callback (callable) – The callable object to be executed.
args (tuple, optional) – The positional arguments to pass to the callable.
kwargs (dict, optional) – The keyword arguments to pass to the callable.
priority (int, optional) – The queue priority for the callable. Smaller values indicate lower priority, larger values indicate higher priority. The default priority is zero.
- Returns:
result – A task object which can be used to unschedule the task or retrieve the results of the callback after the task has been executed.
- Return type:
- class enaml.application.ProxyResolver[source]
Bases:
Atom
An object which resolves requests for proxy objects.
- factories
A dictionary of factories functions to use when resolving the proxy. The function should take no arguments, and return the proxy class when called.
- resolve(name)[source]
Resolve the given name to a proxy calls.
For example, ‘Field’ should resolve to a class which implements the ProxyField interface.
- Parameters:
name (string) – The name of the proxy object to resolve.
- Returns:
result – A class which implements the proxy interface, or None if no class can be found for the given name.
- Return type:
type or None
- class enaml.application.ScheduledTask(callback, args, kwargs)[source]
Bases:
Atom
An object representing a task in the scheduler.
- notify(callback)[source]
Set a callback to be run when the task is executed.
- Parameters:
callback (callable) – A callable which accepts a single argument which is the results of the task. It will be invoked immediate after the task is executed, on the main event loop thread.