SHARE
TWEET

Escape closes Window

steve-shambles-2109 Jan 15th, 2020 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """Escape closes Window
  2.  
  3.   stevepython.wordpress.com
  4.   code-snippet-vol_42-snip_209
  5.  
  6. source: Unknown
  7. """
  8.  
  9. from tkinter import Tk
  10.  
  11. def esc_win(event):
  12.     """Destroy root window when escape key pressed."""
  13.     root.destroy()
  14.  
  15. root = Tk()
  16. root.title('Press ESC')
  17.  
  18. root.bind('<Escape>', esc_win)
  19. root.focus()
  20.  
  21. root.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top