query mouse and keyboard pose

18 views
Skip to first unread message

miarmy

unread,
Jan 13, 2015, 10:23:01 AM1/13/15
to python_in...@googlegroups.com
hi...example i have this code:
 
from PySide import QtGui, QtCore
def mouseAndkeyboard(*arg):
    print **************
       
timer = QtCore.QTimer()
timer.setInterval(1000.0 / 200)  # Print 25 times per second
timer.timeout.connect(print_mouse_position)
timer.start()
 
now i want mouseAndkeyboard def print... the shift key or midle button or...is Pressing or no?
sorry,my english is bad

Justin Israel

unread,
Jan 13, 2015, 1:30:21 PM1/13/15
to python_in...@googlegroups.com

If you are trying to randomly query the state of the keyboard modifiers and mouse buttons, then you can query them on the QApplication class as static methods :

http://qt-project.org/doc/qt-4.8/qapplication.html#keyboardModifiers

http://qt-project.org/doc/qt-4.8/qapplication.html#mouseButtons

But if this actually how you are going to use them, by starting a timer that checks repeatedly? The other way is to watch for the actual events to occur, and react.

Reply all
Reply to author
Forward
0 new messages