My favorites | Sign in
Project Home Downloads Issues
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 174 attachment: scroller.py (3.9 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
'''
WORK UNDER PROGRESS
Please do not change anything :)

Thank You.
Sharath Patali

'''

from __future__ import with_statement
from pymt import *
import pyglet
from pyglet.gl import *
from pyglet.graphics import draw

class MTicon(MTButton):
def __init__(self, **kwargs):
kwargs.setdefault('scale', 1.0)
kwargs.setdefault('filename', None)
if kwargs.get('filename') is None:
raise Exception('No filename given to MTicon')

super(MTicon, self).__init__(**kwargs)
self.fname = kwargs.get('filename')
img = pyglet.image.load(kwargs.get('filename'))
self.image = pyglet.sprite.Sprite(img)
self.image.x = self.x
self.image.y = self.y
self.scale = kwargs.get('scale')
self.image.scale = self.scale
self.width,self.height = (self.image.width, self.image.height)
self.texture = img.get_texture()

def draw(self):
self.image.x = self.x
self.image.y = self.y
self.size = (self.image.width, self.image.height)
#
set_color(1, 1, 1, 1)
drawCover(self.texture.id, pos=(self.x,self.y), size=(self.image.width,self.image.height))
self.parent.do_layout()




self.parent.do_layout()

def on_touch_down(self, touch):
if self.collide_point(touch.x,touch.y):
print "Touched"
print "file: ",self.fname , self.parent.parent.to_parent(self.x,self.y)[0]
return

def on_touch_move(self, touch):
return

def on_touch_up(self, touch):
if self.collide_point(touch.x, touch.y):
return

def on_draw(self):
if (self.parent.parent.to_parent(self.x,self.y)[0] >= (w.width/2-256)) & (self.parent.parent.to_parent(self.x,self.y)[0] <= (w.width/2)):
if self.image.scale < 1.0:
self.image.scale = self.image.scale+0.07
self.width,self.height = (self.image.width, self.image.height)
else:
if self.image.scale > 0.5:
self.image.scale = self.image.scale-0.07
self.width,self.height = (self.image.width, self.image.height)
self.draw()

def drawCover(texture, pos=(0,0), size=(1.0,1.0)):
with gx_texture(texture):
pos = ( pos[0],pos[1], pos[0]+size[0],pos[1], pos[0]+size[0],pos[1]+size[1], pos[0],pos[1]+size[1] )
texcoords = (0.0,0.0, 1.0,0.0, 1.0,1.0, 0.0,1.0)
draw(4, GL_QUADS, ('v2f', pos), ('t2f', texcoords))
set_color(1, 1, 1, 0.999, dfactor=GL_ONE_MINUS_SRC_COLOR)
pos2 = ( pos[0],pos[1]-size[1], pos[0]+size[0],pos[1]-size[1], pos[0]+size[0],pos[1]+size[1]-size[1], pos[0],pos[1]+size[1]-size[1] )
texcoords2 = (0.0,1.0, 1.0,1.0, 1.0,0.0, 0.0,0.0)
color2 = (0,0,0,0.5, 0,0,0,0.5, 0.65,0.65,0.65,0.5, 0.65,0.65,0.65,0.5 )
draw(4, GL_QUADS, ('v2f', pos2), ('t2f', texcoords2), ('c4f', color2))

if __name__ == '__main__':
w = MTWindow(bgcolor=(0,0,0,1.0))
plane = MTScatterPlane(bgcolor=(0,0,0,1.0),do_rotation=False, do_scale=False, do_translation=['x'], size=(1440,300),pos=(0,w.height/2-150))
w.add_widget(plane)
layme = MTBoxLayout(padding=10, spacing=10, color=(0,0,0,1.0))
plane.add_widget(layme)
layme.add_widget(MTicon(filename = "browser.png",scale=0.5))
layme.add_widget(MTicon(filename = "calculator.png",scale=0.5))
layme.add_widget(MTicon(filename = "chat.png",scale=0.5))
layme.add_widget(MTicon(filename = "graph.png",scale=0.5))
layme.add_widget(MTicon(filename = "settings.png",scale=0.5))
layme.add_widget(MTicon(filename = "ipod.png",scale=0.5))
layme.add_widget(MTicon(filename = "maps.png",scale=0.5))
layme.add_widget(MTicon(filename = "notes.png",scale=0.5))
layme.add_widget(MTicon(filename = "phone.png",scale=0.5))
layme.add_widget(MTicon(filename = "weather.png",scale=0.5))
runTouchApp()
Powered by Google Project Hosting