Hi, I am trying to make a drag and drop function to be able to drag an
icon or image from my window into the main maya window... So far I was
able to drag and drop an icon from one part of my window to another
part of the same window... but I can't figure out how to drag and drop
from the window to a Maya window.

The problem I see is that the dropcallback need to be put on the drop
site and not on the item being drag... I guess I could add a
dropcallback in the main maya window, but i'm sure there must be a
better way that doesn't require modifying the main maya layouts and
windows.

Anyone even manage to get this to work?

Thanks

here is the code that works from one part of the window to another...
simply run the script and middle drag the icon to the right part of
the window.


import maya.cmds as cmds

def dragCallback( dragControl, x, y, modifiers ):
        print '--begin drag--'
        print 'dragControl', dragControl
        print 'x', x
        print 'y', y
        print 'modifiers ', modifiers
        image = cmds.iconTextButton(dragControl, q=True, image=True)
        msgs = [image]
        print msgs
        print '--end drag--'
        return msgs


def dropCallback( dragControl, dropControl, messages, x, y,
dragType ):
        print '--begin drop--'
        print 'dragControl', dragControl
        print 'dropControl', dropControl
        print 'messages', messages
        print 'x', x
        print 'y', y
        print 'dragType', dragType
        print '--end drop--'
        parent=dropControl
        cmds.setParent(parent)
        cmds.iconTextButton(image=messages[0])



cmds.window()
cmds.gridLayout( numberOfColumns=2, cellWidthHeight=(160, 160))
cmds.iconTextButton( style='iconOnly', image1='sphere.xpm',
label='sphere', dgc=dragCallback)
cmds.gridLayout( numberOfColumns=2, cellWidthHeight=(160, 160),
dpc=dropCallback)
cmds.showWindow()
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to