Advertisement
here2share

# pythonic_command.py

Oct 5th, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. # pythonic_command.py
  2.  
  3. from Tkinter import *
  4. root = Tk()
  5.  
  6. def cash(price=0):
  7.     def wrap():
  8.         total.set(int(total.get()) + price)
  9.     return wrap
  10.  
  11. Button(root, text = "ones",width = 20, command = cash(1)).pack()
  12. Button(root, text = "tens",width = 20, command = cash(10)).pack()
  13. Button(root, text = "hundreds",width = 20, command = cash(100)).pack()
  14. Button(root, text = "thousands",width = 20, command = cash(1000)).pack()
  15.  
  16. total = StringVar()
  17. total.set(0)
  18. Label(root, text = '$').pack(side=LEFT)
  19. Label(root, textvariable = total).pack(side=LEFT)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement