for example in this
Code: Select all
def heater():
global heater_on, heat_on
if heater_on <= current_temp - 1 and heat_on == 0:
block8.config(text='Heater On', bg='green')
heat_on = 1
if heater_on >= current_temp and heat_on == 1:
block8.config(text='Heater Off', bg='red')
heat_on = 0
root.after(1000, heater)would it be better to use a while?
Code: Select all
def heater():
global heater_on, heat_on
while True:
if heater_on <= current_temp - 1 and heat_on == 0:
block8.config(text='Heater On', bg='green')
heat_on = 1
if heater_on >= current_temp and heat_on == 1:
block8.config(text='Heater Off', bg='red')
heat_on = 0
time.sleep(10)would both examples need to be run from threads to prevent pausing within root tasks?