From 7df79442a3eef094fa3ded14c50a9e61b2ccb6e5 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Wed, 27 Apr 2011 18:51:44 +0200 Subject: [PATCH] touchtracer: fixes for text flickering (since we was using floatlayout, size/size_hint was going into conflict). + pep8 fixes --- examples/demo/touchtracer/main.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/demo/touchtracer/main.py b/examples/demo/touchtracer/main.py index 42e59c7fb..ea678d966 100644 --- a/examples/demo/touchtracer/main.py +++ b/examples/demo/touchtracer/main.py @@ -8,6 +8,7 @@ from kivy.graphics import Color, Rectangle, Point from random import random from math import sqrt + def calculate_points(x1, y1, x2, y2, steps=5): dx = x2 - x1 dy = y2 - y1 @@ -25,6 +26,7 @@ def calculate_points(x1, y1, x2, y2, steps=5): class Touchtracer(FloatLayout): + def on_touch_down(self, touch): win = self.get_parent_window() ud = touch.ud @@ -35,10 +37,9 @@ class Touchtracer(FloatLayout): Rectangle(pos=(touch.x, 0), size=(1, win.height), group=g), Rectangle(pos=(0, touch.y), size=(win.width, 1), group=g), Point(points=(touch.x, touch.y), source='particle.png', - pointsize=5, group=g) - ) + pointsize=5, group=g)) - ud['label'] = Label() + ud['label'] = Label(size_hint=(None, None)) self.update_touch_label(ud['label'], touch) self.add_widget(ud['label']) @@ -65,11 +66,7 @@ class Touchtracer(FloatLayout): def update_touch_label(self, label, touch): label.text = 'ID: %s\nPos: (%d, %d)\nClass: %s' % ( - touch.id, - touch.x, - touch.y, - touch.__class__.__name__ - ) + touch.id, touch.x, touch.y, touch.__class__.__name__) label.texture_update() label.pos = touch.pos label.size = label.texture_size[0] + 20, label.texture_size[1] + 20 @@ -78,8 +75,9 @@ class Touchtracer(FloatLayout): class TouchtracerApp(App): title = 'Touchtracer' icon = 'icon.png' + def build(self): return Touchtracer() -if __name__ in ('__main__', '__android__'): +if __name__ in ('__main__', '__android__'): TouchtracerApp().run()