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

Frederic Rentsch anthra.norell at bluewin.ch
Wed Jul 11 03:59:27 EDT 2012


On Tue, 2012-07-10 at 18:06 -0700, Rick Johnson wrote:
> Also:
> 
> Q3: Why are you explicitly setting the name of your "subFrame" widgets
> instead of allowing Tkinter to assign a unique name?...AND are you
> aware of the conflicts that can arise from such changes[1]?
> 

I find custom-named widgets easier to work with during development. I can tell
what this is; ".main-frame.data-frame.title-hit-list.-10-". If I didn't assign
names it would look something line this:".2837029.283725.283762.2848308".  
Once my program works I can drop custom-naming.
   I understand that conflicts may arise if one assigns numeric names.
To find out whether the digits in the label names ('-10-' above) might
be implicated, I changed to spelled-out names ('ten'). The change had no
effect. The reference you list blow (x147-more-on-widget-names.htm)
indeed says "don't use names which only contain digits". 

> Q4: Are you aware of the built-in function "enumerate"[2]? I see you
> are passing around indexes to iterables AND simultaneously needing the
> obj reference itself. I prefer to keep indexing to a minimum.  If
> there is no bleeding edge performance issue to worry about (and there
> almost *always* never is) why not use enumerate?
> 
Aware, yes. In the habit of, no. Thanks for the reminder.

> [1] http://www.pythonware.com/library/tkinter/introduction/x147-more-on-widget-names.htm
> [2] http://docs.python.org/release/3.0.1/library/functions.html#enumerate

Frederic





More information about the Python-list mailing list