# Path: mGui/properties.py
# class LateBoundProperty(object):
#     """
#     This is a property descriptor that's useful for mixin classes that need to
#     create instance properties but which won't get called in the __init__ of a
#     class they are tacked onto.
# 
#     The property in the Mixin declares a name (which will be added to every
#     instance as with a leading underscore, and optionally a string name allowing
#     the mixin's target class to specify a default value at the class level. For example:
# 
#     class Mixin(object):
#         example = LateBoundProperty('example', '_EX')
# 
#     class Target (Mixin):
#         _EX = 99
# 
#     print Target().example
#     # 99
#     """
# 
#     def __init__(self, name, class_default="IGNORE"):
#         self._class_default_string = class_default
#         self._name = "_" + name
# 
#     def __create_backstore(self, instance, owner=None):
#         if not hasattr(instance, self._name):
#             default = None
#             if owner and hasattr(owner, self._class_default_string):
#                 default = copy.copy(getattr(owner, self._class_default_string))
#             setattr(instance, self._name, default)
# 
#     def __get__(self, instance, owner):
#         self.__create_backstore(instance, owner)
#         return getattr(instance, self._name)
# 
#     def __set__(self, instance, val):
#         self.__create_backstore(instance)
#         setattr(instance, self._name, val)


import sys
import maya.cmds as cmds
import weakref
from collections import Mapping
from mGui.properties import LateBoundProperty
    BindableObject is an extension of Bindable which defines a default binds
    source and bind target for an object. This is handy for UI objects that
    typically bind only one value at a time.

    When a BindableObject is used in a binding expression (see @Bindable), you
    can omit the explicit specification of the attribute.  So for example:

        class DefaultBind (BindableObject):
            _BIND_SRC = 'Name'
            _BIND_TGT = 'Name'

            def _init_(self, name):
                self.Name = name


        Fred = DefaultBind('Fred Flinstone')
        OtherGuy = DefaultBind('Barney Rubble')
        Fred > bind() > OtherGuy

        # which is equal to
        # Fred.bind.Name > bind() > OtherGuy.bind.Name

    """

    _BIND_SRC = None
    _BIND_TGT = None
    _BINDINGS = []

    bind_source = LateBoundProperty("bind_source", "_BIND_SRC")
    bind_target = LateBoundProperty("bind_target", "_BIND_TGT")

# Path: mGui/properties.py
# class LateBoundProperty(object):
#     """
#     This is a property descriptor that's useful for mixin classes that need to
#     create instance properties but which won't get called in the __init__ of a
#     class they are tacked onto.
# 
#     The property in the Mixin declares a name (which will be added to every
#     instance as with a leading underscore, and optionally a string name allowing
#     the mixin's target class to specify a default value at the class level. For example:
# 
#     class Mixin(object):
#         example = LateBoundProperty('example', '_EX')
# 
#     class Target (Mixin):
#         _EX = 99
# 
#     print Target().example
#     # 99
#     """
# 
#     def __init__(self, name, class_default="IGNORE"):
#         self._class_default_string = class_default
#         self._name = "_" + name
# 
#     def __create_backstore(self, instance, owner=None):
#         if not hasattr(instance, self._name):
#             default = None
#             if owner and hasattr(owner, self._class_default_string):
#                 default = copy.copy(getattr(owner, self._class_default_string))
#             setattr(instance, self._name, default)
# 
#     def __get__(self, instance, owner):
#         self.__create_backstore(instance, owner)
#         return getattr(instance, self._name)
# 
#     def __set__(self, instance, val):
#         self.__create_backstore(instance)
#         setattr(instance, self._name, val)


# Path: mGui/bindings.py
import sys
import maya.cmds as cmds
import weakref
from collections import Mapping
from mGui.properties import LateBoundProperty

    BindableObject is an extension of Bindable which defines a default binds
    source and bind target for an object. This is handy for UI objects that
    typically bind only one value at a time.

    When a BindableObject is used in a binding expression (see @Bindable), you
    can omit the explicit specification of the attribute.  So for example:

        class DefaultBind (BindableObject):
            _BIND_SRC = 'Name'
            _BIND_TGT = 'Name'

            def _init_(self, name):
                self.Name = name


        Fred = DefaultBind('Fred Flinstone')
        OtherGuy = DefaultBind('Barney Rubble')
        Fred > bind() > OtherGuy

        # which is equal to
        # Fred.bind.Name > bind() > OtherGuy.bind.Name

    """

    _BIND_SRC = None
    _BIND_TGT = None
    _BINDINGS = []

    bind_source = LateBoundProperty("bind_source", "_BIND_SRC")
    bind_target = LateBoundProperty("bind_target", "_BIND_TGT")

    bindings = LateBoundProperty("bindings", "_BINDINGS")