import tkinter as tk import threading import time import tkinter #create/run_gui() root=tk.Tk() root.mainloop() #give to another thread and delete the reference def mayfly_func(obj):time.sleep(1) mayfly=threading.Thread(target=mayfly_func,args=(root,)) mayfly.start() del root time.sleep(10**9) #root will be garbage collected when the mayfly thread dies #this occurs in the mayfly thread context and triggers a panic ############################################################################### # #second error case, this time triggered with the _tkinter c library. # # import _tkinter # import threading # # class GUI(): # def build_and_run_gui(self, # screenName=None, baseName='', className='Tk',useTk=1, sync=0, use=None): # wantobjects = 1 # interactive = 0 # self._tk=_tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) # self._tk.mainloop() # # #create/run_gui() # g=GUI() # gui_thread=threading.Thread(target=g.build_and_run_gui) # gui_thread.start()