Page Contents

This Page

enaml

The top-level enaml package contains modules used throughout the Enaml library.

application Module

class enaml.application.ScheduledTask(callback, args, kwargs)[source]

Bases: object

An object representing a task in the scheduler.

undefined = <object object at 0x03A55DE8>

A sentinel object indicating that the result of the task is undefined or that the task has not yet been executed.

__init__(callback, args, kwargs)[source]

Initialize a ScheduledTask.

Parameters:
  • callback (callable) – The callable to run when the task is executed.
  • args (tuple) – The tuple of positional arguments to pass to the callback.
  • kwargs (dict) – The dict of keyword arguments to pass to the callback.
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.
pending()[source]

Returns True if this task is pending execution, False otherwise.

unschedule()[source]

Unschedule the task so that it will not be executed. If the task has already been executed, this call has no effect.

result()[source]

Returns the result of the task, or ScheduledTask.undefined if the task has not yet been executed, was unscheduled before execution, or raised an exception on execution.

__weakref__

list of weak references to the object (if defined)

class enaml.application.Application(factories)[source]

Bases: object

The application object which manages the top-level communication protocol for serving Enaml views.

__metaclass__

alias of ABCMeta

static instance()[source]

Get the global Application instance.

Returns:result (Application or None) – The global application instance, or None if one has not yet been created.
static __new__(*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.

__init__(factories)[source]

Initialize an Enaml Application.

Parameters:factories (iterable) – An iterable of SessionFactory instances that will be used to create the sessions for the application.
start_session(name)[source]

Start a new session of the given name.

This method will create a new session object for the requested session type and return the new session_id. If the session name is invalid, an exception will be raised.

Parameters:name (str) – The name of the session to start.
Returns:result (str) – The unique identifier for the created session.
end_session(session_id)[source]

End the session with the given session id.

This method will close down the existing session. If the session id is not valid, an exception will be raised.

Parameters:session_id (str) – The unique identifier for the session to close.
session(session_id)[source]

Get the session for the given session id.

Parameters:session_id (str) – The unique identifier for the session to retrieve.
Returns:result (Session or None) – The session object with the given id, or None if the id does not correspond to an active session.
sessions()[source]

Get the currently active sessions for the application.

Returns:result (list) – The list of currently active sessions for the application.
start()[source]

Start the application’s main event loop.

stop()[source]

Stop the application’s main event loop.

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, **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, **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 (bool) – True if called from the main gui thread. False otherwise.
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 (ScheduledTask) – A task object which can be used to unschedule the task or retrieve the results of the callback after the task has been executed.

has_pending_tasks()[source]

Get whether or not the application has pending tasks.

Returns:result (bool) – True if there are pending tasks. False otherwise.
add_factories(factories)[source]

Add session factories to the application.

Parameters:factories (iterable) – An iterable of SessionFactory instances to add to the application.
discover()[source]

Get a dictionary of session information for the application.

Returns:result (list) – A list of dicts of information about the available sessions.
destroy()[source]

Destroy this application instance.

Once an application is created, it must be destroyed before a new application can be instantiated.

__weakref__

list of weak references to the object (if defined)

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, **kwargs
Any additional positional and keyword arguments to pass to the callback.
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, **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 (bool) – True if called from the main gui thread. False otherwise.
enaml.application.schedule(self, 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 (ScheduledTask) – A task object which can be used to unschedule the task or retrieve the results of the callback after the task has been executed.

callableref Module

class enaml.callableref.CallableRef(obj, callback=None)[source]

Bases: object

An object which will weakly wrap a callable object.

This class is useful when weakrefs to callable objects need to be used alongside regular callables. It exposes a callable interface which will dererence the underlying callable before calling it.

__init__(obj, callback=None)[source]

Initialize a CallableRef.

Parameters:
  • obj (callable) – The callable object which should be weakly wrapped.
  • callback (callable or None) – An optional callable to invoke when the object has been garbage collected. It will be passed the weakref instance for associated with the dead object.

Note

Instances of this class will compare equally to equivalent CallableRef instances as well as weakref instances which compare equally to the internal weakref.

__eq__(other)[source]

Custom equality checking for a CallableRef.

This will return True for an equivalent CallableRef or a weakref pointing to the same underlying callable.

__call__(*args, **kwargs)[source]

Invoke the underlying callable.

*args, **kwargs
The positional and keyword arguments to pass to the callable.
Returns:result (object) – The results of the callable, or None if it has already been garbage collected.

colors Module

A utility module for dealing with colors.

enaml.colors.parse_color(color)[source]

Parse a color string into a tuple of RGBA values.

Parameters:color (string) – A CSS3 string representation of the color.
Returns:result (tuple or None) – A tuple of RGBA values. All values are floats in the range 0.0 - 1.0. If the string is invalid, None will be returned.
enaml.colors.composite_colors(first, second)[source]

Composite two colors together using their given alpha.

The first color will be composited on top of the second color.

Parameters:
  • first (tuple) – The rgba tuple of the first color. All values are floats in the range 0.0 - 1.0.
  • second (tuple) – The rgba tuple of the second color. The format of this tuple is the same as the first color.
Returns:

result (tuple) – The composited rgba color tuple.

icon_provider Module

class enaml.icon_provider.IconImage[source]

Bases: traits.has_traits.HasTraits

An object representing an image in an icon.

Instances of this class are used to populate the images list of an Icon instance. Instances of this class should be treated as read-only once they are created.

mode = None

The widget mode for which this icon should apply.

state = None

The widget state for which this icon should apply.

image = None

The image to use for this icon.

snapshot()[source]

Get a snapshot dictionary for this icon image.

__implements__

alias of __NoInterface__

class enaml.icon_provider.Icon[source]

Bases: enaml.resource.Resource

A resource object representing an icon.

Instances of this class are created by an IconProvider when it handles a request for an icon. Instances of this class should be treated as read-only once they are created.

images = None

The list of icon images which compose this icon.

snapshot()[source]

Get a snapshot dictionary for this icon.

__implements__

alias of __NoInterface__

class enaml.icon_provider.IconProvider[source]

Bases: object

An abstract API definition for an icon provider object.

__metaclass__

alias of ABCMeta

request_icon(path, callback)[source]

Request an icon from this provider.

Parameters:
  • path (str) – The requested path of the icon, with the provider prefix removed. For example, if the full icon source path was: icon://myprovider/icons/foo then the path passed to this method will be icons/foo.
  • callback (callable) – A callable which should be invoked when the icon is loaded. It accepts a single argument, which is the loaded Icon object. It is safe to invoke this callable from a thread.
__weakref__

list of weak references to the object (if defined)

image_provider Module

class enaml.image_provider.Image[source]

Bases: enaml.resource.Resource

A resource object representing an image.

Instances of this class are created by an ImageProvider when it handles a request for an image. Instances of this class should be treated as read-only once they are created.

format = None

The format of the image. By default, the consumer of the image will probe the header to automatically infer a type.

size = None

The (width, height) size of the image. An invalid size indicates that the size of the image should be automatically inferred.

data = None

The bytestring holding the data for the image.

snapshot()[source]

Get a snapshot dictionary for this image.

__implements__

alias of __NoInterface__

class enaml.image_provider.ImageProvider[source]

Bases: object

An abstract API definition for an image provider object.

__metaclass__

alias of ABCMeta

request_image(path, size, callback)[source]

Request an image from this provider.

Parameters:
  • path (str) – The requested path of the image, with the provider prefix removed. For example, if the full image source path was: image://myprovider/icons/foo then the path passed to this method will be icons/foo.
  • size (tuple) – A tuple of (width, height) which is the requested size of the image. If this value is (-1, -1), then the image should be loaded in its original size. Otherwise, the image should be loaded in the requested size if possible.
  • callback (callable) – A callable which should be invoked when the image is loaded. It accepts a single argument, which is the loaded Image object. It is safe to invoke this callable from a thread.
__weakref__

list of weak references to the object (if defined)

resource Module

class enaml.resource.Resource[source]

Bases: traits.has_traits.HasTraits

A base class to use for creating resource objects.

class_name()[source]

Get the class name of this resource.

base_names()[source]

Get the base class names of this resource.

snapshot()[source]

Get a snapshot dictionary for this resource.

Subclass should reimplement this method to add more metadata to the snapshot dictionary.

__implements__

alias of __NoInterface__

resource_manager Module

class enaml.resource_manager.ResourceManager[source]

Bases: traits.has_traits.HasTraits

A class which manages resource loading for a Session.

A ResourceManager is used by a Session object to load resources when a url resource request is made by a client session. Users work with the manager by assigning provider objects associated with a host name. For example, a user can provide an image for the url image://filesystem/c:/foo/bar.png by assigning an ImageProvider instace to the image_providers dict with the key filesystem.

image_providers = None

A dict mapping provider location to image provider object. When a resource image://foo/bar/baz is requested, the image provider provider foo is use to request path /bar/baz.

icon_providers = None

A dict of icon providers for the icon://... scheme.

load(url, metadata, reply)[source]

Load a resource from the manager.

Parameters:
  • url (str) – The url pointing to the resource to load.
  • metadata (dict) – Additional metadata required to load the resource of the given type. See the individual loading handlers for the supported metadata.
  • reply (URLReply) – A url reply which will be invoked with the loaded resource object, or None if the loading fails. It must be safe to invoke this reply from a thread.
__implements__

alias of __NoInterface__

runner Module

Command-line tool to run .enaml files.

session Module

enaml.session.BATCH_ACTIONS = set(['destroy', 'children_changed', 'relayout'])

The set of actions which should be batched and sent to the client as a single message. This allows a client to perform intelligent message handling when dealing with messages that may affect the widget tree.

enaml.session.dispatch_action(obj, name, *args)

The dispatch function for action dispatching on the session.

class enaml.session.DeferredMessageBatch[source]

Bases: object

A class which aggregates batch messages.

Each time a message is added to this object, its tick count is incremented and a tick down event is posted to the event queue. When the object receives the tick down event, it decrements its tick count, and if it’s zero, fires the triggered signal.

This allows a consumer of the batch to continually add messages and have the triggered signal fired only when the event queue is fully drained of relevant messages.

triggered

A signal emitted when the tick count of the batch reaches zero and the owner of the batch should consume the messages.

__init__()[source]

Initialize a DeferredMessageBatch.

release()[source]

Release the messages that were added to the batch.

Returns:result (list) – The list of messages added to the batch.
add_message(message)[source]

Add a message to the batch.

This will cause the batch to tick up and then start the tick down process if necessary.

Parameters:message (object) – The message object to add to the batch.
__weakref__

list of weak references to the object (if defined)

class enaml.session.URLReply(session, req_id, url)[source]

Bases: object

A reply object for sending a loaded resource to a client session.

__init__(session, req_id, url)[source]

Initialize a URLReply.

Parameters:
  • session (Session) – The session object for which the image is being loaded.
  • req_id (str) – The identifier that was sent with the originating request. This identifier will be included in the response.
  • url (str) – The url that was sent with the originating request. This url will be included in the response.
__call__(resource)[source]

Send the reply to the client session.

Parameters:resource (Resource) – The loaded resource object, or None if the resource failed to load.
class enaml.session.Session[source]

Bases: traits.has_traits.HasTraits

An object representing the session between a client and its Enaml objects.

The session object is what ensures that each client has their own individual instances of objects, so that the only state that is shared between simultaneously existing clients is that which is explicitly provided by the developer.

session_id = None

The string identifier for this session. This is provided by the application when the session is opened. The value should not be manipulated by user code.

windows = None

The top level windows which are managed by this session. This should be populated by user code during the on_open method.

widget_groups = None

The widget implementation groups which should be used by the widgets in this session. Widget groups are an advanced feature which allow the developer to selectively expose toolkit specific implementations of Enaml widgets. All standard Enaml widgets are available in the ‘default’ group. This value will rarely need to be changed by the user.

resource_manager = None

A resource manager used for loading resources for the session.

socket = None

The socket used by this session for communication. This is provided by the Application when the session is activated. The value should not normally be manipulated by user code.

state = None

The current state of the session. This value is changed by the by the application as it drives the session through its lifetime. This should not be manipulated directly by user code.

is_inactive = None

A read-only property which is True if the session is inactive.

is_opening = None

A read-only property which is True if the session is opening.

is_opened = None

A read-only property which is True if the session is opened.

is_activating = None

A read-only property which is True if the session is activating.

is_active = None

A read-only property which is True if the session is active.

is_closing = None

A read-only property which is True if the session is closing.

is_closed = None

A read-only property which is True if the session is closed.

classmethod factory(name='', description='', *args, **kwargs)[source]

Get a SessionFactory instance for this Session class.

Parameters:
  • name (str, optional) – The name to use for the session instances. The default uses the class name.
  • description (str, optional) – A human friendly description of the session. The default uses the class docstring.
*args, **kwargs
Any positional and keyword arguments to pass to the session when it is instantiated.
on_open()[source]

Called by the application when the session is opened.

This method must be implemented in a subclass and is called to create the Enaml objects for the session. This method will only be called once during the session lifetime. User code should create their windows and assign them to the list of windows before the method returns.

on_close()[source]

Called by the application when the session is closed.

This method may be optionally implemented by subclasses so that they can perform custom cleaup. After this method returns, the session should be considered invalid. This method is only called once during the session lifetime.

open(session_id)[source]

Called by the application to open the session.

This method will call the on_open abstract method which must be implemented by subclasses. The method should never be called by user code.

Parameters:session_id (str) – The unique identifier to use for this session.
activate(socket)[source]

Called by the application to activate the session and its windows.

This method will be called by the Application once during the session lifetime. Once this method returns, the session and its objects will be ready to send and receive messages. This should never be called by user code.

Parameters:socket (ActionSocketInterface) – A concrete implementation of ActionSocketInterface to use for messaging by this session.
close()[source]

Called by the application when the session is closed.

This method will call the on_close method which can optionally be implemented by subclasses. The method should never be called by user code.

snapshot()[source]

Get a snapshot of the windows of this session.

Returns:result (list) – A list of snapshots representing the current windows for this session.
register(obj)[source]

Register an object with the session.

This method is called by an Object when it is activated by a Session. It should never be called by user code.

Parameters:obj (Object) – The object to register with the session.
unregister(obj)[source]

Unregister an object from the session.

This method is called by an Object when it is being destroyed. It should never be called by user code.

Parameters:obj (Object) – The object to unregister from the session.
send(object_id, action, content)[source]

Send a message to a client object.

This method is called by the Object instances owned by this session to send messages to their client implementations.

Parameters:
  • object_id (str) – The object id of the client object.
  • action (str) – The action that should be performed by the object.
  • content (dict) – The content dictionary for the action.
on_message(object_id, action, content)[source]

Receive a message sent to an object owned by this session.

This is a handler method registered as the callback for the action socket. The message will be routed to the appropriate Object instance.

Parameters:
  • object_id (str) – The object id of the target object.
  • action (str) – The action that should be performed by the object.
  • content (dict) – The content dictionary for the action.
on_action_url_request(content)[source]

Handle the ‘url_request’ action from the client session.

__implements__

alias of __NoInterface__

session_factory Module

class enaml.session_factory.SessionFactory(name, description, session_class, *args, **kwargs)[source]

Bases: object

A class whose instances are used by an Enaml Application to create Session instances.

__init__(name, description, session_class, *args, **kwargs)[source]

Initialize a SessionFactory.

Parameters:
  • name (str) – A unique, human-friendly name for the Session that will be created.
  • description (str) – A brief description of the Session that will be created.
  • session_class (Session subclass) – A concrete subclass of Session that will be created by this factory.
*args, **kwargs
Optional positional and keyword arguments to pass to the __init__() method of the Session that gets created.
__call__()[source]

Called by the Enaml Application to create an instance of the Session.

Returns:result (Session) – A new instance of the Session type provided to the factory.
__weakref__

list of weak references to the object (if defined)

signaling Module

enaml.signaling.Signal[source]

A descriptor which provides notification functionality similar to Qt signals and slots.

A Signal is used by creating an instance in the body of a class definition. Slots (callables) are connected to the signal through the connect and disconnect methods. A signal can be emitted by calling the emit method passing arbitrary positional and keyword arguments.

If a bound method is connected to a signal, then that slot will be automatically disconnected when the underlying object instance is garbage collected.

class enaml.signaling.BoundSignal(signal, objref)[source]

Bases: object

A bound Signal object.

Instances of this class are created on the fly by a Signal. This class performs the actual work for connecting, disconnecting, and emitting signals.

__init__(signal, objref)[source]

Initialize a BoundSignal.

Parameters:
  • signal (Signal) – The Signal instance which created this BoundSignal.
  • objref (weakref) – A weak reference to the object which owns the signal. The weakref should not have been created with a callback, as the internal implementation depends on the semantics of weakrefs created without callbacks.
__eq__(other)[source]

Custom equality checking for a BoundSignal.

A BoundSignal will compare equal to another BoundSignal if the unerlying Signal and object reference are equal. This equality is part of the mechanism which allows a signal to be connected to another signal.

__call__(*args, **kwargs)[source]

Custom call support for a BoundSignal.

Calling a signal is indentical invoking the emit method. By making a signal callable, it is possible to directly connect a signal to another signal.

*args, **kwargs
The positional and keyword arguments to pass to the slots connected to the signal.
emit(*args, **kwargs)[source]

Emit the signal with the given arguments and keywords.

If a connected slot raises an exceptions, no further slots will be invoked and the exception will be bubbled up.

*args, **kwargs
The positional and keyword arguments to pass to the slots connected to the signal.
connect(slot)[source]

Connect the given slot to the signal.

The slot will be called when the signal is emitted. It will be passed any positional and keyword arguments that were emitted with the signal. Multiple slots connected to a signal will be invoked in the order in which they were connected. Slots which are instance methods will be automatically disconnected when their underlying instance is garbage collected.

Parameters:slot (callable) – The callable slot to invoke when the signal is emitted.
disconnect(slot)[source]

Disconnect the slot from the signal.

If the slot was not previously connected, this is a no-op.

Parameters:slot (callable) – The callable slot to disconnect from the signal.

socket_interface Module

class enaml.socket_interface.ActionSocketInterface[source]

Bases: object

An abstract base class defining an action socket interface.

Concrete implementations of this interface can be used by Session instances to send and recieve messages to and from their client objects.

__metaclass__

alias of ABCMeta

on_message(callback)[source]

Register a callback for receiving messages sent by a client object.

Parameters:callback (callable) – A callable with an argument signature that is equivalent to the send method. If the callback is a bound method, then the lifetime of the callback will be bound to lifetime of the method owner object.
send(object_id, action, content)[source]

Send an action to the client of an object.

Parameters:
  • object_id (str) – The object id for the Object sending the message.
  • action (str) – The action that should be take by the client object.
  • content (dict) – The dictionary of content needed to perform the action.
__weakref__

list of weak references to the object (if defined)

utils Module

An amalgamation of utilities used throughout the Enaml framework.

enaml.utils.id_generator(stem)[source]

A unique identifier generator.

For a given stem, the returned generator is guaranteed to yield consecutively increasing identifiers using a randomly ordered base 62 charset. The identifiers are only guaranteed unique for a given instance of the generator. The randomness is employed to improve the hashing characteristics of the returned identifiers.

Parameters:stem (str) – A string stem to prepend to a incrementing integer value.
enaml.utils.abstractclassmethod[source]

A backport of the Python 3’s abc.abstractclassmethod.

class enaml.utils.LoopbackContext(guard, items)[source]

Bases: object

A context manager generated by LoopbackGuard.

Instances of this class manage acquiring and releasing the lock items for instances of LoopbackGuard.

__init__(guard, items)[source]

Initialize a LoopbackContext

Parameters:
  • guard (LoopbackGuard) – The loopback guard instance for which we will acquire the lock for the items.
  • items (iterable) – An iterable items which will be passed to the ‘acquire’ method on the loopback guard.
__enter__()[source]

Acquire the guard lock on the lock items.

__exit__(exc_type, exc_value, traceback)[source]

Release the guard lock on the lock items.

class enaml.utils.LoopbackGuard[source]

Bases: object

A guard object to protect against feedback loops.

Instances of this class are used by objects to protect against loopback conditions while updating attributes. Instances of this class are callable and return a guarding context manager for the provided lock items. The guard can be tested for a locked item using the in keyword.

__init__()[source]

Initialize a loopback guard.

__call__(*items)[source]

Return a context manager which will guard the given items.

items
The items for which to acquire the guard from within the returned context manager. These items must be hashable.
Returns:result (LoopbackContext) – A context manager which will acquire the guard for the provided items.
__contains__(item)[source]

Returns whether or not the given item is currently guarded.

Parameters:item (object) – The item to check for guarded state.
Returns:result (bool) – True if the item is currently guarded, False otherwise.
acquire(items)[source]

Acquire the guard for the given items.

This method is normally called by the LoopbackContext returned by calling this instance. User code should not typically call this method directly. It is safe to call this method multiple times for and item, provided it is paired with the same number of calls to release(...). The guard will be released when the acquired count on the item reaches zeros.

Parameters:items (iterable) – An iterable of objects for which to acquire the guard. The items must be hashable.
release(items)[source]

Release the guard for the given lock items.

This method is normally called by the LoopbackContext returned by calling this instance. User code should not normally call this method directly. It is safe to call this method multiple times for and item, provided it is paired with the same number of calls to acquire(...). The guard will be released when the acquired count on the item reaches zeros.

Parameters:items (iterable) – An iterable of objects for which to release the guard. The items must be hashable.
class enaml.utils.ObjectDict[source]

Bases: dict

A dict subclass which exposes its keys as attributes.

__weakref__

list of weak references to the object (if defined)

enaml.utils.log_exceptions(func)[source]

A decorator which will catch errors raised by a function and convert them into log error messages.

When a decorated function raises an Exception, the return value will be None.

enaml.utils.make_dispatcher(prefix, logger=None)[source]

Create a function which will dispatch arguments to specially named handler methods on an object.

Parameters:
  • prefix (str) – The string to prefix to all dispatch names to construct the name of the handler method.
  • logger (logging.Logger, optional) – A logger to use for logging handler lookup misses.
Returns:

result (types.FunctionType) – A function with the signature func(obj, name, *args). Calling it is equivalent to getattr(obj, prefix + name)(*args)

version Module

The version information for this release of Enaml.

weakmethod Module

class enaml.weakmethod.WeakMethod[source]

Bases: object

An object which weakly binds a method with a lifetime bound to the lifetime of the underlying object.

Instances of WeakMethod are also weakref-able with a lifetime which is also bound to lifetime of the method owner.

If multiple WeakMethods are requested for the same equivalent method object, the same WeakMethod will be returned. This behavior is the same as the standard weakref semantics.

static __new__(method)[source]

Create a new WeakMethod instance or return an equivalent which already exists.

Parameters:method (A bound method object) – The bound method which should be wrapped weakly.
__call__(*args, **kwargs)[source]

Invoke the wrapped method by reconstructing the bound method from its components.

If the underlying instance object has been destroyed, this method will return None.

*args, **kwargs
The positional and keyword arguments to pass to the method.
__weakref__

list of weak references to the object (if defined)