Advertisement
here2share

# Tk_arrowkey_int_scroll.py

Jul 31st, 2016
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. # Tk_arrowkey_int_scroll.py
  2.  
  3. from Tkinter import *
  4.  
  5. def up(event):
  6.     old = int(event.widget.get()) # this gives back the actual object!
  7.     event.widget.delete(0, END) # delete existing text
  8.     event.widget.insert(10, old + 1) # put new text in
  9.  
  10. def down(event):
  11.     old = int(event.widget.get()) # this gives back the actual object!
  12.     event.widget.delete(0, END) # delete existing text
  13.     event.widget.insert(10, old - 1) # put new text in
  14.  
  15. root = Tk()
  16.  
  17. A = Entry(root, width=4, font=("Helvetica", 16)) #  Entry A
  18. A.insert(10, 64)
  19. A.grid(row=1, column=1)
  20.  
  21. B = Entry(root, width=4, font=("Helvetica", 16)) #  Entry B
  22. B.insert(10, 100)
  23. B.grid(row=1, column=2)
  24.  
  25. C = Entry(root, width=4, font=("Helvetica", 16)) #  Entry C
  26. C.insert(10, 6)
  27. C.grid(row=1, column=3)
  28.  
  29. # bind both keys to corresponding event handlers
  30. root.bind('<Up>', up)
  31. root.bind('<Down>', down)
  32. mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement