Exemple #1
0

#: A namedtuple which contains information about a child change event.
#: The `old` slot will be the ordered list of old children. The `new`
#: slot will be the ordered list of new children.
ChildrenEvent = namedtuple('ChildrenEvent', 'old new')


#: A namedtuple which contains information about a parent change event.
#: The `old` slot will be the old parent and the `new` slot will be
#: the new parent.
ParentEvent = namedtuple('ParentEvent', 'old new')


#: The identifier generator for object instances.
object_id_generator = id_generator('o_')


class ChildrenEventContext(object):
    """ A context manager which will emit a child event on an Object.

    This context manager will automatically emit the child event on an
    Object when the context is exited. This context manager can also be
    safetly nested; only the top-level context for a given object will
    emit the child event, effectively collapsing all transient state.

    """
    #: Class level storage for tracking nested context managers.
    _counters = defaultdict(int)

    def __init__(self, parent):
Exemple #2
0
#------------------------------------------------------------------------------
#  Copyright (c) 2012, Enthought, Inc.
#  All rights reserved.
#------------------------------------------------------------------------------
import logging
from urlparse import urlparse

from enaml.utils import id_generator

from .q_deferred_caller import deferredCall
from .qt_resource import convert_resource

logger = logging.getLogger(__name__)

#: An id generator for making requests to the server.
req_id_generator = id_generator('r_')


class DeferredResource(object):
    """ An deferred resource object returned by a `QtURLRequestManager`.

    Instances of this class are provided to widgets when they request a
    resource url. Since the url may need to be retrieved from a server,
    Loading occurs asynchronously. This object allows a widget to supply
    a callback to be invoked when the resource is loaded.

    """
    __slots__ = ('_callback')

    def __init__(self):
        """ Initialize a DeferredResource.
Exemple #3
0
#: The dispatch function for action dispatching.
dispatch_action = make_dispatcher('on_action_', logger)

#: A namedtuple which contains information about a child change event.
#: The `old` slot will be the ordered list of old children. The `new`
#: slot will be the ordered list of new children.
ChildrenEvent = namedtuple('ChildrenEvent', 'old new')

#: A namedtuple which contains information about a parent change event.
#: The `old` slot will be the old parent and the `new` slot will be
#: the new parent.
ParentEvent = namedtuple('ParentEvent', 'old new')

#: The identifier generator for object instances.
object_id_generator = id_generator('o_')


class ChildrenEventContext(object):
    """ A context manager which will emit a child event on an Object.

    This context manager will automatically emit the child event on an
    Object when the context is exited. This context manager can also be
    safetly nested; only the top-level context for a given object will
    emit the child event, effectively collapsing all transient state.

    """
    #: Class level storage for tracking nested context managers.
    _counters = defaultdict(int)

    def __init__(self, parent):
Exemple #4
0
#  All rights reserved.
#------------------------------------------------------------------------------
import logging
from urlparse import urlparse

from enaml.utils import id_generator

from .q_deferred_caller import deferredCall
from .qt_resource import convert_resource


logger = logging.getLogger(__name__)


#: An id generator for making requests to the server.
req_id_generator = id_generator('r_')


class DeferredResource(object):
    """ An deferred resource object returned by a `QtURLRequestManager`.

    Instances of this class are provided to widgets when they request a
    resource url. Since the url may need to be retrieved from a server,
    Loading occurs asynchronously. This object allows a widget to supply
    a callback to be invoked when the resource is loaded.

    """
    __slots__ = ('_callback')

    def __init__(self):
        """ Initialize a DeferredResource.