Ändern einer Kivy-Eigenschaft aus einem anderen Thread

Ich experimentiere mit einem Kivy-Code. Ich habe versucht, eine Kivy-Eigenschaft zu ändern (text_colour) von einem mit threading lib erstellten Profil. Programm funktioniert gut, aber der Thread ändert die Eigenschaft nicht.

Ich habe auch versucht, eine Methode in der Klasse zu erstellen, über die der Wert als Argument ausgegeben wird, was ebenfalls fehlgeschlagen ist.

from kivy.app import App

from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ListProperty


import threading
import random
import time


def zaaa():
    import time
    time.sleep(3)
    ScatterTextWidget.text_colour = [0, 0, 1, 1]
    print "function ran"   

t = threading.Thread(target= zaaa)
t.start()


class ScatterTextWidget(BoxLayout):

    text_colour = ListProperty([1, 0, 0, 1])

    def change_label_colour(self, *args):
        colour = [random.random() for i in xrange(3)] + [1]
        self.text_colour = colour

    def press(self, *args):
        self.text_colour = [1, 1, 1, 1]


class TataApp(App):
    def build(self):
        return ScatterTextWidget()


if __name__ == "__main__":
    TataApp().run()

AUSGABE:

[INFO              ] Kivy v1.8.0
[INFO              ] [Logger      ] Record log in /home/mbp/.kivy/logs/kivy_14-02-26_44.txt
[INFO              ] [Factory     ] 157 symbols loaded
[DEBUG             ] [Cache       ] register <kv.lang> with limit=None, timeout=Nones
[DEBUG             ] [Cache       ] register <kv.image> with limit=None, timeout=60s
[DEBUG             ] [Cache       ] register <kv.atlas> with limit=None, timeout=Nones
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_pygame, img_pil, img_gif 
[DEBUG             ] [Cache       ] register <kv.texture> with limit=1000, timeout=60s
[DEBUG             ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600s
[DEBUG             ] [App         ] Loading kv </home/mbp/workspace/KiviPlay/tata.kv>
[DEBUG             ] [Window      ] Ignored <egl_rpi> (import error)
[INFO              ] [Window      ] Provider: pygame(['window_egl_rpi'] ignored)
libpng warning: iCCP: known incorrect sRGB profile
[DEBUG             ] [Window      ] Display driver x11
[DEBUG             ] [Window      ] Actual window size: 800x600
[DEBUG             ] [Window      ] Actual color bits r8 g8 b8 a8
[DEBUG             ] [Window      ] Actual depth bits: 24
[DEBUG             ] [Window      ] Actual stencil bits: 8
[DEBUG             ] [Window      ] Actual multisampling samples: 2
[INFO              ] [GL          ] OpenGL version <4.3.12618 Compatibility Profile Context 13.251>
[INFO              ] [GL          ] OpenGL vendor <ATI Technologies Inc.>
[INFO              ] [GL          ] OpenGL renderer <AMD Radeon HD 7700 Series>
[INFO              ] [GL          ] OpenGL parsed version: 4, 3
[INFO              ] [GL          ] Shading version <4.30>
[INFO              ] [GL          ] Texture max size <16384>
[INFO              ] [GL          ] Texture max units <32>
[DEBUG             ] [Shader      ] Fragment compiled successfully
[DEBUG             ] [Shader      ] Vertex compiled successfully
[DEBUG             ] [ImagePygame ] Load </usr/lib/python2.7/site-packages/Kivy-1.8.0-py2.7-linux-x86_64.egg/kivy/data/glsl/default.png>
[INFO              ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO              ] [Text        ] Provider: pygame
[DEBUG             ] [Cache       ] register <kv.loader> with limit=500, timeout=60s
[INFO              ] [Loader      ] using a thread pool of 2 workers
[DEBUG             ] [Cache       ] register <textinput.label> with limit=None, timeout=60.0s
[DEBUG             ] [Cache       ] register <textinput.width> with limit=None, timeout=60.0s
[DEBUG             ] [Atlas       ] Load </usr/lib/python2.7/site-packages/Kivy-1.8.0-py2.7-linux-x86_64.egg/kivy/data/../data/images/defaulttheme.atlas>
[DEBUG             ] [Atlas       ] Need to load 1 images
[DEBUG             ] [Atlas       ] Load </usr/lib/python2.7/site-packages/Kivy-1.8.0-py2.7-linux-x86_64.egg/kivy/data/../data/images/defaulttheme-0.png>
[DEBUG             ] [ImagePygame ] Load </usr/lib/python2.7/site-packages/Kivy-1.8.0-py2.7-linux-x86_64.egg/kivy/data/../data/images/defaulttheme-0.png>
[INFO              ] [GL          ] NPOT texture support is available
[INFO              ] [OSC         ] using <multiprocessing> for socket
[DEBUG             ] [Base        ] Create provider from mouse
[DEBUG             ] [Base        ] Create provider from probesysfs
[DEBUG             ] [ProbeSysfs  ] using probsysfs!
[INFO              ] [Base        ] Start application main loop
<kivy.properties.ListProperty object at 0x124f870>
function ran
[INFO              ] [Base        ] Leaving application in progress...

Antworten auf die Frage(2)

Ihre Antwort auf die Frage