Hello everyone! I am a newbie to Python. I'd like to create a program that runs using Tkinter, but my code doesn't work correctly, unluckily. Could you please tell me where the issue is?
from tkinter import *
def conv1(self):
gbp0=174000000
galleons0=34000872
sickles0=14
knuts0=7
galleons1=float(galleons0+sickles0/17+knuts0/29/17)
fracture=float(gbp0/galleons1)
convert1=Toplevel(root)
convert1.title("Pounds Sterling (GBP) to Galleons, Sickles and Knuts Converter")
label1_1=Label(convert1, text="Type the amount of money in GBP that you would like to convert to Galleons, Sickles and Knuts and press Enter.")
label1_1.pack()
label1_2=Label(convert1, text="1 Galleon = 5.12 GBP")
label1_2.pack()
label1_3=Label(convert1, text='GBP:')
label1_3.pack()
usergbpvar=DoubleVar()
usergbp=Entry(convert1, textvariable=usergbpvar)
usergbp.pack()
a=float(usergbpvar.get()/fracture)
galleons=int(a//1)
a=a%1
a=a*17
sickles=int(a//1)
a=a%1
a=a*29
if a%1==0.5:
knuts=int(round(a, 0))
knuts=knuts+1
else:
knuts=int(round(a, 0))
galleons=str(galleons)
sickles=str(sickles)
knuts=str(knuts)
label1_4=Label(convert1, text=galleons)
label1_4.pack()
label1_5=Label(convert1, text=sickles)
label1_5.pack()
label1_6=Label(convert1, text=knuts)
label1_6.pack()
convert1.mainloop()
root=Tk()
btn1=Button(root, text='GBP to Galleons, Sickles and Knuts', bg='#555', fg='#ccc', font='16')
btn1.pack()
btn1.bind('<Button-1>', conv1)
root.mainloop()The code is supposed to calculate the number entered by the user and to show the result consisting of three numbers. However, it shows 0.
