An answer to this question might be either about tkinter or parallel loops. I am not sure which solution will be the best. I need your advice.
I have a while True loop, which goes infinitely. Each loop takes around 5 seconds or more, and I wanted to create a GUI button (skip and stop_skip buttons). If the skip button is clicked by a user, it will skip the current while loop and move on to the next while loop until 'stop_skip' button is clicked. So, the skip button will be working as 'continue' in a loop.
Since each loop takes around 5 seconds, I want it to check the variable frequently in the loop. I found that tk.after() may work in every x milliseconds, and some people mentioned tk.update_idletasks() and tk.update(). I tried them, but they just show the box when the loop begins and freeze for the rest 5 seconds. If nothing can work like this (performing a function repetitively with intervals in a while loop), I will probably put if conditions multiple times during the while loop.
The script I want may look like..
show_tk_gui()
while True:
check_tk_if_skip_button_clicked(interval==1000) #if clicked, continue to the next while loop until 'stop_skip' button is clicked.
performing_5_sec_calculation()
Is there any way that can make this possible? Not using GUI option is also acceptable.