def pressCallback(self):
print 'Press', self.sharedData
self.sharedData = [1,2,3] # this changes the memory address and breaks everything
# self.sharedData[0] = 1 # this doesn't change the memory address and everything still works TestDataModifier.sharedData = [1,2,3] TestDataModifier.sharedData[0] = 1Then I would add a kivy event that you raise after it is changed to alert all instances. They can then react and take action.
http://kivy.org/docs/api-kivy.event.html
Sorry, I would give you a code example, but I'm on my bicycle writing this on my phone, so can't right now. But post if you don't come right and I'll do that later..
Peace out
from kivy.app import App
from kivy.uix.label import Label
from kivy.lang import Builder
from kivy.clock import Clock
class BoundLabel(Label):
instances = [] # A list of all instances of the class
def __init__(self, **kwargs):
BoundLabel.instances.append(self)
super(BoundLabel, self).__init__(**kwargs)
@staticmethod
def set_shared_text(dt):
""" Loop through all instances and set to the shared data """
for instance in BoundLabel.instances:
instance.text = str(dt) # use str(dt) as shared for simplicity
class TestApp(App):
def build(self):
# Set the clock to alter the all the label captions to the delta time
Clock.schedule_interval(BoundLabel.set_shared_text, 1)
return Builder.load_string('''
BoxLayout:
orientation: "vertical"
BoundLabel:
BoundLabel:
BoundLabel:
''')
TestApp().run()