[PyKDE] The tablet event, it works not!

Sundance sundance at ierne.eu.org
Mon Oct 11 14:59:05 BST 2004


Hello people,

I've been playing around with tabletEvents, and they just plain don't 
work.

See the attached script:

---[ tabletevents.py ]-------------------------------------------------
import sys
from qt import *

class TabletWidget(QLabel):

  def __init__(self, parent=None,
               text="Please move and click\nthe pointer here!"):

    QLabel.__init__(self, parent)
    self.setText(text)
    self.setAlignment(Qt.AlignHCenter|Qt.AlignVCenter)
    self.setMinimumSize(QSize(320, 200))
    self.setMouseTracking(True)
    # It doesn't change a thing if I set mouse tracking to off, note.


  def tabletEvent(self, e):

    deviceType = e.device()
    deviceTypeName = { e.NoDevice: "None/Unknown",
                       e.Puck: "Puck",
                       e.Stylus: "Stylus",
                       e.Eraser: "Eraser" } [deviceType]
    pressure = e.pressure()
    idType, idSerial=e.uniqueId()
    x = e.x()
    y = e.y()

    print "Device %d:%d (%s) X:%d Y:%d Pr:%d" % \
          (idType, idSerial, deviceTypeName, x, y, pressure)

    e.ignore()
    # It doesn't change a thing if I accept() the event instead, note.


if __name__ == "__main__":

  app=QApplication(sys.argv)
  widget = TabletWidget()
  app.setMainWidget(widget)
  widget.show()
  app.exec_loop()
-----------------------------------------------------------------------

This is with Qt 3.3.3 and PyQt 3.12.
Yes, Qt has been compiled with tablet supported enabled, I've 
doublechecked.

Anyone has any idea what I'm doing wrong?
Thanks. :)

-- S.




More information about the PyQt mailing list