Need help with Tkinter for dynamic # of objects

Donald Parker dbparker at nortelnetworks.com
Sun Dec 12 22:26:45 EST 1999


Apologies in advance .... I'm quite new to Python so I suspect my problem is
quite simple and due to a basic misunderstanding ... nevertheless, some
insight into that misunderstanding would be appreciated.

I'm trying to define a Frame class that can have a variable number of button
widgets. Within the Frame class I've tried coding the constructor as

n=0
while n < m :
    self.set_of_buttons[n] = [Tkinter.Button(self)]
    n+n+1

...which results an exception for an attribute error for 'set_of_buttons'

I thought types and variables came into existence as a result of assignment,
but I am clearly breaking a rule I do not understand here.

I would like to know:
a) what rule I am breaking
b) how to achieve my objective





More information about the Python-list mailing list