Tkinter列表框到组合框

时间:2017-05-19 05:49:19

标签: python tkinter

实际上,我有两个问题。第一个问题是,如何用组合框替换列表框?第二个问题,我希望用户看到dic键但是使用该值的函数,我该怎么做?

onUnchecked

1 个答案:

答案 0 :(得分:0)

请阅读:Combobox documentation

在您的情况下,您可以将l1定义为:

# Read-only combobx with choice values (50, 80)
l1 = ttk.Combobox(aken, values=[50, 80], state='readonly')
# Select the first item of the combobox by default
l1.current(0)

然后在您的calculate()方法中:

def calculate():
    # Get current value selected in the combobox and convert it to float
    a = float(l1.get())
    ...