Note to self and world: PyQt PyKDE discovering state of num scroll and caps lock keys

maj 21, 2010

If you are looking for a Qt only solution, I am sorry, but that is not available (according to a bug report on qt which I now can’t find). If you are against using the KDE libraries, I am pretty sure you can do it with SDL.

import sys
from PyKDE4 import kdeui
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import Qt

app = QApplication(sys.argv)
a = kdeui.KModifierKeyInfo()
print(a.isKeyLocked(Qt.Key_NumLock))

The keys are in the PyQt4.QtCore.Qt class (and the names of the keys can be found in the qt docs).

Lämna en kommentar

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Logga ut / Ändra )

Twitter-bild

You are commenting using your Twitter account. Logga ut / Ändra )

Facebook-foto

You are commenting using your Facebook account. Logga ut / Ändra )

Ansluter till %s

Follow

Get every new post delivered to your Inbox.