cleanup examples

This commit is contained in:
Mathieu Virbel 2011-01-31 22:37:48 +01:00
parent 15274b2578
commit 85abba014c
17 changed files with 3 additions and 218 deletions

View File

@ -1,100 +0,0 @@
from kivy.app import App
from kivy.clock import Clock
from kivy.uxl import UxlBuilder
from threading import Thread
from collections import deque
from subprocess import Popen, PIPE
content = '''
Widget:
canvas:
Color:
rgb: (1, 0, 1)
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
Rectangle:
pos: self.pos
'''
class AcceleratorApp(App):
def build(self):
root = UxlBuilder(content=content).root
self.queue = deque()
self.thread = Thread(target=self.read_accelerometer, args=(self.queue, ))
self.thread.daemon = True
self.thread.start()
Clock.schedule_interval(self.pop_deque, 0)
return root
def pop_deque(self, *largs):
print '=========+++++FPS+++++=============', Clock.get_fps()
try:
while True:
axis, value = self.queue.pop()
if axis == 'X':
self.root.x = value
if axis == 'Y':
self.root.y = value
except IndexError:
return
def read_accelerometer(self, q):
process = Popen('sudo evtest /dev/input/event7', shell=True,
stdout=PIPE)
while True:
line = process.stdout.readline()
line = line.split(' ')
if len(line) != 11:
continue
if line[0] != 'Event:':
continue
axis = line[8]
value = int(line[10].strip('\n'))
q.appendleft((axis[1], value))
AcceleratorApp().run()

View File

@ -11,7 +11,7 @@ class TestApp(App):
animation.start(instance)
def build(self):
button = Button(size_hint=(None, None), label='plop')
button = Button(size_hint=(None, None), text='plop')
button.bind(on_press=self.animate)
return button

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -11,7 +11,7 @@ Widget:
size: self.texture_size
Image:
source: '../kivy.jpg'
source: 'kivy.jpg'
canvas:
PushMatrix:
Rotate:

View File

@ -3,4 +3,4 @@ Widget:
size: image.texture_size
Image:
id: image
source: '../kivy.jpg'
source: 'kivy.jpg'

View File

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -1,43 +0,0 @@
from kivy.app import App
from kivy.clock import Clock
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.video import Video
from kivy.core.image import Image
from kivy.graphics import *
from kivy.core.text import Label as CoreLabel
from random import random
root = None
tex = Image('examples/test-rect.png').texture
label = CoreLabel(text="oo", font_size=32)
class TestApp(App):
def build(self):
global root
label.refresh()
print "XXXXXXXX", label.texture, tex.size
w = Widget()
with w.canvas:
Color(.5,.5,.5,.5)
Rectangle(size=(500,500))
Color(1,1,1,1)
Rectangle(texture=label.texture)
#Rectangle(pos=(300,300), texture=tex)
root = w
return w
def update_texture(*args):
label.refresh()
with root.canvas:
Color(0,1,0,1)
Rectangle(texture=label.texture)
Clock.schedule_interval(update_texture, 2)
TestApp().run()

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="200"
height="200"
id="svg2">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<path
d="M 100,200 C 100,200 0,100 25,50 50,0 150,0 150,50 150,100 100,100 100,100 z"
id="path2985"
style="fill:none;stroke:#000000;stroke-width:1.32014501px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1013 B

View File

@ -1,2 +0,0 @@
SVG:
source: 'examples/svg/drawing.svg'

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="744.09448"
height="1052.3622"
id="svg2">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<path
d="M 314.28572,832.36218 311.42857,1040.9336 22.857147,1038.0765 C 22.857147,1038.0765 22.857141,829.50504 314.28572,832.36218 z"
id="path3778"
style="fill:#ff0000;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB