سؤال

I'm creating a simple GUI menu with 2X3 ImageButtons using PyQt4. It should look like this, except there should be images instead of text:

There should be images instead of text

I followed this tutorial: http://popdevelop.com/2010/05/an-example-on-how-to-make-qlabel-clickable/ for creating image buttons out of QLabels and I put them in grid layout.

It works fine, but my problem is that my application is supposed to be used using keyboard arrows (without mouse), so I want to make visible which label is focused before being selected.

Is it possible to do in PyQt? Thanks in advance

هل كانت مفيدة؟

المحلول

One way of capturing keyboard events is done by installing an event filter in your app with installEventFilter ( QObject * filterObj ) and then filter with something like:

if event.type() == QEvent.KeyPress:
    print "Key pressed!"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top