Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_arrowkey_int_scroll.py
- from Tkinter import *
- def up(event):
- old = int(event.widget.get()) # this gives back the actual object!
- event.widget.delete(0, END) # delete existing text
- event.widget.insert(10, old + 1) # put new text in
- def down(event):
- old = int(event.widget.get()) # this gives back the actual object!
- event.widget.delete(0, END) # delete existing text
- event.widget.insert(10, old - 1) # put new text in
- root = Tk()
- A = Entry(root, width=4, font=("Helvetica", 16)) # Entry A
- A.insert(10, 64)
- A.grid(row=1, column=1)
- B = Entry(root, width=4, font=("Helvetica", 16)) # Entry B
- B.insert(10, 100)
- B.grid(row=1, column=2)
- C = Entry(root, width=4, font=("Helvetica", 16)) # Entry C
- C.insert(10, 6)
- C.grid(row=1, column=3)
- # bind both keys to corresponding event handlers
- root.bind('<Up>', up)
- root.bind('<Down>', down)
- mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement