Placing Tkinter objects in a dictionary

David Brown david at no.westcontrol.spam.com
Thu Nov 7 04:17:19 EST 2002


"Adonis" <deltapigz at telocity.com> wrote in message
news:3dc9fa87$1_4 at nopics.sjc...
> I have a loop creating Tkinter objects (an Entry text box) all with the
same
> name and placing its instance in a dictionary: i.e:
>
> for x in range(10):
>     myEntry = Entry(frame)
>     myEntry.grid(row=x, column=0)
>
>     someDict['%s'%x] = myEntry
>
> now I have another function which will modify myEntry:
>
> def someFunc(x, data):
>     someDict[str(x)].config(text=data) # here is my error; the config does
> not work;
>                                        # no error is raised.
>
> any help is greatly appreciated.
>
> Adonis
>

Just as an asside (it's not related to your problem, which Jørgen has
addressed), why are you converting x to a string for the dictionary key, and
not just using someDict[x] directly?






More information about the Python-list mailing list