Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- w = Tk()
- w.title("Operator")
- e1 = Entry(w, bd = 3, font = "helvetica")
- e2 = Entry(w, bd = 3, font = "helvetica")
- operator_e = Entry(w, bd = 3, font = "helvetica")
- e1.grid(row = 0, column = 0)
- e2.grid(row = 0, column = 2)
- operator_e.grid(row = 0, column = 1)
- def callback():
- if operator_e.get() == "+":
- answer_label1 = Label(w, text = int(e1.get()) + int(e2.get()))
- answer_label1.grid(row = 3, column = 1)
- elif operator_e.get() == "-":
- answer_label2 = Label(w, text = int(e1.get()) - int(e2.get()))
- answer_label2.grid(row = 3, column = 1)
- elif operator_e.get() == "*":
- answer_label3 = Label(text = int(e1.get()) * int(e2.get()))
- answer_label3.grid(row = 3, column = 1)
- else:
- pass
- b_exec = Button(w, text = "click", command = callback, bd = 5, font = "helvetica")
- b_exec.grid(row = 2, column = 1)
- w.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement