编写一个GUI程序,将摄氏温度转换为华氏温度。用户应该能够输入摄氏温度,点击一个按钮,然后看到等效的华氏温度。使用以下公式进行转换:
F=(9/5)C+32
F是华氏温度,C是摄氏温度。在
以下是我所拥有的,但当我运行它时,什么都不会发生:#import
#main function
from tkinter import *
def main():
root=Tk()
root.title("Some GUI")
root.geometry("400x700")
#someothersting=""
someotherstring=""
#enter Celcius
L1=Label(root,text="Enter a Celcius temperature.")
E1=Entry(root,textvariable=someotherstring)
somebutton=Button(root, text="Total", command=lambda: convert(E1.get()))
somebutton.pack()
E1.pack()
L1.pack()
root.mainloop()#main loop
#convert Celcius to Fahrenheit
def convert(somestring):
if somestring != "":
cel=int(somestring)
far=(9/5*(cel))+32
print(far)

1632

被折叠的 条评论
为什么被折叠?



