Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from threading import Thread
- from time import sleep
- import tkinter as tk
- def function(root):
- # Make sure that the root is destroyed from the main thread
- sleep(2)
- root = tk.Tk()
- # Start a new thread and pass in the `root`
- thread = Thread(target=function, args=(root, ), daemon=True)
- thread.start()
- # Make sure we are inside the other function
- sleep(1)
- root.destroy()
- # If for some reason we loose access to the root object
- # before the other thread...
- del root
- # Make sure the function finished
- sleep(3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement