Your Tingbot comes equipped with a resistive touch screen! It’s easy to react to touch events.
import tingbot from tingbot import * screen.fill(color='black') @touch() def on_touch(xy): screen.rectangle(xy=xy, size=(5,5), color='blue') tingbot.run()
This is a simple drawing app. It uses the
@touch() decorator to receive touch events and draws a
rectangle to the screen at the same place.
touch(xy=…, size=…, align=…)
This ‘decorator’ marks the function after it to receive touch events.
You can optionally pass an area that you’re interested in, using the
alignarguments. If you specify no area, you will receive all touch events.
The handler function can optionally take the arguments
xyis the location of the touch.
actionis one of ‘down’, ‘move’, ‘up’.
@touch() def on_touch(xy): screen.rectangle(xy=xy, size=(5,5), color='blue')