How to enable drag selection in UI Maya Python
<p>I would like to know how to enable drag selection to select some buttons on my UI.</p>

<p>I have tried to use <code>cmds.selectPref(clickBoxSize=True)</code> but it doesn't work.</p>

<pre><code>import maya.cmds as cmds
import shiboken
import maya.OpenMayaUI as omUI
from PySide import QtGui, QtCore
ui_btns = {}

win = cmds.window()
cmds.columnLayout(adjustableColumn=True)
ui_btns["btn_a"] = cmds.button(label="Burning")
ui_btns["btn_b"] = cmds.button(label="Man")
cmds.setParent("..")
cmds.showWindow(win)

draggerContext_id = "dga"
def dga():
    cp = QtGui.QCursor().pos()
    widget = QtGui.qApp.widgetAt(cp)
    ui_id = omUI.MQtUtil.fullName(long(shiboken.getCppPointer(widget)[0]))
    print "ui path :{0}".format([ui_id for k, v in ui_btns.iteritems() if ui_id in v])

cmds.draggerContext(draggerContext_id, dragCommand = "dga()", cursor="hand", space="screen")
cmds.setToolTo(draggerContext_id)
</code></pre>

<p>its a simple idea to get the ui path, you can also replace the draggerContext with a scriptjob or the threading.Timer().start() command, there are more solutions, depend on your UI and the workflow (post process eval or ui element dragcallback...it would be great to see some sections from your code)</p>

python maya