mrv :: maya :: ui :: util :: UIContainerBase :: Class UIContainerBase
[hide private]
[frames] | no frames]

Class UIContainerBase

source code

object --+
         |
        UIContainerBase

A ui container is a base for all classes that can have child controls or other containers.

This class is just supposed to keep references to it's children so that additional information stored in python will not get lost

Child-Instances are always unique, thus adding them several times will not keep them several times , but just once

Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__getitem__(self, key)
Returns: the child with the given name, see childByName
source code
 
__enter__(self) source code
 
__exit__(self, type, value, traceback) source code
 
add(self, child, set_self_active=False, revert_to_previous_parent=True)
Add the given child UI item to our list of children
source code
 
removeChild(self, child)
Remove the given child from our list
source code
 
deleteChild(self, child)
Delete the given child ui physically so it will not be shown anymore after removing it from our list of children
source code
 
listChildren(self, predicate=lambda c: True)
Returns: list with our child instances
source code
 
childByName(self, childname)
Returns: stored child instance, specified either as short name ( without pipes ) or fully qualified ( i.e.
source code
 
setActive(self)
Set this container active, such that newly created items will be children of this layout
source code
 
clearChildren(self)
Clear our child arrays to quickly forget about our children
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__getitem__(self, key)
(Indexing operator)

source code 
Parameters:
  • key - if integer, will return the given list index, if string, the child matching the id
Returns:
the child with the given name, see childByName

add(self, child, set_self_active=False, revert_to_previous_parent=True)

source code 
Add the given child UI item to our list of children
Parameters:
  • set_self_active - if True, we explicitly make ourselves the current parent for newly created UI elements
  • revert_to_previous_parent - if True, the previous parent will be restored once we are done, if False we keep the parent - only effective if set_self_active is True
Returns:
the newly added child, allowing contructs like button = layout.addChild( Button( ) )

removeChild(self, child)

source code 
Remove the given child from our list
Returns:
True if the child was found and has been removed, False otherwise

listChildren(self, predicate=lambda c: True)

source code 
Parameters:
  • predicate - function returning True for each child to include in result, allows to easily filter children
Returns:
list with our child instances
Notes:
  • it's a copy, so you can freely act on the list
  • children will be returned in the order in which they have been added

childByName(self, childname)

source code 
Returns:
stored child instance, specified either as short name ( without pipes ) or fully qualified ( i.e. mychild or parent|subparent|mychild" )
Raises:
  • KeyError - if a child with that name does not exist

setActive(self)

source code 
Set this container active, such that newly created items will be children of this layout
Returns:
self

Note: always use the addChild function to add the children !