Ejemplo n.º 1
0
 def __get__(self, obj, objtype):
     cb = obj.Callbacks.get(self.Key, None)
     # @note: don't use simple truth test here! No-handler event evals to false,
     # so manually assigned events are overwritten!
     if cb is None:
         obj.Callbacks[self.Key] = MayaEvent(sender=obj)
         obj.register_callback(self.Key, obj.Callbacks[self.Key])
     return obj.Callbacks[self.Key]
Ejemplo n.º 2
0
    def __init__(self, *items, **kwargs):
        self._max_size = kwargs.pop('limit', 0)
        synchronous = kwargs.pop('synchronous', False)
        super(ViewCollection, self).__init__(*items)
        self.onViewChanged = MayaEvent(collection=self)
        if synchronous:
            self.onViewChanged = Event(collection=self)

        self._filter = lambda p: p
        self._last_count = len(self._internal_collection)
        self._truncated = False
Ejemplo n.º 3
0
 def __get__(self, obj, objtype):
     cb = obj.callbacks.get(self.key, None)
     # @note: don't use simple truth test here! No-handler event evals to false,
     # so manually assigned events are overwritten!
     if cb is None:
         if obj.parent and obj.parent.modal:
             obj.callbacks[self.key] = Event(sender=weakref.proxy(obj))
         else:
             obj.callbacks[self.key] = MayaEvent(sender=weakref.proxy(obj))
         obj.register_callback(self.key, obj.callbacks[self.key])
     return obj.callbacks[self.key]
Ejemplo n.º 4
0
    def __get__(self, obj, obj_type):
        if obj is None:
            return self
        qt_object = as_qt_object(obj)

        cb = obj.callbacks.get(self._key, None)
        if cb is None:
            if obj.modal or obj.parent and obj.parent.modal:
                cb = obj.callbacks[self._key] = Event(sender=weakref.proxy(obj), qWidget=qt_object)
            else:
                cb = obj.callbacks[self._key] = MayaEvent(sender=weakref.proxy(obj), qWidget=qt_object)
            getattr(qt_object, self._key).connect(cb)
        return cb
Ejemplo n.º 5
0
 def __init__(self, *items):
     self._internal_collection = [i for i in items]
     self.onCollectionChanged = MayaEvent(collection=self)
     self.onItemAdded = MayaEvent(collection=self)
     self.onItemRemoved = MayaEvent(collection=self)
Ejemplo n.º 6
0
 def __init__(self):
     self._internal_collection = ()
     self.onCollectionChanged = MayaEvent(
     )  # these are MayaEvents so they are thread safe... we hope
     self.widgetCreated = MayaEvent()
Ejemplo n.º 7
0
    def __init__(self, *items):
        super(ViewCollection, self).__init__(*items)
        self.ViewChanged = MayaEvent(collection=self)

        self.Filter = lambda p: p
        self._last_count = len(self._Internal_Collection)
Ejemplo n.º 8
0
"""
This module exposes a single event callback, which fires on a maya idle event.  It's intended to be used as a way to
trigger things like menu or ui loads once the main Maya UI is initialized.
"""
from mGui.events import MayaEvent
import maya.cmds as cmds

Maya_is_ready = MayaEvent()


class MayaUIStatus(object):
    """
    This object can be used to check to see if the maya UI has finished booting. When the UI has loaded,
    MayaUIStatus.ready will be True; until them it will be false
    """
    ready = False

    @classmethod
    def maya_is_ready(cls, *args, **kwargss):
        cls.ready = True


cmds.scriptJob(e=('idle', Maya_is_ready), runOnce=True)
Maya_is_ready += MayaUIStatus.maya_is_ready