There's no reason to use vars
. The simple solution is to store all the widgets in a dictionary:
self.buttons = {}
for b in controls:
self.buttons[b[0]] = Button(...)
There's also no good reason to use place
-- place
has it's advantages but they are few and far between. Your GUI will be much easier to write and maintain if you use pack
or grid
. In the case of a calculator, grid
is a very natural choice. Also, trying to define the layout in a data structure is cumbersome. I'm not sure there's any real value to it since it's unlikely you're going to be creating a generic algorithm that can create calculators with different numbering systems.
I recommend separating the layout of the widgets from the creation of the widgets. In my experience that simply makes GUI development easier.
self.buttons["zer"].grid(row=3, column=0, columnspan=2, sticky="nsew")
self.buttons["two"].grid(row=2, column=0, sticky="nsew")
self.buttons["thr"].grid(row=2, column=1, sticky="nsew")
...
Also, I'd suggest not using names like "zer" -- there's really no value in abbreviating a four letter word to three letters.