Advertisement
Felanpro

tkinter calc

Sep 19th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. from tkinter import *
  2.  
  3. w = Tk()
  4. w.title("Operator")
  5.  
  6. e1 = Entry(w, bd = 3, font = "helvetica")
  7. e2 = Entry(w, bd = 3, font = "helvetica")
  8. operator_e = Entry(w, bd = 3, font = "helvetica")
  9.  
  10. e1.grid(row = 0, column = 0)
  11. e2.grid(row = 0, column = 2)
  12. operator_e.grid(row = 0, column = 1)
  13.  
  14. def callback():
  15.     if operator_e.get() == "+":
  16.         answer_label1 = Label(w, text = int(e1.get()) + int(e2.get()))
  17.         answer_label1.grid(row = 3, column = 1)
  18.     elif operator_e.get() == "-":
  19.         answer_label2 = Label(w, text = int(e1.get()) - int(e2.get()))
  20.         answer_label2.grid(row = 3, column = 1)
  21.     elif operator_e.get() == "*":
  22.         answer_label3 = Label(text = int(e1.get()) * int(e2.get()))
  23.         answer_label3.grid(row = 3, column = 1)
  24.     else:
  25.         pass
  26.  
  27. b_exec = Button(w, text = "click", command = callback, bd = 5, font = "helvetica")
  28. b_exec.grid(row = 2, column = 1)
  29.  
  30. w.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement