python calculator program gui code example
Example: python calculator gui
from tkinter import *
def adding():
try:
text1 = int(Textbox1.get())
text2 = int(Textbox2.get())
except Exception:
Output.delete(0, END)
Output.insert(0, 'Error! Enter a number please!')
return
text_output = str(text1 + text2)
Output.delete(0, END)
Output.insert(0, text_output)
root = Tk()
root.title('Adding')
root.geometry('500x500')
Textbox1 = Entry(root)
Textbox1.pack(ipadx=50, ipady=10)
spacing = Label(root, text='+')
spacing.pack()
Textbox2 = Entry(root)
Textbox2.pack(ipadx=50, ipady=10)
spacing2 = Label(root)
spacing2.pack()
Button1 = Button(root, text='Add The numbers!', command=adding)
Button1.pack()
spacing3 = Label(root)
spacing3.pack()
Output = Entry(root)
Output.pack(ipadx=50)
root.mainloop()