Hi all, Is there actually any difference between root.after_idle(foo) and root.after(0, foo) ? (I've noticed that if I call after_idle and re-add it at the end of my callbacks then any calls to "after" have no effect, and that I can work around this by doing after(0, ...) instead, but wondered if there were any drawbacks to doing this.) Regards, Geoff Bache
On Mon, May 17, 2010 at 10:52:56PM +0200, Geoff Bache wrote: . . .
root.after_idle(foo)
and
root.after(0, foo)
?
(I've noticed that if I call after_idle and re-add it at the end of my callbacks then any calls to "after" have no effect, and that I can work around this by doing after(0, ...) instead, but wondered if there were any drawbacks to doing this.) . . . Does <URL: http://wiki.tcl.tk/9926 > help?
On Mon, May 17, 2010 at 11:01 PM, Cameron Laird <Cameron@phaseit.net> wrote:
On Mon, May 17, 2010 at 10:52:56PM +0200, Geoff Bache wrote: . . .
root.after_idle(foo)
and
root.after(0, foo)
?
(I've noticed that if I call after_idle and re-add it at the end of my callbacks then any calls to "after" have no effect, and that I can work around this by doing after(0, ...) instead, but wondered if there were any drawbacks to doing this.) . . . Does <URL: http://wiki.tcl.tk/9926 > help?
Hi Cameron, Thanks for the tip, hadn't occurred to me to look for Tcl/Tk documentation. It didn't really answer the question though and I must admit I don't speak Tcl so didn't really follow the example (which looked to me like it nested a call to "after" inside a call to "after_idle", why would you want to do that?) Regards, Geoff
On Mon, May 17, 2010 at 11:17:31PM +0200, Geoff Bache wrote: . . .
Thanks for the tip, hadn't occurred to me to look for Tcl/Tk documentation. It didn't really answer the question though and I must admit I don't speak Tcl so didn't really follow the example (which looked to me like it nested a call to "after" inside a call to "after_idle", why would you want to do that?) . . . I quote two Masters of Tk:
Idles run until the idle queue is drained. If an [after idle] reschedules itself endlessly, it hangs the event loop. [after idle [after 0 ...]] causes the idle to schedule a timer event that's immediately ready, so the rescheduled callback is NOT an idle event and the event loop can make progress. idle events are critical to doing a good job of a GUI; [I have] no idea if they are useful for anything else ... One of us needs to write this in readable English. I know *I* am already backed up ...
. I quote two Masters of Tk:
Idles run until the idle queue is drained. If an [after idle] reschedules itself endlessly, it hangs the event loop. [after idle [after 0 ...]] causes the idle to schedule a timer event that's immediately ready, so the rescheduled callback is NOT an idle event and the event loop can make progress.
idle events are critical to doing a good job of a GUI; [I have] no idea if they are useful for anything else ...
One of us needs to write this in readable English. I know *I* am already backed up ...
OK. It would help me if the example was in readable Python for a start... Am I right in thinking it would translate as root.after_idle(foo) def foo(): ..... root.after(0, foo) In this case I'm even more confused. What's the point of it being an "idle event" the first time but never thereafter? Wouldn't it be equivalent to also add it the same way the first time? Thanks, Geoff
participants (2)
-
Cameron Laird -
Geoff Bache