[Tutor] Lots of variables
alan.gauld at freenet.co.uk
Sun Aug 7 19:04:13 CEST 2005
> I am trying to write a gui that has a lot of checkboxes. It is over
> different ones. I use a for statement to generate:
> ver = 200
> for i in ['Car','House','Boat','Plane']:
> self.fra26_che01p = Checkbutton (self.fra26)
> The variable does not work for obvious reasons. I need to change
> for each new creation. If I had made the variables manually, I would
Try a dictionary using the strings in your list as the keys and the
controls as the values.
See the bank account example in my OOP topic for an example.
Author of the Learn to Program web tutor
More information about the Tutor