Advertisement
here2share

# Tk_hide_window.py

Oct 20th, 2016
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. # Tk_hide_window.py
  2.  
  3. import Tkinter as tk
  4.  
  5. def keycodess(event):
  6.     if event.keysym == 'Escape':
  7.         root.destroy()
  8.     x = event.char
  9.     if x == "1":
  10.         print "Option 'ONE' has been selected"
  11.     elif x == "2":
  12.         print "Option 'TWO' has been selected"
  13.     elif x == "3":
  14.         print "Option 'THREE' has been selected"
  15.     elif x == "4":
  16.         print "Option 'FOUR' has been selected"
  17.     else:
  18.         print x
  19.  
  20. root = tk.Tk()
  21. print "1. Menu choice 'ONE'"
  22. print "2. Menu choice 'TWO'"
  23. print "3. Menu choice 'THREE'"
  24. print "4. Menu choice 'FOUR'"
  25. root.bind_all('<KeyRelease>', keycodess)
  26. # hiding the tk window
  27. root.withdraw()
  28. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement