我在 Tkinter Python 中遇到了组合框更新的问题。
我有两个组合框:
A带有values =['A','B','C']和 的组合框B我想要的是:
A当在组合框中选择值时A,然后在组合框中B显示值['1','2','3']
B当在组合框中选择值时A,然后在组合框中B显示值['11','12','13']
C当在组合框中选择值时A,然后在组合框中B显示值 s['111','112','113']
目前我的部分代码如下:
def CallHotel(*args):
global ListB
if hotel.get()==ListA[0]
ListB=ListB1
if hotel.get()==ListA[1]
ListB=ListB2
if hotel.get()==ListA[2]
ListB=ListB3
ListA=['A','B','C']
ListB1=['1','2','3']
ListB2=['11','12','13']
ListB3=['111','112','113']
ListB=ListB1
hotel = StringVar()
hotel.set('SBT')
comboboxA=ttk.Combobox(win0,textvariable=hotel,values=ListA,width=8)
comboboxA.bind("<<ComboboxSelected>>",CallHotel)
comboboxA.pack(side='left')
stp = StringVar()
stp.set('STP')
comboboxB=ttk.Combobox(win0,textvariable=stp,values=ListB,width=15)
comboboxB.pack(side='left')
Run Code Online (Sandbox Code Playgroud)