Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 4 commits
  • 4 files changed
  • 0 comments
  • 1 contributor

Showing 4 changed files with 41 additions and 22 deletions. Show diff stats Hide diff stats

  1. +1 1  README
  2. +7 0 lib/__init__.py
  3. +31 0 lib/window.py
  4. +2 21 main.py
2  README
... ... @@ -1 +1 @@
1   -Multitouch Recognizer using Python and PyMt
  1 +Multitouch Gesture Recognizer using Python and PyMt
7 lib/__init__.py
... ... @@ -0,0 +1,7 @@
  1 +#!/usr/bin/env python
  2 +# encoding: utf-8
  3 +"""
  4 +File: __init__.py
  5 +Adelino Lobão
  6 +03/02/2012
  7 +"""
31 lib/window.py
... ... @@ -0,0 +1,31 @@
  1 +#!/usr/bin/env python
  2 +# encoding: utf-8
  3 +"""
  4 +File: window.py
  5 +Adelino Lobão
  6 +03/02/2012
  7 +"""
  8 +
  9 +from pymt import *
  10 +
  11 +class WindowApp(MTWidget):
  12 + def __init__(self, **kwargs):
  13 + super(WindowApp, self).__init__(**kwargs)
  14 + #store gesture
  15 + self.gesture = []
  16 +
  17 + #fired when a touch is down
  18 + def on_touch_down(self, touch):
  19 + touch.userdata['points'] = list(touch.pos)
  20 + touch.userdata['trace'] = [touch.pos]
  21 +
  22 + #fired when a touch is moving
  23 + def on_touch_move(self, touch):
  24 + touch.userdata['points'].extend(touch.pos)
  25 + touch.userdata['trace'].append(touch.pos)
  26 +
  27 + #draw widget
  28 + def draw(self):
  29 + set_color(1,1,1)
  30 + for touch in getCurrentTouches():
  31 + drawLine(touch.userdata['points'])
23 main.py
@@ -7,25 +7,12 @@
7 7 """
8 8
9 9 from pymt import *
  10 +from lib.window import WindowApp
10 11
11 12 """
12 13 Class MTApplication
13 14 """
14   -class MTApplication(MTWidget):
15   - def __init__(self, **kwargs):
16   - super(MTApplication, self).__init__(**kwargs)
17   - self.gesture = [];
18   -
19   - #fired when a touch is down
20   - def on_touch_down(self, touch):
21   - touch.userdata['points'] = list(touch.pos)
22   - touch.userdata['trace'] = [touch.pos]
23   -
24   - #fired when a touch is moving
25   - def on_touch_move(self, touch):
26   - touch.userdata['points'].extend(touch.pos)
27   - touch.userdata['trace'].append(touch.pos)
28   -
  15 +class MTApplication(WindowApp):
29 16 #fired when a touch is up
30 17 def on_touch_up(self, touch):
31 18 #build gesture
@@ -34,12 +21,6 @@ def on_touch_up(self, touch):
34 21 print 'Recognition process...'
35 22 #clean gesture
36 23 self.gesture = []
37   -
38   - #draw widget
39   - def draw(self):
40   - set_color(1,1,1)
41   - for touch in getCurrentTouches():
42   - drawLine(touch.userdata['points'])
43 24
44 25 if __name__ == '__main__':
45 26 window = MTWindow()

No commit comments for this range

Something went wrong with that request. Please try again.