Sunday, 11 August 2013

Variable subsitution in tkinter

Variable subsitution in tkinter

Why doesn't this code work
objects=[
('o','label', 0, 1),
('g','label', 0, 2),
('e','label', 0, 3),
('r','label', 1, 0),
('w','label', 2, 0),
('x','label', 3, 0),
]
for thing in objects:
name = thing[0]
type = thing[1]
name = tk.type()
I am trying to use an list to define my tkinter widgets in an attempt to
keep the code neat. The first item is the name and then the type. I keep
getting this error.
module has no attribute thing
I know what I'm doing wrong I just don't know how to fix it. How can I use
the values that are stored in the variable to create the widget?
So I want name = tk.type() to be interpreted as o = tk.label()
Thanks for any help.

No comments:

Post a Comment