Advertisement
Guest User

Untitled

a guest
May 27th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. """An exercise in improving layout"""
  2. from tkinter import *
  3. from tkinter.ttk import *
  4.  
  5. def calculate():
  6. """Calculate twice the number and set that answer into result"""
  7. global entry, result_label
  8. result_label['text'] = 2 * int(entry.get())
  9.  
  10. def main():
  11. """Every home should have one"""
  12. global entry, result_label
  13. window = Tk()
  14. header = Label(window, text="Doubler", font=("Arial", 18))
  15. header.grid(row=0, column=0, columnspan=3, pady=10, padx=(20, 20))
  16. entry = Entry(window, width=5)
  17. entry.grid(row=1, column=0, padx=(20, 0))
  18. times_2 = Label(window, text=" * 2 = ")
  19. times_2.grid(row=1, column=1)
  20. result_label = Label(window, text='0')
  21. result_label.grid(row=1, column=2, padx=(0, 20))
  22. button = Button(window, text="Calculate", command=calculate)
  23. button.grid(row=2, column=0, columnspan=3, pady=10, padx=(20, 20))
  24. window.mainloop()
  25.  
  26. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement