My favorites
▼
|
Sign in
pymt
PyMT, a framework for making accelerated multitouch UI
Project Home
Downloads
Issues
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
221
attachment: IT_Flip_Showcase.py
(2.4 KB)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# PYMT Plugin integration
IS_PYMT_PLUGIN = True
PLUGIN_TITLE = 'Flip Showcase'
PLUGIN_AUTHOR = 'Eduardo Garcia'
PLUGIN_EMAIL = 'simbaedu@yahoo.com.br'
PLUGIN_DESCRIPTION = 'Flips parts of an image when someone passes in front it'
from pymt import *
import OpenGL
class IT_Flip_Showcase(MTScatterWidget):
def __init__(self, pos, **kwargs):
super(IT_Flip_Showcase, self).__init__(**kwargs)
self.style = {'bg-color':(.0,.0,.0,1)}
self.size = [1024,768]
self.pos = [pos[0] + self.width /2, pos[1] + self.height /2 ]
self.do_translation = False
self.do_rotation = False
self.do_scale = False
self.flips = []
self.last_position = [0,0]
self.direction = ""
self.time = getFrameDt()
self.delay = 3
self.time_limit = 0
current_dir = os.path.dirname(__file__)
for i in range (0, 5):
#flip = IT_Flip(index=i, size=[204.8, self.height], pos=[204 * i, 0 ])
#flip.push_handlers(on_flip=self.check_flips)
flip = MTFlippableWidget(size=[204.8, self.height], pos=[204 * i, 0 ],
flipangle=90+40-i*20)
flip.push_handlers(on_touch_down=curry(self.flip, flip) )
front_image = MTContainer(Image(
os.path.join(current_dir, 'front%d.jpg' % i)))
back_image = MTContainer(Image(
os.path.join(current_dir, 'back%d.jpg' % i)))
flip.add_widget(front_image, side='front')
flip.add_widget(back_image, side='back')
self.flips.append(flip)
self.add_widget(flip)
def flip(self, flip, touch):
if flip.collide_point(touch.x, touch.y):
flip.flip()
def pymt_plugin_activate(window, ctx):
ctx.showcase = IT_Flip_Showcase(pos=[0,0])
window.add_widget(ctx.showcase)
def pymt_plugin_deactivate(window, ctx):
ctx.showcase.__finalize__()
window.remove_widget(ctx.showcase)
del ctx.showcase
if __name__ == '__main__':
window = MTWindow()
#window._size = [1024,768]
#window.toggle_fullscreen()
#window.toggle_fullscreen()
ctx = MTContext()
pymt_plugin_activate(window, ctx)
runTouchApp()
pymt_plugin_deactivate(window, ctx)
Powered by
Google Project Hosting