Ejemplo n.º 1
0
 def pop(self):
     """
     set the default parent to the parent of this layout
     """
     p = self.parent()
     cmds.setParent(p)
     return p
Ejemplo n.º 2
0
 def pop(self):
     """
     set the default parent to the parent of this layout
     """
     p = self.parent()
     cmds.setParent(p)
     return p
Ejemplo n.º 3
0
 def __exit__(self, type, value, traceback):
     global _withParentStack
     _withParentStack.pop()
     if _withParentStack:
         parent = _withParentStack[-1]
     else:
         parent = self.pop()
         while parent and objectTypeUI(parent) == u'rowGroupLayout':
             parent = parent.pop()
     cmds.setParent(parent)
Ejemplo n.º 4
0
 def __exit__(self, type, value, traceback):
     global _withParentStack
     _withParentStack.pop()
     if _withParentStack:
         parent = _withParentStack[-1]
     else:
         parent = self.pop()
         while parent and objectTypeUI(parent) == u'rowGroupLayout':
             parent = parent.pop()
     cmds.setParent(parent)
Ejemplo n.º 5
0
 def __exit__(self, type, value, traceback):
     p = self.parent()
     #Ensure we set the parent back to a layout not some ui element
     # like say a button which does not accept children
     if not cmds.layout(p, exists=True):
         p = p.parent()
         
     #However we want to be careful not to attach to a rowGroupLayout(textFieldButtonGrp etc)
     # in this case set the parent to the rowGroupLayout's parent
     if cmds.objectTypeUI(p) == u'rowGroupLayout':
         p = p.parent()
     cmds.setParent(p)
     return p
Ejemplo n.º 6
0
 def __exit__(self, type, value, traceback):
     global _withParentMenuStack
     _withParentMenuStack.pop()
     if _withParentMenuStack:
         cmds.setParent(_withParentMenuStack[-1], menu=True)
     else:
         parent = self
         while True:
             parent = parent.parent()
             try:
                 cmds.setParent(parent, menu=True)
             except RuntimeError:
                 continue
             break
Ejemplo n.º 7
0
 def __exit__(self, type, value, traceback):
     global _withParentMenuStack
     _withParentMenuStack.pop()
     if _withParentMenuStack:
         cmds.setParent(_withParentMenuStack[-1], menu=True)
     else:
         parent = self
         while True:
             parent = parent.parent()
             try:
                 cmds.setParent(parent, menu=True)
             except RuntimeError:
                 continue
             break
Ejemplo n.º 8
0
def menu(*args, **kwargs):
    """
Modifications
  - added ability to query parent
    """
    if _versions.current() < _versions.v2011:
        # on create only
        if not ( kwargs.get('query', False) or kwargs.get('q', False) ) \
            and not ( kwargs.get('edit', False) or kwargs.get('e', False) ) \
            and not ( kwargs.get('parent', False) or kwargs.get('p', False) ):
            kwargs['parent'] = cmds.setParent(q=1)

    if ( kwargs.get('query', False) or kwargs.get('q', False) ) \
            and ( kwargs.get('parent', False) or kwargs.get('p', False) ):
        name = unicode(args[0])
        if '|' not in name:
            try:
                name = _findLongName(name, 'menu')
            except ValueError:
                name = _findLongName(name, 'popupMenu')
        return name.rsplit('|',1)[0]

    result = cmds.menu(*args, **kwargs)

    if ( kwargs.get('query', False) or kwargs.get('q', False) ) \
            and ( kwargs.get('itemArray', False) or kwargs.get('ia', False) ) \
            and result is None:
        result = []
    return result
Ejemplo n.º 9
0
def menu(*args, **kwargs):
    """
Modifications
  - added ability to query parent
    """
    if _versions.current() < _versions.v2011:
        # on create only
        if not ( kwargs.get('query', False) or kwargs.get('q', False) ) \
                and not ( kwargs.get('edit', False) or kwargs.get('e', False) ) \
                and not (kwargs.get('parent', False) or kwargs.get('p', False)):
            kwargs['parent'] = cmds.setParent(q=1)

    if ( kwargs.get('query', False) or kwargs.get('q', False) ) \
            and (kwargs.get('parent', False) or kwargs.get('p', False)):
        name = unicode(args[0])
        if '|' not in name:
            try:
                name = _findLongName(name, 'menu')
            except ValueError:
                name = _findLongName(name, 'popupMenu')
        return name.rsplit('|', 1)[0]

    result = cmds.menu(*args, **kwargs)

    if ( kwargs.get('query', False) or kwargs.get('q', False) ) \
            and ( kwargs.get('itemArray', False) or kwargs.get('ia', False) ) \
            and result is None:
        result = []
    return result
