我想调用一个函数,在选择其中一种材料后,它会获得电抗性的值,然后在计算中使用它
def selected():
if tow1.get() == "Cu":
Er=0.8
print(Er)
elif tow1.get() == CuSn:
Er=..
elif tow1.get() == .:
Er=...
else:
Er=..
data1 = ("Cu", "CuSn", "CuMg", "Al")
tow1 = Combobox(frame31, values=data1)
tow1.current(0)
tow1.pack()
答案 0 :(得分:0)
您可以绑定到<<ComboboxSelected>>
事件。绑定函数将收到一个代表事件的对象,因此您需要对selected
函数进行一些修改:
def selected(event):
value = event.widget.get()
print("value: '{}'".format(value))
...
tow1.bind("<<ComboboxSelected>>", selected)