'Pyglet Tablet Input make weird prints
So, I want to make a Whiteboard app and I decided to make it in pyglet, because it has support for tablet input, but when I use the tablet, it is making some prints that I didn't ask for.
Like: 0 0 0 0 0 0 0 (or 1 if I press the pen on the surface)
There is any possibility to stop that?
'''
import pyglet
window = pyglet.window.Window(800, 600, "Whiteboard", resizable=True)
points = []
is_drawing = False
is_pen_drawing = False
tablets = pyglet.input.get_tablets()
if len(tablets) > 0:
tablet = tablets[0]
tablet = tablet.open(window)
@tablet.event
def on_motion(cursor, x, y, pressure, a, b):
if pressure > 0:
is_pen_drawing = True
points.append((x, y))
else:
is_pen_drawing = True
@window.event
def on_mouse_press(x, y, button, modifiers):
if button == pyglet.window.mouse.LEFT:
global is_drawing
is_drawing = True
@window.event
def on_mouse_release(x, y, button, modifiers):
if button == pyglet.window.mouse.LEFT:
global is_drawing
is_drawing = False
points.append(None)
@window.event
def on_mouse_drag(x, y, dx, dy, buttons, modifiers):
if is_drawing and not is_pen_drawing:
pos = (x, y)
if pos not in points:
points.append(pos)
@window.event
def on_draw():
window.clear()
for i in range(0, len(points) - 1):
if points[i] is not None and points[i + 1] is not None:
pyglet.graphics.draw(2, pyglet.gl.GL_LINES,
('v2f', points[i] + points[i + 1]))
pyglet.app.run()
'''
Solution 1:[1]
There was a redundant print
at Pyglet's code. Fixed at https://github.com/pyglet/pyglet/pull/612
You can remove it yourself - pyglet/input/wintab.py - end of _event_wt_packet
function (actually, in my version it's the only print
in this file).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Zvika |