<s> import pyglet <EOL> window = pyglet . window . Window ( ) <EOL> tablets = pyglet . input . get_tablets ( ) <EOL> canvases = [ ] <EOL> if tablets : <EOL> print '<STR_LIT>' <EOL> for i , tablet in enumerate ( tablets ) : <EOL> print '<STR_LIT>' % ( i + <NUM_LIT:1> , tablet . name ) <EOL> print '<STR_LIT>' <EOL> else : <EOL> print '<STR_LIT>' <EOL> @ window . event <EOL> def on_text ( text ) : <EOL> try : <EOL> index = int ( text ) - <NUM_LIT:1> <EOL> except ValueError : <EOL> return <EOL> if not ( <NUM_LIT:0> <= index < len ( tablets ) ) : <EOL> return <EOL> name = tablets [ i ] . name <EOL> try : <EOL> canvas = tablets [ i ] . open ( window ) <EOL> except pyglet . input . DeviceException : <EOL> print '<STR_LIT>' % index <EOL> print '<STR_LIT>' % name <EOL> @ canvas . event <EOL> def on_enter ( cursor ) : <EOL> print '<STR_LIT>' % ( name , cursor ) <EOL> @ canvas . event <EOL> def on_leave ( cursor ) : <EOL> print '<STR_LIT>' % ( name , cursor ) <EOL> @ canvas . event <EOL> def on_motion ( cursor , x , y , pressure ) : <EOL> print '<STR_LIT>' % ( name , cursor , x , y , pressure ) <EOL> @ window . event <EOL> def on_mouse_press ( x , y , button , modifiers ) : <EOL> print '<STR_LIT>' % ( x , y , button , modifiers ) <EOL> @ window . event <EOL> def on_mouse_release ( x , y , button , modifiers ) : <EOL> print '<STR_LIT>' % ( x , y , button , modifiers ) <EOL> pyglet . app . run ( ) </s>
