tkinter question

Alan Gauld alan.gauld at gssec.bt.co.uk
Tue Jun 13 09:56:16 EDT 2000


Bob van der Poel wrote:
> Third, how can I define a widget command with an arg. For example:
> 
>         q = Button( text="Quit", command = quitit("sure?") )

Use a lambda:

foo = lambda s="sure?" : # define it here
q = Button(text="Quit"), command=foo)

Alternatively you can use the bind mechanism which passes an 
event object to your handler - but the event might not hold 
what you need...

Thirdly you can make your handler a method of a class and 
have the class store the 'parameters'.

Alan G.

-- 
=================================================
This post represents the views of the author 
and does not necessarily accurately represent 
the views of BT.



More information about the Python-list mailing list