@window.event
def on_text(text):
    try:
        index = int(text) - 1
    except ValueError:
        return
    
    if not (0 <= index < len(tablets)):
        return

    name = tablets[i].name

    try:
        canvas = tablets[i].open(window)
    except pyglet.input.DeviceException:
        print 'Failed to open tablet %d on window' % index

    print 'Opened %s' % name

    @canvas.event
    def on_enter(cursor):
        print '%s: on_enter(%r)' % (name, cursor)

    @canvas.event
    def on_leave(cursor):
        print '%s: on_leave(%r)' % (name, cursor)

    @canvas.event
    def on_motion(cursor, x, y, pressure):
        print '%s: on_motion(%r, %r, %r, %r)' % (name, cursor, x, y, pressure)
dataset/ETHPy150Open ardekantur/pyglet/examples/tablet.py/on_text/original