Tkinter.event.widget: handler gets name instead of widget.

Chris Angelico rosuav at gmail.com
Mon Jul 9 18:23:39 EDT 2012


On Tue, Jul 10, 2012 at 3:49 AM, Rick Johnson
<rantingrickjohnson at gmail.com> wrote:
> ALL event handlers should marked as *event
> handlers* using a prefix. I like to use the prefix "evt". Some people
> prefer other prefixes. In any case, just remember to be consistent.
> Also, event handler names should reflect WHAT event they are
> processing, not some esoteric functionality of the application like
> "pick_record" or "info_profile". However if you like, simply have the
> event handler CALL an outside func/meth. This type of consistency is
> what separates the men from the boys.

Or perhaps it separates the half-elves from the hobgoblins.
Hard-and-fast rules are seldom valid in stylistic questions. There's
nothing wrong with having a prefix like "evt" or "on" or whatever;
there's also nothing wrong with a naming convention of PB_Open_Click
(PB for "PushButton" (which is what that GUI toolkit called them),
Open being what the button does, and Click is the event being handled
- that's the VX-REXX convention). Or having no specific event handler
and going straight to your "pick_record" function; that's fine too,
especially if you have multiple entry-points to that.

Frederic, you'll get a lot of advice on this list, but treat it as
just that - advice. There are very few actual rules; read what people
say and then make your own choices.

ChrisA



More information about the Python-list mailing list