from tkinter import *
import decimal
twoD = int(0.80)
threeD = int(1.50)
gui = int(2.00)
root = Tk()
e = Entry(root, width=8)
e.pack()
e.get()
a = Entry(root, width=8)
a.pack()
a.get()
b = Entry(root, width=8)
b.pack()
b.get()
twoD_num = e.get()
threeD_num = a.get()
gui_num = b.get()
twoD_amount = twoD * twoD_num
threeD_amount = threeD * threeD_num
gui_amount = gui * gui_num
output = twoD_amount + threeD_amount + gui_amount
def myClick():
myLabel = Label(root, text = output)
myLabel.pack()
print(output)
myButton = Button(root, text = "Calculate", command = myClick)
myButton.pack()
root.mainloop()```
when i output the numbers there is no value, i am trying to set it up as a money calculator type thing where the twoD = 0.8 as the price and then you times by the amount of products and add all of the products together the issue is that the output is blank
#๐ adding/multiplying decimal
10 messages ยท Page 1 of 1 (latest)
@gleaming wing
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
I think the problem is that you call a.get before you've typed anything into the entry
try this instead -- I can't tell if the output is right, but at least it displays something ```py
from tkinter import Button, Entry, Label, Tk
twoD = int(0.80)
threeD = int(1.50)
gui = int(2.00)
root = Tk()
e = Entry(root, width=8)
e.pack()
a = Entry(root, width=8)
a.pack()
b = Entry(root, width=8)
b.pack()
def myClick():
twoD_num = e.get()
threeD_num = a.get()
gui_num = b.get()
twoD_amount = twoD * twoD_num
threeD_amount = threeD * threeD_num
gui_amount = gui * gui_num
output = twoD_amount + threeD_amount + gui_amount
myLabel = Label(root, text=output)
myLabel.pack()
print(output)
myButton = Button(root, text="Calculate", command=myClick)
myButton.pack()
root.mainloop()
gotta say, your variable names are so bad that they are probably half your problem
yeah ik
When I was in junior high school, struggling with my math homework, my Dad helped me by telling me to write neatly and big. I thought that was so stupid; I was having trouble with the quadratic equation, not my handwriting!!
He was right.
And what about:
twoD = int(0.80)
threeD = int(1.50)
gui = int(2.00)
That's the same as:
twoD = 0
threeD = 1
gui = 2
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.