Generating an event in Tkinter

nharlow at my-deja.com nharlow at my-deja.com
Wed Sep 1 15:56:08 EDT 1999


This is the code I am now using.  However, now the window is just
freezing entirely.  It is not executing the print statement.  None of
the other buttons will work.  It just locks up; I don't even get any
errors.  Any other ideas?


import time
name="Analyze"
while i< 100:
	print "%s: This is %s time through the loop"%(name,i+1)
	widget.event_generate("<<foo>>")
	widget.bind("<<foo>>", lambda e, y=1, x=time.sleep: x(y))
	i=i+1

Nick

In article <022101bef44f$8e98b9c0$f29b12c2 at secret.pythonware.com>,
  "Fredrik Lundh" <fredrik at pythonware.com> wrote:
> nharlow at my-deja.com wrote:
> > I get the following error:
> > Traceback (innermost last):
> >   File "c:\program files\python\lib\lib-tk\Tkinter.py", line 752, in
> > __call__
> >     return apply(self.func, args)
> >   File "C:\nick\GUI\spidergui.py", line 145, in <lambda>
> >     widget.bind("<<foo>>",lambda x=sleep, y=1:x(y))
> > AttributeError: no __call__ method defined
>
> the lambda is called with one argument (the event
> descriptor), which is then called instead of the sleep
> function.  changing the lambda to:
>
>     lambda e, x=sleep, y=1:x(y)
>
> should help.
>
> </F>
>
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list