Ejemplo n.º 10
0
 def __exit__(self, type, value, traceback):
     global _withParentMenuStack
     _withParentMenuStack.pop()
     if _withParentMenuStack:
         cmds.setParent(_withParentMenuStack[-1], menu=True)
     else:
         parent = self
         while True:
             parent = parent.parent()
             # Maya 2012 Service Pack 2 (or SAP1, SP1) introduces a bug where
             # '' is returned, instead of None; problem being that doing
             # cmds.setParent(None, menu=True) is valid, but
             # cmds.setParent('', menu=True) is not
             if parent == '':
                 parent = None
             try:
                 cmds.setParent(parent, menu=True)
             except RuntimeError:
                 continue
             break
Ejemplo n.º 11
0
 def __exit__(self, type, value, traceback):
     global _withParentMenuStack
     _withParentMenuStack.pop()
     if _withParentMenuStack:
         cmds.setParent(_withParentMenuStack[-1], menu=True)
     else:
         parent = self
         while True:
             parent = parent.parent()
             # Maya 2012 Service Pack 2 (or SAP1, SP1) introduces a bug where
             # '' is returned, instead of None; problem being that doing
             # cmds.setParent(None, menu=True) is valid, but
             # cmds.setParent('', menu=True) is not
             if parent == '':
                 parent = None
             try:
                 cmds.setParent(parent, menu=True)
             except RuntimeError:
                 continue
             break
Ejemplo n.º 12
0
def setParent(*args, **kwargs):
    """
Modifications
  - returns None object instead of the string 'NONE'
    """
    import uitypes    
    result = cmds.setParent(*args, **kwargs)
    if kwargs.get('query', False) or kwargs.get('q', False):
        if result == 'NONE':
            result = None
        else:
            result = uitypes.PyUI(result)
    return result
Ejemplo n.º 13
0
def setParent(*args, **kwargs):
    """
Modifications
  - returns None object instead of the string 'NONE'
    """
    import uitypes
    result = cmds.setParent(*args, **kwargs)
    if kwargs.get('query', False) or kwargs.get('q', False):
        if result == 'NONE':
            result = None
        else:
            result = uitypes.PyUI(result)
    return result
Ejemplo n.º 14
0
def menu(*args, **kwargs):
    """
Modifications
  - added ability to query parent
    """
    if _versions.current() < _versions.v2011:
        # on create only
        if not ( kwargs.get('query', False) or kwargs.get('q', False) ) \
            and not ( kwargs.get('edit', False) or kwargs.get('e', False) ) \
            and not ( kwargs.get('parent', False) or kwargs.get('p', False) ):
            kwargs['parent'] = cmds.setParent(q=1)

    if ( kwargs.get('query', False) or kwargs.get('q', False) ) \
            and ( kwargs.get('parent', False) or kwargs.get('p', False) ):
        name = unicode(args[0])
        if '|' not in name:
            name = _findLongName(name, 'menu')
        return name.rsplit('|',1)[0]

    return cmds.menu(*args, **kwargs)
Ejemplo n.º 15
0
def menu(*args, **kwargs):
    """
Modifications
  - added ability to query parent
    """
    if _versions.current() < _versions.v2011:
        # on create only
        if (
            not (kwargs.get("query", False) or kwargs.get("q", False))
            and not (kwargs.get("edit", False) or kwargs.get("e", False))
            and not (kwargs.get("parent", False) or kwargs.get("p", False))
        ):
            kwargs["parent"] = cmds.setParent(q=1)

    if (kwargs.get("query", False) or kwargs.get("q", False)) and (
        kwargs.get("parent", False) or kwargs.get("p", False)
    ):
        name = unicode(args[0])
        if "|" not in name:
            name = _findLongName(name, "menu")
        return name.rsplit("|", 1)[0]

    return cmds.menu(*args, **kwargs)
Ejemplo n.º 16
0
 def makeDefault(self):
     """
     set this layout as the default parent
     """
     cmds.setParent(self, menu=True)
Ejemplo n.º 17
0
 def __enter__(self):
     cmds.setParent(self,menu=True)
     return self
Ejemplo n.º 18
0
 def __exit__(self, type, value, traceback):
     p = self.parent()
     cmds.setParent(p,menu=True)
     return p
Ejemplo n.º 19
0
 def makeDefault(self):
     """
     set this layout as the default parent
     """
     cmds.setParent(self, menu=True)
Ejemplo n.º 20
0
def currentParent():
    "shortcut for ``ui.PyUI(setParent(q=1))`` "
    return _uitypes.PyUI(cmds.setParent(q=1))