您好,我有一些带有一些值的 comobox(用户仅选择一项),我希望根据该选择,用户将被允许从单选按钮中选择多项选择。例如: elemnt 的 comobox - 用户选择一个元素,然后选择许多作物 grom 单选按钮。我无法在两者之间建立联系。请帮助我的代码:
def calibration_window():
global cb_elemnt,cb_crop
top = tkinter.Toplevel (window)
top.title ("Calibration")
top.geometry ("400x400")
ttk.Label (top, text="Select an element:",font = ("Segoe UI Light", 10)).grid (column=0, row=0)
cb_elemnt = ttk.Combobox (top, values=ele_list)
cb_elemnt.grid(column=0, row=1)
ttk.Label (top, text="Select a crop:",font = ("Segoe UI Light", 10)).grid (column=2, row=0)
# connect between element comobox to the func
cb_elemnt.bind ("<<ComboboxSelected>>",set_radio)
def set_radio(event):
i=0
radios=[]
for widget in radios:
widget.destroy ()
radios = []
if StringVar().get() !="N":
radio_values = pd.unique (df[df['elemnt'] == StringVar().get()]["crop"]) #take the suitable crop from DB
else:
radio_values = pd.unique (df_nir[df_nir['elemnt'] == StringVar().get()]["crop"])
for t in radio_values:
i = i + 1
b = Radiobutton (self, text=t, variable=IntVar(), value=t)
b.grid (row=i, column=0)
radios.append(b)
叮当猫咪
相关分类