root.after or while true ?
Posted: Fri Jan 22, 2016 2:56 pm
is it better to use root.after or while true?
for example in this
ive used root. after(1000, heater) but would this not call heater from within its own def and create multiple instances?
would it be better to use a while?
is it better to use a sleep with the while, so it isn't running as quickly as it can but rather on a sleep time?
would both examples need to be run from threads to prevent pausing within root tasks?
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?