[英]python calculator error using tkinter coolprop
我用 tkinter 做了一个计算器
但它不起作用
我认为 CoolProp 库是个问题,但我不知道该怎么办
我现在能做什么 我该如何解决?
import tkinter
from CoolProp.HumidAirProp import HAPropsSI
def click_btn():
txt1 = input(entry1.get())
txt2 = input(entry2.get())
txt3 = HAPropsSI('H','T',txt1 + 273.15,'P',101325,'R',txt2)
button["text"] = txt3
win = tkinter.Tk()
win.title("엔트리(텍스트 입력 필드) 사용하기")
win.geometry("400x400")
# 첫번째 입력
entry1 = tkinter.Entry(width=30)
entry1.place(x=20, y=20)
# 두번째 입력
entry2 = tkinter.Entry(width=30)
entry2.place(x=20, y=40)
button = tkinter.Button(text="Calculate enthalphy", command=click_btn)
button.place(x=20, y=70)
win.mainloop()
您的问题是input
等待终端中的用户输入,您应该使用float
将文本框中的文本转换为库的数字。
def click_btn():
txt1 = float(entry1.get())
txt2 = float(entry2.get())
txt3 = HAPropsSI('H','T',txt1 + 273.15,'P',101325,'R',txt2)
button["text"] = txt3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.