Tkinter.event.widget: handler gets name instead of widget.
anthra.norell at bluewin.ch
Wed Jul 11 09:59:27 CEST 2012
On Tue, 2012-07-10 at 18:06 -0700, Rick Johnson wrote:
> 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?
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"? 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.
>  http://www.pythonware.com/library/tkinter/introduction/x147-more-on-widget-names.htm
>  http://docs.python.org/release/3.0.1/library/functions.html#enumerate
More information about the Python-list