Adam Cripps wrote:
I'm trying to create recursive Tkinter buttons with:

                for i in range(0,10):
                        print i
                        buttonlabel = "field " +str(i)
                        button[i] = Button (text=buttonlabel)
                        button[i].grid(column=3, row = i+3)

However, Tkinter doesn't seem to like it with

Please show us the whole program. This works for me:

from Tkinter import *

root = Tk()
button = {}
for i in range(0,10):
    print i
    buttonlabel = "field " +str(i)
    button[i] = Button (text=buttonlabel)
    button[i].grid(column=3, row = i+3)

root.mainloop()

Kent


Traceback (most recent call last): File "report.py", line 83, in ? app = Application(root) File "report.py", line 28, in __init__ self.createWidgets() File "report.py", line 79, in createWidgets button[i] = Button (text=buttonlabel) File "C:\PYTHON24\lib\lib-tk\Tkinter.py", line 1146, in __setitem__ self.configure({key: value}) File "C:\PYTHON24\lib\lib-tk\Tkinter.py", line 1139, in configure return self._configure('configure', cnf, kw) File "C:\PYTHON24\lib\lib-tk\Tkinter.py", line 1130, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) File "C:\PYTHON24\lib\lib-tk\Tkinter.py", line 997, in _options if k[-1] == '_': k = k[:-1] TypeError: unsubscriptable object

What is a good method for producing recursive Tk widgets?

TIA. Adam


_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to