Tkinter GUI で指数関数を定義しようとして問題が発生しています。私の GUI は、異なる数字を選択できる 3 つのコンボ ボックスで構成されています。すべての数値を選択すると、指数関数に基づく結果が表示されます。私が意味することは次のとおりです。
- NumberA #Combobox 1 を選択
- NumberB #Combobox 2 を選択
NumberC #Combobox 3 を選択
Result = exp[(-NumberA/NumberB)* NumberC]
私がこれまでに持っているものは次のとおりですが、うまくいきません:
#Main Selection
def exponential(*args):
try:
product.set('%g' %math.exp((float(Num_A.get())/float(Num_B.get())*float(Num_C.get()),2)))
except ValueError:
pass
## variables
NumA = StringVar()
NumB = StringVar()
NumC = StringVar()
product= DoubleVar()
#Combo boxes,
#NumA NumB and NumC are similar
ttk.Label(stepTen, text="Select A):").grid(column =3, row = 0)
NumA_Select = Combobox(stepTen, values=("0.1", "0.2", "0.3","0.4",),textvariable=Num_OneT)
NumA_Select.grid(column=4, row=0, columnspan="5", sticky="nswe")
NumA.trace("w",exponential)
## display results
ttk.Label(stepTen, text = "Exponential Dist result:").grid(column = 3, row = 12)
ttk.Label(stepTen, textvariable=product).grid(column = 4, row = 12)
#End Code
root.mainloop()
事前にどうもありがとうございました!