i just started learning how to code python last month and i've been trying to run this code which basically accepts some parameters calculates them and prints them out,but for some reason i cant get the result.Please any help would be appreciated
res1=int()
def converting():
print(num1.get())
print(form1.get())
print(form2.get())
mytext.set(res1)
if form1 == 'meter' and form2=='kilometer':
res1= print(num1*1000)
elif form1 == 'kilometer' and form2 == 'meter':
res1=print(num1/1000)
elif form1 == 'gram' and form2 == 'kilogram':
res1=print(num1*1000)
elif form1 == 'kilogram' and form2 == 'gram' :
res1=print(num1/1000)
elif form1 == 'celsius' and form2 == 'fahrenheit':
res1=print((num1*9/5)+32)
elif form1 == 'fahrenheit' and form2 == 'celsius':
res1=print((num1-32)*5/9)
else:
print('Invalid parameters')
ws = Tk()
ws.title("Python Guides")
ws.geometry("500x300")
mytext=StringVar()
Label(ws, text="Number").grid(row=0, sticky=W)
Label(ws, text="Initial Form").grid(row=1, sticky=W)
Label(ws, text="Conversion Form").grid(row=2, sticky=W)
Label(ws, text="Result").grid(row=3, sticky=W)
result=Label(ws, text=res1, textvariable=mytext).grid(row=3,column=1, sticky=W)
num1 = Entry(ws)
form1 = Entry(ws)
form2 = Entry(ws)
num1.grid(row=0, column=1)
form1.grid(row=1, column=1)
form2.grid(row=2, column=1)
button = Button(ws, text="Calculate", command=converting)
button.grid(row=0, column=2,columnspan=2, rowspan=2,sticky=W+E+N+S, padx=5, pady=5)
ws.mainloop()
i've checked the code and it runs fine but it doesnt give me the answer in the tkinter window instead it prints the values i've entered back on the terminal