Пример #1
0
class AbstractFlowWidget(with_metaclass(ABCMeta, object)):
    """ An abstract base class which defines the interface for widgets
    which can be used in a QFlowLayout.

    Users of QFlowLayout must register their custom QWidget classes with
    this class in order to use the QFlowLayout.

    """
    @abstractmethod
    def layoutData(self):
        """ An abstractmethod which must be implemented by subclasses.

        Returns
        -------
        result : FlowLayoutData
            The FlowLayoutData instance to use for this widget. The
            same data layout data instance should be returned for
            each call to this method.

        """
        raise NotImplementedError
Пример #2
0
class _DockLayoutItem(with_metaclass(_DockLayoutItemMeta, object)):
    """ A private class which performs type checking for dock layouts.
Пример #3
0
class _AreaLayoutItem(with_metaclass(_AreaLayoutItemMeta, object)):
    """ A private class which performs type checking for area layouts.
Пример #4
0
class _SplitLayoutItem(with_metaclass(_SplitLayoutItemMeta, object)):
    """ A private class which performs type checking for split layouts.
Пример #5
0
class LinearSymbolic(with_metaclass(ABCMeta, object)):
    """ An abstract base class for testing linear symbolic interfaces.
Пример #6
0
class Constrainable(with_metaclass(ABCMeta, object)):
    """ An abstract base class for defining constrainable objects.
Пример #7
0
class Declarative(with_metaclass(DeclarativeMeta, Object)):
    """ The most base class of the Enaml declarative objects.

    This class provides the core functionality required of declarative
    Enaml types. It can be used directly in a declarative Enaml object
    tree to store and react to state changes. It has no concept of a
    visual representation; that functionality is added by subclasses.

    """

    #: Export the 'name' attribute as a declarative member.
    name = d_(Unicode())

    #: An event fired when an object is initialized. It is triggered
    #: once during the object lifetime, at the end of the initialize
    #: method.
    initialized = d_(Event(), writable=False)

    #: A property which gets and sets the initialized flag. This should
    #: not be manipulated directly by user code.
    is_initialized = flag_property(INITIALIZED_FLAG)

    #: Storage space for the declarative runtime. This value should not
    #: be manipulated by user code.
    _d_storage = Typed(sortedmap, ())

    #: Storage space for the declarative engine. This value should not
    #: be manipulated by user code.
    _d_engine = Typed(ExpressionEngine)

    def initialize(self):
        """ Initialize this object all of its children recursively.

        This is called to give the objects in the tree the opportunity
        to initialize additional state which depends upon the object
        tree being fully built. It is the responsibility of external
        code to call this method at the appropriate time. This will
        emit the `initialized` signal after all of the children have
        been initialized.

        """
        # Iterate over a copy since the children add and remove
        # other children during initialization.
        for child in self.children[:]:
            if isinstance(child, Declarative):
                child.initialize()
        self.is_initialized = True
        self.initialized()

    def destroy(self):
        """ An overridden destructor method for declarative cleanup.

        """
        self.is_initialized = False
        del self._d_storage
        del self._d_engine
        super(Declarative, self).destroy()

    def child_added(self, child):
        """ An overridden child added event handler.

        This handler will automatically initialize a declarative child
        if this object itself has already been initialized.

        """
        super(Declarative, self).child_added(child)
        if isinstance(child, Declarative):
            if self.is_initialized and not child.is_initialized:
                child.initialize()