0

I am a Python noob, and I'm trying to make a washing device, programming the interface with Python. For now, the machine should work like that:

  1. Wash
  2. Tell washing is complete
  3. Dry
  4. Tell drying is complete

For this, after times for washing/drying are entered, a button is pressed:

button1 = Button(window.tk, command = lambda:main_process(int(varWashtime.get()), int(varDrytime.get())))

def main_process(wash_seconds,dry_seconds):
        wash(wash_seconds)
        stop_wash()
        dry(dry_seconds)
        stop_dry()
        return

def wash(seconds):
    varWashStarted.set("Washing Started") 
    Timer(seconds,idle_fnc).start() 
    return

def stop_wash():
    varWashStarted.set("Washing Stopped")
    Timer(3,idle_fnc,()).start()
    return

def dry(seconds):
    varDryStarted.set("Drying Started")
    Timer(seconds,idle_fnc,()).start()
    return

def stop_dry():
    varDryStarted.set("Drying Stopped")
    return

def idle_fnc():
    pass
    return

Here, I used the function idle_fnc to make threading.Timer properly work.

I found out that I can just use Timer to call other functions after each other, but I would prefer to return from a function, then branch to a new one.

My problem is, as I click the button, the whole thing executes without waiting; I instantly see "Washing Stopped" and "Drying Stopped" on the corresponding label, without the delays triggered.

What is the problem?

S. de Melo
  • 786
  • 4
  • 11
C K
  • 344
  • 2
  • 13

0 Answers0