Message 1 of 7
treeView query in python?
Not applicable
06-09-2010
09:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi
suppose Hi have a treeView control like this
and I want to query the the itemIndex or the itemParent of the 'layer 2'
I can do :
but if I want to use Python?
this is the same window in python
about the query if I write
I got
than I write
but this ime he's looking for the item name
how is the sintax for this query in python?
thanks in advance
suppose Hi have a treeView control like this
string $window = `window`;
string $layout = `formLayout`;
string $control = `treeView -parent $layout -numberOfButtons 3 -abr false`;
formLayout -e
-attachForm $control "top" 2
-attachForm $control "left" 2
-attachForm $control "bottom" 2
-attachForm $control "right" 2
$layout;
showWindow $window;
treeView -edit -addItem "layer 1" "" $control;
treeView -edit -addItem "layer 2" "layer 1" $control;
treeView -edit -addItem "layer 3" "layer 2" $control;
and I want to query the the itemIndex or the itemParent of the 'layer 2'
I can do :
treeView -itemIndex "layer 2" -q $control; // result 0
treeView -itemParent "layer 2" -q $control; // result layer 1
treeView -itemExists "layer 2" -q $control; // result 1
but if I want to use Python?
this is the same window in python
import maya.cmds as cmds
from maya import cmds
window = cmds.window()
layout = cmds.formLayout()
control = cmds.treeView( parent = layout, numberOfButtons = 3, abr = False )
cmds.formLayout(layout,e=True, attachForm=(control,'top', 2))
cmds.formLayout(layout,e=True, attachForm=(control,'left', 2))
cmds.formLayout(layout,e=True, attachForm=(control,'bottom', 2))
cmds.formLayout(layout,e=True, attachForm=(control,'right', 2))
cmds.showWindow( window )
cmds.treeView( control, e=True, addItem = ("layer 1", ""))
cmds.treeView( control, e=True, addItem = ("layer 2", "layer 1"))
cmds.treeView( control, e=True, addItem = ("layer 3", "layer 2"))
about the query if I write
cmds.treeView( control, q =1, itemIndex = 'layer 2' )
I got
# TypeError: Flag 'itemIndex' must be passed a boolean argument when query flag is set #
than I write
cmds.treeView( control, q =1, itemIndex = 1)
but this ime he's looking for the item name
# RuntimeError: Item '' was not found in the treeview #
how is the sintax for this query in python?
thanks in advance