[英]Pyglet Tablet Input make weird prints
所以,我想制作一個 Whiteboard 應用程序,我決定用 pyglet 制作它,因為它支持平板電腦輸入,但是當我使用平板電腦時,它會打印一些我沒有要求的打印件。
喜歡:0 0 0 0 0 0 0(如果我將筆按在表面上,則為 1)
有沒有可能阻止它?
'''
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()
'''
Pyglet 的代碼有多余的print
。 固定在https://github.com/pyglet/pyglet/pull/612
你可以自己刪除它 - pyglet/input/wintab.py - end of _event_wt_packet
function (實際上,在我的版本中,它是這個文件中唯一的print
)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.