Press button to load data

jim-on-linux inq1ltd at verizon.net
Fri Nov 17 20:27:09 CET 2006


On Friday 17 November 2006 02:58, you wrote:
> On Fri, 17 Nov 2006 00:25:39 -0500,
> jim-on-linux <inq1ltd at verizon.net>
>
> declaimed the following in comp.lang.python:
> > Without being able to run the code my
> > question is where is the  id  in the lambda
> > defined?
>
> 	Please take into account that I've not
> actually used lambdas, so might have some
> mistakes in the syntax...
>
> > >     for bill in shelvename:
> > >         global funcs
> > >         bill1 = Button(None, text=
> > > shelvename[bill].name,
> > > font=('bold',10),command=(lambda x = id:
> > > fetchRecord(x)))
>
> 	"id" would be something that "identifies" the
> button... In this case, maybe you can use
> "bill":
>

Think about relating a Tkinter variable to each 
button then the button is related to a unique 
variable. ( Tkinter StingVar or IntVar or some 
others.) Then you will have to keep the variables 
in a list or dictionary for recalling. 


jim-on-linux
http://www.inqvista.com





> 	... command=(lambda x = bill: fetchRecord(x))
> ...
>
> As I understand the lambda syntax, what this
> does is create a "function" (which is the
> command that gets run when the button is
> pushed), and this function will call
> fetchRecord passing it the value that "x" had
> at the time of definition (hence the x=...)
> --
> 	Wulfraed	Dennis Lee Bieber		KD6MOG
> 	wlfraed at ix.netcom.com		wulfraed at bestiaria.com
> 		HTTP://wlfraed.home.netcom.com/
> 	(Bestiaria Support
> Staff:		web-asst at bestiaria.com)
> HTTP://www.bestiaria.com/



More information about the Python-list mailing list