# 20210905 # R. Dawes from tkinter import * window = Tk() window.title("Simple Calculator") window.geometry("450x300") # get the next number get_num1_label = Label(window,text="Enter an integer") num1 = Entry(window, width = 10) # show the current total show_total_label = Label(window,text="Total") # place these things on the window get_num1_label.grid(column = 0,row = 0) num1.grid(column = 1, row = 0) show_total_label.grid(column = 0, row = 3) total = 0 def add_clicked(): global total x = num1.get() total = total + int(x) show_total_label.configure(text = str(total)) num1.delete(0,'end') def subtract_clicked(): global total x = num1.get() total = total - int(x) show_total_label.configure(text = str(total)) num1.delete(0,'end') def multiply_clicked(): global total x = num1.get() total = total * int(x) show_total_label.configure(text = str(total)) num1.delete(0,'end') def divide_clicked(): global total x = num1.get() total = total / float(x) show_total_label.configure(text = str(total)) num1.delete(0,'end') add_button = Button(window, text = "+", command = add_clicked) subtract_button = Button(window, text = "-", command = subtract_clicked) multiply_button = Button(window, text = "*", command = multiply_clicked) divide_button = Button(window, text = "/", command = divide_clicked) add_button.grid(column = 4, row = 1) subtract_button.grid(column = 4, row = 2) multiply_button.grid(column = 4, row = 3) divide_button.grid(column = 4, row = 4) # start the process window.mainloop()