I created a GUI in TKINTER PYTHON that takes 2 numbers from a user and adds them
from tkinter import *
root = Tk()
root.geometry("400x230")
root.title("Add Two Numbers")
def clear():
screen.delete(0, END)
myint1_val.delete(0, END)
myint2_val.delete(0, END)
def clicked():
screen.delete(0, END)
a = int(myint1_val.get()) + int(myint2_val.get())
screen.insert(0, a)
Label(root, text="Add Your TWO numbers", font="verdana 23 underline").pack()
Label(root, text="Enter your 1st number:", font="verdana 13 bold").pack()
myint1 = StringVar
myint1_val = Entry(root, textvariable=myint1)
myint1_val.pack()
Label(root, text="Enter your 2nd number:", font="verdana 13 bold").pack()
myint2 = StringVar
myint2_val = Entry(root, textvariable=myint2)
myint2_val.pack()
Label(root, text="The sum of your numbers is:", font="verdana 13 bold").pack()
myint3 = StringVar
screen = Entry(root, textvariable=myint3)
screen.pack()
b = Button(root, text="Calculate", command=clicked).pack(side=LEFT)
b = Button(root, text="Clear", command=clear).pack(side=LEFT, pady=9, padx=135)
root.mainloop()
Comments
Post a Comment
Write something to CodeWithAbdur!