Fixed texture example bug with finding texture

This commit is contained in:
Alexander Taylor 2014-07-30 22:23:36 +01:00
parent 1aac389b53
commit 8fc1c193ed
1 changed files with 9 additions and 7 deletions

View File

@ -18,18 +18,18 @@ class TextureAccessibleWidget(Widget):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(TextureAccessibleWidget, self).__init__(**kwargs) super(TextureAccessibleWidget, self).__init__(**kwargs)
print 'children', self.canvas.children Clock.schedule_once(self.texture_init, 0)
# self.texture = self.canvas.children[-1].texture
# self.texture.wrap = 'repeat'
def update(self, dt): def texture_init(self, *args):
tcs = self.tex_coords self.texture = self.canvas.children[-1].texture
for i in range(0, 8, 2):
self.tex_coords[i] += dt/3. def on_texture_wrap(self, instance, value):
self.texture.wrap = value
root = Builder.load_string(''' root = Builder.load_string('''
<TextureAccessibleWidget>: <TextureAccessibleWidget>:
on_touch_down: print self.canvas.children
canvas: canvas:
Rectangle: Rectangle:
pos: self.pos pos: self.pos
@ -90,10 +90,12 @@ BoxLayout:
text: 'size' text: 'size'
text_size: self.size text_size: self.size
halign: 'right' halign: 'right'
valign: 'middle'
Label: Label:
text: 'tex_coords' text: 'tex_coords'
text_size: self.size text_size: self.size
halign: 'left' halign: 'left'
valign: 'middle'
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
SliderWithValue: SliderWithValue: