I'm using the TreeView control in Maya 2009 but I'm getting a syntax error on drag and drop. My code is as follows (simplified for brevity):
class View(event.Dispatcher):
def __init__(self):
self.window = cmds.window()
tree_view = cmds.treeView(
numberOfButtons=1,
allowReparenting=True,
dragAndDropCommand=self.tree_view_onDrag
)
cmds.showWindow(self.window)
def tree_view_onDrag(self, dropped_items, old_parents, old_indexes, new_parent, new_indexes, item_before, item_after, *args):
print "worked"
When I drag and drop and element I get the following command is executed in the console:
<bound method View.tree_view_onDrag of {"layer 3"} {""} {1} "layer 1" {0} "" "layer 2";
And get the following error:
// Error: <bound method View.tree_view_onDrag of {"layer 3"} {""} {1} "layer 1" {0}€ //
// Error: Line 1.1: Syntax error //
EDIT: It turns out that the issues I was having were due to the treeView still implementing MEL function calls on most of its event callbacks. The errors above are being thrown by the MEL interpreter as it attempts to feed arguments to a command name.