答案 0 :(得分:1)
在maya python小组中有这样的讨论。这是link,而你需要的代码片段
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()
#when ever you want to stop it uncomment below line
#timer.stop()