pygame is
Simple DirectMedia Layer is
Site Swing
Tablet Pressure

Tablet Pressure - 1.3

Eric Pavey (akeric)



A class giving you access to tablet pressure data in Pygame.

It requires the "Python Computer Graphics Kit" (cgkit) and specifically its wintab module:

Only works on windows (frown), since its an implementation of the wintab api. See homepage (link below) for, simple pygame showing example usage (what the screenshot was made with), and other instructions.


Updated to version 1.3: Realized that I didnā??t need to track mouse position and button-presses in the Tablet class: Pygame (obviously) does all this for you. Solves a lot of problems. Tablet object now only returns back pressure info, which is all we really want from it anyway. The example 'Pressure Test' app has been updated as well to reflect this as well. Simpler, but better! Windows only.


Home Page:


click to view original size


Tablet Pressure - 1.3 - Nov 4, 2009
Tablet Pressure - 1.0 - Oct 15, 2009 account Comments

If you wish to leave a comment with your account, please sign in first.

November 4, 2009 1:38am - Eric Pavey - nickname: (akeric)
Check out the new v1.3: I *hope* this should now resolve the issues you were having.
October 19, 2009 2:17pm - Eric Pavey - nickname: (akeric)
AH, I bet you're right! The smoke clears ;) It's probably disallowing you from being mapped into the pygame window, since you'd never be able to move back out of it. Although, I'm not sure I know of the fix seeing as I've never used a tablet PC before. But like you first mentioned, changing the example app to make it fullscreen should fix the problem. I've done some research as well into tracking the actual screen-position of the active pygame surface, and once I finish that it should let your stuff work too. In my copious spare time ;)
October 19, 2009 2:09pm - RB[0] - nickname: (roebros)
It had no effect - also tried some other options and some failed while others simply didn't affect anything :S

Perhaps the issue may be that I am using a tablet pc?
October 17, 2009 7:43pm - Eric Pavey - nickname: (akeric)
gar, I just replied, but pygame seemed to erase it. Again, but shorter:
The problem you're describing is exactly the one I was trying to work around having setup the system the way it is: Mapping the tablet space into the pygame screen. But it's weird that yours is staying mapped to the whole screen. I can simulate you problem by adding this immediately after the Context creation:
self.context.options = CXO_SYSTEM
Which turns the context into a "system context", re-mapping it back to the whole windows screen. Maybe you can just try this, immediately after the context is created:
self.context.options = 0
Who knows? :) Indeed, making fullscreen should resolve the issue, but I'd rather try and find the reason behind why its acting this way. I'm guessing you have some global windows system var set that's different than mine, and its changing the default way our tablets are reporting data. Or something :P
October 17, 2009 1:15pm - RB[0] - nickname: (roebros)
Interesting - well I couldn't find anything better to use.
I did sort of get it to work by getting the max display size and dividing the inextx/y by that instead of my window's size.
But then you would need to offset the x/y pos by the window's position - so I dunno...

I guess best you can do is recommend people use fullscreen mode when using it?
October 15, 2009 10:50pm - RB[0] - nickname: (roebros)
I will look into it sometime tomorrow hopefully :)
October 15, 2009 12:22pm - Eric Pavey - nickname: (akeric)
Interesting: On my machine, it maps the entire extents of my tablet to the extents of the pygame screen. Its physically impossible for me to move the tablet cursor outside that pygame window. Using the mouse though, I regain control for external applications. This is just first pass code, not sure why it would behave differently for you: I'm using these context attrs to query the tablet resolution, then I map that into the pygame screen space:
But maybe I should be using different attrs? (those just happened to work for me). If you want, check the wintab docs, replace those attrs with others and see if it changes your behavior?
October 15, 2009 11:07am - RB[0] - nickname: (roebros) - 4/5
Worked like a charm for me - except (using latest alpha for cgkit) - it assumes the entire display is the bounds for drawing - not the window...

Ie, when I run your example, it is a small(ish) window on my screen - but I can draw by pressing outside of the window - in fact, the far right of my screen is mapped to the far right of the window, instead of it only working while I am over the window...

our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
Nov 17, 2015

Nov 12, 2015

Nov 11, 2015

Nov 8, 2015

Oct 16, 2015

Oct 9, 2015

Sep 11, 2015

Sep 6, 2015

Aug 26, 2015

Aug 25, 2015

... more!
for pygame related questions, comments, and suggestions, please see help (lists, irc)