mrv :: maya :: ui :: base :: NamedUI :: Class NamedUI
[hide private]
[frames] | no frames]

Class NamedUI

source code

         object --+        
                  |        
         basestring --+    
                      |    
                unicode --+
                          |
             object --+   |
                      |   |
                 BaseUI --+
                          |
         object --+       |
                  |       |
interface.Interface --+   |
                      |   |
     interface.iDagItem --+
                          |
         object --+       |
                  |       |
   util.EventSender --+   |
                      |   |
     util.EventSenderUI --+
                          |
                         NamedUI

Implements a simple UI element having a name and most common methods one can apply to it. Derived classes should override these if they can deliver a faster implementation. If the 'name' keyword is supplied, an existing UI element will be wrapped

Events

As subclass of EventSenderUI, it can provide events that are automatically added by the metaclass as described by the _events_ attribute list. This allows any number of clients to register for one maya event. Derived classes may also use their own events which is useful if you create components

Register for an event like:

>>> uiinstance.e_eventlongname = yourFunction( sender, *args, **kwargs )
>>> *args and **kwargs are determined by maya

Note: although many access methods look quite 'repeated' as they are quite similar except for a changing flag, they are hand-written to provide proper docs for them

Nested Classes [hide private]
  __metaclass__
Builds the base hierarchy for the given classname based on our typetree.

Inherited from util.EventSenderUI (private): _UIEvent

Instance Methods [hide private]
 
_parentString(self)
Returns: string of the parent, without a wrap
source code
 
