【发布时间】:2015-03-23 21:02:07
【问题描述】:
class Controls(BoxLayout):
delta_value=NumericProperty()
max_value=NumericProperty()
solar_value=NumericProperty()
hysteresis=NumericProperty()
busy_image=StringProperty('125.png')
temp_solar=NumericProperty()
temp_pool=NumericProperty()
def __init__(self, **kwargs):
super(Controls, self).__init__(**kwargs)
Clock.schedule_interval(self.set_value, 1)
def PID_an_aus(self, instance, value):
if value is True:
pass
else:
pass
def set_value(self, *args):
# I want to pass temp_solar and temp_pool from PoolApp from read_temperature function
print "Temperature",self.temp_solar, self.temp_pool
print "Delta",self.delta_value
print "Max", self.max_value
print self.hysteresis
class PoolApp(App):
temperature=ListProperty()
temp_sensor = DS18B20()
temp_solar=NumericProperty(0.0)
temp_pool=NumericProperty(0.0)
def build(self):
self.temp_sensor.start()
Clock.schedule_interval(self.read_temperature, 0)
def read_temperature(self, temperature):
if not self.temp_sensor.temp_queue.empty():
self.temperature = self.temp_sensor.temp_queue.get()
self.temp_solar=self.temperature[0]
self.temp_pool=self.temperature[1]
#how to pass these values to Controls class
def on_stop(self):
self.temp_sensor.running = False
sys.exit()
if __name__ == '__main__':
PoolApp().run()
【问题讨论】:
-
我知道你们中的大多数人会忽略它并且不会回答。我尝试了不同的绑定方法,但最终值总是为零。我一定犯了同样的愚蠢错误,看不到,请帮忙