这是一个带有GUI的温度转换器。我在GUI方面有问题。在我添加GUI之前,我的代码运行正确,现在说它已经全部签出了,但是当我实际运行程序时什么也不会发生。我不知道是不是因为我需要把Tkinter文件放在同一个文件夹里?我以前从文件中获取文本时遇到过这个问题,或者我的GUI完全编程错误!谢谢!你知道吗
#import
#main function
from Tkinter import *
def main():
root=Tk()
root.title("Temperature Converter")
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=0 dont need these in python
# far=0
cel=int(somestring)
far=(9/5*(cel))+32
print(F)
添加main()并将F改为far。我还添加了一个例子,使标签状态转换是什么!:)希望这有帮助。你知道吗
相关问题 更多 >
编程相关推荐