I'd like to know how to run Python tkinter sequentially.

Asked 2 years ago, Updated 2 years ago, 77 views

I want to run the after function sequentially. For example,

root.after(10, A)
root.after(10, B)

If this is the case,

After 10 ms, A runs If A runs, I want B to run after 10 ms I don't think it comes out even if I search it.

python3 python tkinter

2022-09-21 22:08

1 Answers

I think we can use the timer function of threading. I think the following schematic will be possible simply. When calling another function as a callback in the threading.timer, it would be good to note that the function input value should be included as follows.

import threading

def b_function():
    print("This is B")

def a_function(time):
    print("This is A")
    threading.Timer(time, b_function).start()

def genesis_function(time):
    threading.Timer(time, a_function, [time]).start()

genesis_function(10)

#10 seconds later 
This is A.
#10 seconds later
This is B.


2022-09-21 22:08

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.