python stop infinite thread loop
# specific problem and answer
import threading
import tkinter
def Loop(run):
while run():
# infinite loop
run = True
main = tkinter.Tk()
threading.Thread(target=Loop, args=(lambda:run,)).start()
main.mainloop()
run = False # thread will be stopped after Tkinter GUI closed
# or use other trigger
# alternatively, you might want to read about daemon instead