我用 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()
uj5u.com熱心網友回復:
您的問題是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
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/510580.html
