This command creates a custom control.
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
addItem (ai) | unicode, unicode | ||
Adds a tree view item to the tree view. First argument specifies the item’s name, second argument specifies the item’s parent (use an empty string to have it at the top level of the tree) |
|||
allowHiddenParents (ahp) | bool | ||
If not cleared(default), the treeView will make parent nodes of visibles nodes automatically visible Flag can have multiple arguments, passed either as a tuple or a list. |
|||
allowReparenting (arp) | bool | ||
Allow the user to reparent items in the tree view using the middle mouse button. Defaults to true. If false, user can still reorder items within a group using the middle mouse button. |
|||
annotation (ann) | unicode | ||
|
|||
attachButtonRight (abr) | int | ||
Sets tree view item’s buttons to appear on the right or left. Argument specifies if they are to be attached to the right, if it is set to false they will attach on the left. |
|||
backgroundColor (bgc) | float, float, float | ||
The background color of the control. The arguments correspond to the red, green, and blue color components. Each component ranges in value from 0.0 to 1.0. When setting backgroundColor, the background is automatically enabled, unless enableBackground is also specified with a false value. |
|||
borderHighlite (bh) | unicode, bool | ||
|
|||
borderHighliteColor (bcl) | unicode, float, float, float | ||
Sets the color an item’s border highlite will turn when highlite is enabled. first paramater specifies layer three float values specify RGB values, between 0 and 1. |
|||
buttonState (bst) | unicode, int, unicode | ||
Sets the state of a button. First argument specifies the layer, second argument specifies which button, third argument specifies the state Possible states: buttonUp- button is up buttonDown- button is down buttonThirdState- button is in state three (used by the 3StateButtonbutton style) |
|||
buttonStyle (bs) | unicode, int, unicode | ||
Sets the type of button, used to indicate possible states and if the button is reset upon release. First argument specifies the layer, second argument specifies which button, third argument specifies the type of button Possible button types: pushButton- two possible states, button is reset to up upon release 2StateButton- two possible states, button changes state on click 3StateButton- three button states, button changes state on click |
|||
buttonTextIcon (bti) | unicode, int, unicode | ||
Sets a one letter text to use as the icon to use for a specific button on a specific item. First argument specifies the item, second argument specifies the button, third argument specifies the icon text. |
|||
buttonTooltip (btp) | unicode, int, unicode | ||
Sets a tooltip for specific button on a specific item. First argument specifies the item, second argument specifies the button, third argument specifies the tooltip. |
|||
buttonTransparencyColor (btc) | unicode, int, float, float, float | ||
Sets the background color of a button that will be used if buttonTransparencyOverride is enabled. First argument specifies item, second argument specifies button, three floats specify RGB values, between 0 and 1. |
|||
buttonTransparencyOverride (bto) | unicode, int, bool | ||
|
|||
buttonVisible (bvf) | unicode, int, bool | ||
|
|||
children (ch) | unicode | ||
|
|||
clearSelection (cs) | bool | ||
|
|||
contextMenuCommand (cmc) | unicode | ||
Set the callback function to be invoked just before any attached context menu is shown. This can be used as a replacement to, or in addition to the postMenuCommand flag on the popupMenu command. The function should accept a string which will be the item that was clicked on (empty if no item was hit). The function should return true if the menu should be shown, false otherwise. |
|||
defineTemplate (dt) | unicode | ||
Puts a command in a mode where any other flags and args are parsed and added to the command template specified in the argument. They will be used as default arguments in any subsequent invocations of the command when templateName is set as the current template. |
|||
displayLabel (dl) | unicode, unicode | ||
Set a label for the item that is different than the string that identifies the item. This label will be used in the display of the item. The first parameter specifies the item, the second specifies the display label. |
|||
displayLabelSuffix (dls) | unicode, unicode | ||
|
|||
docTag (dtg) | unicode | ||
|
|||
dragAndDropCommand (dad) | unicode | ||
Sets the callback function to be invoked upon drag and drop of layers. the callback function should take as parameters: - a string array of the dropped items - a string array of the items previous parents - an integer array of the items previous indexes - a string for the item(s) new parent - an integer array for the item’s new indexes - a string for the item that now comes before the dropped items - a string for the item that now comes after the dropped items |
|||
dragCallback (dgc) | callable | ||
Adds a callback that is called when the middle mouse button is pressed. The MEL version of the callback is of the form: global proc string[] callbackName(string $dragControl, int $x, int $y, int $mods) The proc returns a string array that is transferred to the drop site. By convention the first string in the array describes the user settable message type. Controls that are application defined drag sources may ignore the callback. $mods allows testing for the key modifiers CTL and SHIFT. Possible values are 0 == No modifiers, 1 == SHIFT, 2 == CTL, 3 == CTL + SHIFT. In Python, it is similar, but there are two ways to specify the callback. The recommended way is to pass a Python function object as the argument. In that case, the Python callback should have the form: def callbackName( dragControl, x, y, modifiers ): The values of these arguments are the same as those for the MEL version above. The other way to specify the callback in Python is to specify a string to be executed. In that case, the string will have the values substituted into it via the standard Python format operator. The format values are passed in a dictionary with the keys dragControl, x, y, modifiers. The dragControlvalue is a string and the other values are integers (eg the callback string could be print ‘%(dragControl)s %(x)d %(y)d %(modifiers)d’ |
|||
dropCallback (dpc) | callable | ||
Adds a callback that is called when a drag and drop operation is released above the drop site. The MEL version of the callback is of the form: global proc callbackName(string $dragControl, string $dropControl, string $msgs[], int $x, int $y, int $type) The proc receives a string array that is transferred from the drag source. The first string in the msgs array describes the user defined message type. Controls that are application defined drop sites may ignore the callback. $type can have values of 1 == Move, 2 == Copy, 3 == Link. In Python, it is similar, but there are two ways to specify the callback. The recommended way is to pass a Python function object as the argument. In that case, the Python callback should have the form: def pythonDropTest( dragControl, dropControl, messages, x, y, dragType ): The values of these arguments are the same as those for the MEL version above. The other way to specify the callback in Python is to specify a string to be executed. In that case, the string will have the values substituted into it via the standard Python format operator. The format values are passed in a dictionary with the keys dragControl, dropControl, messages, x, y, type. The dragControlvalue is a string and the other values are integers (eg the callback string could be print ‘%(dragControl)s %(dropControl)s %(messages)r %(x)d %(y)d %(type)d’ |
|||
editLabelCommand (elc) | unicode | ||
Set the callback function to be invoked when the user changes the name of an item by double clicking it in the UI. The callback should accept two string arguments: the item name and the new name. The item name refers to the name of the item and not the display label. The callback function should return a string. An empty string indicates that the rename operation was invalid and the control should revert to the original name. If the rename operation is valid the callback should return a string that identifies the item, possibly different from the new display name entered by the user. |
|||
enable (en) | bool | ||
The enable state of the control. By default, this flag is set to true and the control is enabled. Specify false and the control will appear dimmed or greyed-out indicating it is disabled. |
|||
enableBackground (ebg) | bool | ||
|
|||
enableButton (eb) | unicode, int, int | ||
Sets a specific button on a specific item to being usable or not. First argument specifies the item, second argument specifies the button, third argument specifies on or off. |
|||
enableKeys (enk) | bool | ||
By default the treeview does not accept input from the keyboard. By enabling keyboard support The treeview will support up/down navigation using the up/down arrow keys. |
|||
enableLabel (enl) | unicode, int | ||
|
|||
exists (ex) | bool | ||
|
|||
expandCollapseCommand (ecc) | unicode | ||
Set the callback function to be invoked upon hitting the expand/collapse button. The function should take as paramaters: - a string for the item for which the expand/collapse button was hit - an integer for the state of expansion |
|||
expandItem (ei) | unicode, bool | ||
|
|||
flatButton (fb) | int | ||
font (fn) | unicode, unicode | ||
The first parameter specifies the item string for the TtreeViewNode in the TtreeNodeMap. The second string specifies the font for the text. Valid values are boldLabelFont, smallBoldLabelFont, tinyBoldLabelFont, plainLabelFont, smallPlainLabelFont, obliqueLabelFont, smallObliqueLabelFont, fixedWidthFontand smallFixedWidthFont. |
|||
fontFace (ff) | unicode, int | ||
|
|||
fullPathName (fpn) | bool | ||
|
|||
height (h) | int | ||
|
|||
hideButtons (hb) | bool | ||
Hides the buttons for an item in the tree view. Can only be used when adding the item to the tree with the addItemflag. Space for the buttons is left to make sure items still line up correctly under their parent. |
|||
highlite (hl) | unicode, bool | ||
|
|||
highliteColor (hc) | unicode, float, float, float | ||
|
|||
image (i) | unicode, int, unicode | ||
|
|||
isItemExpanded (iie) | unicode | ||
|
|||
isLeaf (il) | unicode | ||
|
|||
isObscured (io) | bool | ||
Return whether the control can actually be seen by the user. The control will be obscured if its state is invisible, if it is blocked (entirely or partially) by some other control, if it or a parent layout is unmanaged, or if the control’s window is invisible or iconified. |
|||
itemExists (iex) | unicode | ||
|
|||
itemIndex (idx) | unicode | ||
|
|||
itemParent (ip) | unicode | ||
|
|||
itemRenamedCommand (irc) | unicode | ||
Set the callback function to be invoked when an item in the tree has been renamed. This occurs if there is a successful return of the command attached by editLabelCommandor unconditionally if there is no editLabelCommand. The callback should accept two strings, the old name and the new name of the item that was renamed. |
|||
itemSelected (isl) | unicode | ||
|
|||
itemVisible (iv) | unicode, bool | ||
|
|||
labelBackgroundColor (lbc) | unicode, float, float, float | ||
Set the background color for text label for a particular item in the tree. The first parameter specifies layer. Set (-1.0, -1.0, -1.0) to restore the background to the default of transparent |
|||
manage (m) | bool | ||
|
|||
numberOfButtons (nb) | int | ||
|
|||
numberOfPopupMenus (npm) | bool | ||
|
|||
ornament (ornament) | unicode, int, int, int | ||
Sets an item as having an ornament (a small colored circle) as on or off, its size, and if it should have a dot in the center. First Argument specifies item, second argument specifies on or off, third argument specifies radius (in pixels), fourth argument specifies dotted or not. |
|||
ornamentColor (orc) | unicode, float, float, float | ||
|
|||
parent (p) | unicode | ||
|
|||
popupMenuArray (pma) | bool | ||
|
|||
pressCommand (pc) | int, unicode | ||
preventOverride (po) | bool | ||
|
|||
removeAll (ra) | bool | ||
|
|||
reverseTreeOrder (rto) | bool | ||
|
|||
rightPressCommand (rpc) | int, unicode | ||
Sets the callback function to be invoked upon right clicking a button. First argument specifies button. Second argument specifies the callback function to be executed the callback function should take as parameters: - a string for the item whose button was clicked - an int for the button that was clicked’s state |
|||
select (sl) | unicode, int | ||
selectCommand (sc) | unicode | ||
Set the callback function to be invoked when an item is selected or deselected in the tree. The function should accept one string argument and one integer argument: the item name and the select state respectively. If the function returns true, the select/deselect is considered valid and will occur normally, otherwise it will be disallowed. name and |
|||
selectItem (si) | unicode, bool | ||
|
|||
selectionChangedCommand (scc) | unicode | ||
Set the callback function to be invoked when a complete selection operation triggered by the user has occured successfully. The callback is invoked if the selectCommandcallback has returned a non-empy value (or always there is no selectCommandcallback). This differs from selectCommand in that a simple selection replacement will generate two calbacks with selectCommand(one for deselect of the old item and one for select of the new), whereas selectionChangedCommandwill only be invoked once, after the selection is complete. The callback is not passed any parameters and does not need to return any value (ie. It is simply a notification mechanism). |
|||
selectionColor (scl) | unicode, float, float, float | ||
|
|||
showItem (shi) | unicode | ||
|
|||
textColor (tc) | unicode, float, float, float | ||
|
|||
useTemplate (ut) | unicode | ||
|
|||
visible (vis) | bool | ||
The visible state of the control. A control is created visible by default. Note that a control’s actual appearance is also dependent on the visible state of its parent layout(s). |
|||
visibleChangeCommand (vcc) | callable | ||
|
|||
width (w) | int | ||
|
Derived from mel command maya.cmds.treeView
Example:
import pymel.core as pm
from maya import cmds
window = pm.window()
layout = pm.formLayout()
control = pm.treeView( parent = layout, numberOfButtons = 3, abr = False )
pm.formLayout(layout,e=True, attachForm=(control,'top', 2))
# Result: ui.FormLayout('window1|formLayout55') #
pm.formLayout(layout,e=True, attachForm=(control,'left', 2))
# Result: ui.FormLayout('window1|formLayout55') #
pm.formLayout(layout,e=True, attachForm=(control,'bottom', 2))
# Result: ui.FormLayout('window1|formLayout55') #
pm.formLayout(layout,e=True, attachForm=(control,'right', 2))
# Result: ui.FormLayout('window1|formLayout55') #
pm.showWindow( window )
pm.treeView( control, e=True, addItem = ("layer 1", ""))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 2", ""))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 3", ""))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 4", ""))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 5", ""))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 6", ""))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 7", "layer 2"))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 8", "layer 2"))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 9", "layer 2"))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 10", "layer 8"))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 11", "layer 2"))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 12", ""))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, e=True, addItem = ("layer 13", "layer 10"))
# Result: u'window1|formLayout55|treeView1' #
pm.treeView( control, edit=True, removeAll = True )
# Result: u'window1|formLayout55|treeView1' #