Tkinter how to access the widget by name
woooee
woooee at gmail.com
Tue Oct 16 21:52:20 EDT 2012
On Oct 14, 1:11 pm, Владимир Пылев <clinicalf... at gmail.com> wrote:
> label = Label(frame, width = 40, text='text', name = 'name')
> ...
> name_='name'
> configure(name_)
> ...
> def configure(name_)
> #And how can that be?
> # At least let the text you want to change ....
I do not understand your question, but I think you want something like
def configure(name): ## note that a colon is required here
name.configure(bg='green')
# or
name['bg']='green'
label_1 = Label(frame, width = 40, text='text')
configure(label_1)
label_2 = Label(frame, width = 40, text='label_2')
configure(label_2)
If this is not what you want, post an example that is more specific.
More information about the Python-list
mailing list