[Tutor] Callbacks in Python

Luke Paireepinart rabidpoobear at gmail.com
Thu Aug 27 03:51:31 CEST 2009


Suppose you are writing a GUI application.  You don't want to write it from
scratch so you want to use TKInter or WXPython.  However, you also want to
process the user's mouse clicks.  These clicks won't occur in a consistent
manner;  sometimes they may occur frequently (double-clicking), sometimes
infrequently (they're busy reading your interface, whatever.)  So if you
just poll the TKInter side of the program for events, a lot of the polls
will be wasted.  What you really want is that your code is run only when
your event occurs.So you write a program that does what you want on each
mouse click.  Then you pass it to TKInter and say "hey, call this whenever
you get a mouseclick event!"  that function you wrote is called a
"callback".

Make sense?

On Wed, Aug 26, 2009 at 8:47 PM, Jramak <jramak345 at gmail.com> wrote:

> Hello
>
> I'm confused by callbacks. I would really appreciate any introduction or
> help in understanding the concept of callbacks.
>
> Thanks much
> Jramak
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090826/dabe9e70/attachment.htm>


More information about the Tutor mailing list