wolfhece.tablet_wintab
Direct WinTab pressure reader via Wintab32.dll (ctypes).
wx.glcanvas.GLCanvas is not registered as a WinTab context by wxPython,
so wx.MouseEvent.GetPressure() always returns 0.0 on OpenGL canvases even
with a working Wacom driver. This module bypasses wx and opens its own WinTab
context, then polls the packet queue in EVT_MOTION handlers.
Usage:
# In WolfMapViewer.__init__ (after super().__init__):
try:
from wolfhece.tablet_wintab import WinTabContext
self._wintab = WinTabContext(self.GetHandle())
except Exception as exc:
logging.warning("WinTab unavailable: %s", exc)
self._wintab = None
# In _get_event_pressure:
if self._wintab is not None:
return self._wintab.get_pressure()
# On window close:
if self._wintab is not None:
self._wintab.close()
Module Contents
- exception wolfhece.tablet_wintab.DllNotFoundError[source]
Bases:
RuntimeError
Raised when Wintab32.dll cannot be found on this machine.
- class wolfhece.tablet_wintab._LOGCONTEXTA[source]
Bases:
ctypes.Structure
LOGCONTEXTA — WinTab logical context (ASCII variant).
- class wolfhece.tablet_wintab._AXIS[source]
Bases:
ctypes.Structure
AXIS — range and resolution of one tablet axis.
- class wolfhece.tablet_wintab._PACKET[source]
Bases:
ctypes.Structure
Minimal WinTab packet containing only normal pressure.
Must match the
lcPktDatamask set in the LOGCONTEXT (only_PK_NORMAL_PRESSUREis requested, so the packet is one UINT).
- class wolfhece.tablet_wintab.WinTabContext(hwnd: int)[source]
Reads stylus pressure via
Wintab32.dll(polling mode).- Parameters:
hwnd – Native window handle, typically
wx.Window.GetHandle().- Raises:
RuntimeError – If
Wintab32.dllis not found or the tablet context cannot be opened (driver absent, no tablet connected, etc.).
- enable() None[source]
Enable the WinTab context so it starts delivering packets.
Called via
wx.CallAfterfrom_init_wintab_contextso that activation happens after the wx event loop has started, avoiding the Wacom driver heap-corruption bug triggered during app initialisation.