Mouse move events will occur only when a mouse button is pressed down, unless mouse tracking has been enabled with QWidget::setMouseTracking().
For real-time, regardless of playback or events, you could do this.
from PySide import QtGui, QtCore
def print_mouse_position():
point = QtGui.QCursor().pos()
print "x: %s; y: %s"
% (point.x(), point.y())
timer = QtCore.QTimer()
timer.setInterval(1000.0 / 25) # Print 25 times per second
timer.timeout.connect(print_mouse_position)
timer.start()
# timer.stop() # Call this to stop printing
This would need to to be enabled on the widget of interest and all ancestors. You could perhaps recursively walk through all QWidget children starting at the Maya Main Window, or walk up through the parents from the widget of interest.
You could use QApplication.allWidgets()
for this, but there’s still an amount of elements in the Maya window without mouse tracking functionality; mainly the viewport. Not to mention the potential performance bottleneck, and the fact that some widgets may rely on having tracking disabled; e.g. widgets that overlap. Don’t do this. :)
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CANESWi1YAh3RtGw15EAkpKNUci1ue4N9JTR2g5esssG-nOTMCw%40mail.gmail.com.
You could use
QApplication.allWidgets()
Oh man! .allWidgets(). What a great/terrible idea.
I know right. :) I discovered it not too long ago and have found it handy for debugging, but not much else. There’s also .topLevelWidgets() which can be a handy replacement for getting a handle to the Maya window, independent of both PyQt and PySide specifics, as discussed here.
from PySide import QtGui
widgets = dict((w.objectName(), w) for w in QtGui.QApplication.topLevelWidgets())
window = widgets['MayaWindow']
.. I’m not sure if this is going off topic, but you could try to implement something at the windows manager level.
There’s really no need, PySide is cross-platform too and something like iographica could be implemented using a similar approach to the above.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CANESWi2uk4DsQ%3D9zMi_q01t%3De-mmHf-K9d5Mun2XDoCdoHgXGg%40mail.gmail.com.