Reputation: 23
I'm making a calculator program with Python. I want to output the sum of the numbers input using tkinter.
enter code here
def plus():
e1.delete(0, END)
e2.delete(0, END)
e3.delete(0, END)
x = int(e1.get()) #Inputed value.
y = int(e2.get()) #Inputed value.
return e3.insert(0, x+y)
e1 = Entry(window)
e2 = Entry(window)
e3 = Entry(window)
Upvotes: 0
Views: 275
Reputation: 177
Why did you do this before you get()
?
e1.delete(0, END)
e2.delete(0, END)
They go before e1.get()
and e2.get()
, so when you run e1.get()
, it will return ""
. Then you should swap their order like this:
def plus():
e3.delete(0, END)
x = int(e1.get())
y = int(e2.get())
e1.delete(0, END)
e2.delete(0, END)
return e3.insert(0, x+y)
e1 = Entry(window)
e2 = Entry(window)
e3 = Entry(window)
This is my answer, thanks.
Upvotes: 1