/usr/share/pyshared/pymt/tools/demo.py is in python-pymt 0.5.1-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import os
from pymt import *
particle_fn = os.path.join(pymt_data_dir, 'particle.png')
class TouchTracer(MTWidget):
def __init__(self, **kwargs):
super(TouchTracer, self).__init__(**kwargs)
def on_touch_down(self, touch):
color = get_random_color()
touch.userdata['touchtracer.color'] = color
touch.userdata['touchtracer.pos'] = list(touch.pos)
def on_touch_move(self, touch):
touch.userdata['touchtracer.pos'] += list(touch.pos)
def draw(self):
k = {'anchor_y': 'bottom', 'font_size': 10}
margin = 4
set_brush(particle_fn)
points = 0
for touch in getCurrentTouches():
set_color(*touch.userdata['touchtracer.color'])
paintLine(touch.userdata['touchtracer.pos'], width=5)
label = 'ID: %s\npos: (%d,%d)\nDevice: %s\nDouble Tap: %s' % (
touch.id, touch.pos[0], touch.pos[1],
touch.device, str(touch.is_double_tap))
# draw a little box with margin
obj = getLabel(label=label, **k)
pos = Vector(touch.pos) + Vector(0, 10)
lpos = pos - Vector(obj.width / 2. + margin, margin)
lsize = Vector(obj.size) + Vector(margin * 2, margin * 2)
set_color(.2, .2, .4)
drawRoundedRectangle(pos=(int(lpos.x), int(lpos.y)), size=lsize)
drawLabel(label=label, pos=pos, **k)
points += len(touch.userdata['touchtracer.pos'])
drawLabel(label='%d' % points, color=(.5,.5,.5), pos=(5, 5),
center=False)
if __name__ == '__main__':
runTouchApp(TouchTracer())
|