Here it is using multiprocessing if it helps. https://pymotw.com/3/multiprocessing/index.html
import sys if 3 == sys.version_info[0]: ## 3.X is default if dual system import tkinter as tk ## Python 3.x else: import Tkinter as tk ## Python 2.x import time from multiprocessing import Process class TestClass(): def test_f(self, spaces=1): ctr = spaces while True: ctr += 1 print(" "*spaces, ctr) time.sleep(1.0) def tk_quit(self): root=tk.Tk() tk.Button(root, text="Quit", command=root.quit, width=10).grid() root.mainloop() if __name__ == '__main__': ## run functions in the background CT=TestClass() p = Process(target=CT.test_f) p.start() ## run same function in another process to ## simulate 2 different processes p2 = Process(target=CT.test_f, args=(10,)) p2.start() CT.tk_quit() print("terminate process") if p.is_alive(): p.terminate() p.join() if p2.is_alive(): p2.terminate() p2.join()