uiDeleted(self)
If overridden in subclass, it will be called once the UI gets deleted within maya ( i.e.
source code
 
type(self)
Returns: the python class able to create this class
source code
 
shortName(self)
Returns: shortname of the ui ( name without pipes )
source code
 
delete(self)
Delete this UI - the wrapper instance must not be used after this call
source code
 
exists(self)
Returns: True if this instance still exists in maya
source code

Inherited from unicode: __add__, __contains__, __eq__, __format__, __ge__, __getattribute__, __getitem__, __getnewargs__, __getslice__, __gt__, __hash__, __le__, __len__, __lt__, __mod__, __mul__, __ne__, __rmod__, __rmul__, __sizeof__, __str__, capitalize, center, count, decode, encode, endswith, expandtabs, find, format, index, isalnum, isalpha, isdecimal, isdigit, islower, isnumeric, isspace, istitle, isupper, join, ljust, lower, lstrip, partition, replace, rfind, rindex, rjust, rpartition, rsplit, rstrip, split, splitlines, startswith, strip, swapcase, title, translate, upper, zfill

Inherited from unicode (private): _formatter_field_name_split, _formatter_parser

Inherited from interface.Interface: supports

Inherited from util.EventSender: clearAllEvents, sender

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __subclasshook__

    Overridden Methods
a new object with type S, a subtype of T
__new__(cls, *args, **kwargs)
If name is given, the newly created UI will wrap the UI with the given name.
source code
 
__repr__(self)
repr(x)
source code
 
__setattr__(self, attr, value)
Prevent properties or events that do not exist to be used by anyone, everything else is allowed though
source code
 
__init__(self, *args, **kwargs)
Initialize instance and check arguments
source code
    Properties
 
p_exists(self)
Returns: True if this instance still exists in maya
source code
 
p_ex(self)
Returns: True if this instance still exists in maya
source code
    Query Methods
 
children(self, **kwargs)
Returns: all intermediate child instances
source code
 
childrenDeep(self, **kwargs)
Returns: all child instances recursively
source code
 
parent(self)
Returns: parent instance of this ui element
source code

Inherited from interface.iDagItem: basename, isPartOf, isRoot, isRootOf, parentDeep, root

    Iterators

Inherited from interface.iDagItem: iterParents

    Name Generation

Inherited from interface.iDagItem: fullChildName

Class Methods [hide private]

Inherited from util.EventSender: listEventNames

    Overridden Methods
 
_exists(cls, uiname)
Returns: 1 if the given UI element exists, 0 if it does not exist and 2 it exists but the passed in name does not guarantee there are not more objects with the same name
source code
    Hierachy Handling
 
activeParent(cls)
Returns: NameUI of the currently set parent
source code
    Name Generation

Inherited from interface.iDagItem: addSep

Class Variables [hide private]
  _is_menu = False
hash(x)

Inherited from BaseUI: __melcmd__

Inherited from interface.iDagItem: kOrder_BreadthFirst, kOrder_DepthFirst

Inherited from util.EventSenderUI: reraise_on_error, sender_as_argument

    Configuration
  _sep = "|"
hash(x)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_exists(cls, uiname)
Class Method

source code 
Returns:
1 if the given UI element exists, 0 if it does not exist and 2 it exists but the passed in name does not guarantee there are not more objects with the same name

__new__(cls, *args, **kwargs)

source code 
If name is given, the newly created UI will wrap the UI with the given name. Otherwise the UIelement will be created
Parameters:
  • kwargs -
    • name:

      name of the user interface to wrap or the target name of a new elf element. Valid names for creation are short names ( without a | in it's path ), valid names for wrapping are short and preferably long names.

    • wrap_only:

      if True, default False, a wrap will be done even if the passed in name uses the short form ( for non-window elements ). If it exists, one cannot be sure whether more elements with the given name exist. If False, the system will create a new element of our type.

    • force_creation:

      if True, default False, a new item will be created even if an item with the given name uniquely exists. This might be necessary that you wish to create the given named item under the current parent, although an item with that name might already exist below another parent. This is required if you have a short name only

Returns: a new object with type S, a subtype of T
Overrides: object.__new__
Notes:
  • you can use args safely for your own purposes
  • if name is set but does not name a valid user interface, a new one will be created, and passed to the constructor

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__setattr__(self, attr, value)

source code 
Prevent properties or events that do not exist to be used by anyone, everything else is allowed though
Overrides: object.__setattr__

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

source code 
Initialize instance and check arguments
Overrides: object.__init__

children(self, **kwargs)

source code 
Parameters:
  • predicate - return True to include x in result
Returns:
all intermediate child instances
Overrides: interface.iDagItem.children
Notes:
  • the order of children is lexically ordered at this time
  • this implementation is slow and should be overridden by more specialized subclasses

childrenDeep(self, **kwargs)

source code 
Parameters:
  • order - order enumeration
  • predicate - returns true if x may be returned
Returns:
all child instances recursively
Overrides: interface.iDagItem.childrenDeep
Notes:
  • the order of children is lexically ordered at this time
  • this implementation is slow and should be overridden by more specialized subclasses

_parentString(self)

source code 
Returns:
string of the parent, without a wrap

Note: this helps mainly as a workaround for a maya 2011 issues, causing objectTypeUI not to work on many items

parent(self)

source code 
Returns:
parent instance of this ui element
Overrides: interface.iDagItem.parent

activeParent(cls)
Class Method

source code 
Returns:
NameUI of the currently set parent
Raises:
  • RuntimeError - if no active parent was set

uiDeleted(self)

source code 

If overridden in subclass, it will be called once the UI gets deleted within maya ( i.e. the user closed the window )eee The base implementation assures that all event-receivers that are bound to your events will be freed, allowing them to possibly be destroyed as well.

Use this callback to register yourself from all your event senders, then call the base class method.

Note: This is not related to the __del__ method of your object. Its worth noting that your instance will be strongly bound to a maya event, hence your instance will exist as long as your user interface element exists within maya.

type(self)

source code 
Returns:
the python class able to create this class

Note: The return value is NOT the type string, but a class

shortName(self)

source code 
Returns:
shortname of the ui ( name without pipes )

exists(self)

source code 
Returns:
True if this instance still exists in maya

p_exists(self)

source code 
Returns:
True if this instance still exists in maya

p_ex(self)

source code 
Returns:
True if this instance still exists in maya