I working on GUI for insering data to a database.I need to create a dropdown list(combobox) that will change it's values based on a value chosen in another dropdown list.
I've tried to use if statment of chosen values from first OptionMenu to based of StringVar but its not working. Do you have any suggestions?
Type =('Option1', 'Option2', 'Option3')
CategoryA = ('1','2', '3')
CategoryB= ('A','Transport')
TypeSelected = StringVar()
TypeSelected.set(Type[0])
TypeOption = OptionMenu(self,TypeSelected,*Type)
TypeOption.grid(row=1, column=1)
CategoryLabel = Label(self,text='Category')
CategoryLabel.grid(row=2, column=0)
CategorySelected = StringVar()
print(str(TypeSelected))
if(str(TypeSelected)=='Przychody'):
CategorySelected.set(CategoryPrzychody[0])
category = CategoryPrzychody
else:
CategorySelected.set(CategoryRozchody[0])
category = CategoryRozchody
CategoryOption = OptionMenu(self,CategorySelected,*category)
CategoryOption.grid(row=2,column=1)