Advertisement
Guest User

Tkinter crashing no traceback

a guest
Jul 16th, 2021
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. from threading import Thread
  2. from time import sleep
  3. import tkinter as tk
  4.  
  5. def function(root):
  6.     # Make sure that the root is destroyed from the main thread
  7.     sleep(2)
  8.  
  9. root = tk.Tk()
  10.  
  11. # Start a new thread and pass in the `root`
  12. thread = Thread(target=function, args=(root, ), daemon=True)
  13. thread.start()
  14.  
  15. # Make sure we are inside the other function
  16. sleep(1)
  17.  
  18. root.destroy()
  19. # If for some reason we loose access to the root object
  20. # before the other thread...
  21. del root
  22.  
  23. # Make sure the function finished
  24. sleep(3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement