I\'m trying to generate multiple ComboBoxes with values from a \"config.ini\" file, the config.ini file data is:
priority1 = Normal:farty-blobble-fx.wav:2
priority8
The problem is that you're creating more than one combobox, yet you keep overwriting the variables in each iteration of the loop. At the end of the loop, self.PRIOR_SOUNDS
will always point to the last combobox that you created. The same is true for self.box_value
, self.PLAY
, etc.
The simplest solution is to use an array or dictionary to store all of your variables. A dictionary lets you reference each widget or variable by name; using a list lets you reference them by their ordinal position.
A solution using a dictionary would look something like this:
self.combo_var = {}
self.combo = {}
for name, value in parser.items(section_name):
...
self.combo_var[name] = StringVar()
self.combo[name] = Combobox(..., textvariable = self.combo_var[name])
...