Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- root = Tk()
- root.title("Calculator")
- root.geometry("220x550")
- def plus_button_function():
- global plus_first
- plus_first = int(e.get())
- e.delete(0, END)
- def equal_button_function():
- global plus_second
- plus_second = int(e.get())
- plus_sum = plus_first + plus_second
- e.insert(0, plus_sum)
- def b1_function():
- e.insert(0, "1")
- def b2_function():
- e.insert(0, "2")
- def b3_function():
- e.insert(0, "3")
- def b4_function():
- e.insert(0, "4")
- def b5_function():
- e.insert(0, "5")
- def b6_function():
- e.insert(0, "6")
- def b7_function():
- e.insert(0, "7")
- def b8_function():
- e.insert(0, "8")
- def b9_function():
- e.insert(0, "9")
- e = Entry(root)
- equal_button = Button(root, text = "=", command = equal_button_function)
- b1 = Button(root, text = "1", command = b1_function)
- b2 = Button(root, text = "2", command = b2_function)
- b3 = Button(root, text = "3", command = b3_function)
- b4 = Button(root, text = "4", command = b4_function)
- b5 = Button(root, text = "5", command = b5_function)
- b6 = Button(root, text = "6", command = b6_function)
- b7 = Button(root, text = "7", command = b7_function)
- b8 = Button(root, text = "8", command = b8_function)
- b9 = Button(root, text = "9", command = b9_function)
- plus_button = Button(root, text = "+", command = plus_button_function)
- e.grid(row = 0, column = 0)
- equal_button.grid(row = 0, column = 1)
- b1.grid(row = 1, column = 1)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement