Tkinter question

Hendrik van Rooyen mail at microcorp.co.za
Tue Oct 24 01:48:51 EDT 2006


 Sorin Schwimmer  wrote:


Hi All,

Is it possible to have a widget id while it is created?
Something like this:

Button(root, text='...', command= lambda v=<widget id>: fn(v)).grid()

and then the function:

def fn(v):
  v['bg']='BLUE' # or maybe nametowidget(v)['bg']='BLUE'

Thanks,
Sorin

- just give the thing a name when you make it:

MyFirstButton = Button(.....

or possibly if its in a class:

self.MyFirstButton = Button(.....

then use

self.MyFirstButton.configure('bg' = 'blue', 'text' = 'new description on the
button')

HTH

Hendrik





More information about the Python-list mailing list