[issue27025] More human readable generated widget names

Terry J. Reedy report at bugs.python.org
Thu Jun 2 17:44:19 EDT 2016


Terry J. Reedy added the comment:

While a widget tree could be constructed using tk's introspection functions, I believe there are other good uses for monkey patching.  The attached .py file defines a monkeypatch context manager (does one exist already?).  The file uses the c.m. twice to patch ConfigDialog.CreatePageFontTab so it patches tk for the duration of its call.  The result is 16 rather than 287 lines of output.

>Current (from my program)
>.3070117292.3069168812.3069169068.3069251628.3068822220.3069266540.3068822348.3068839820.3068851532
> Using Tk command name as a base of a name: >._toplevel1._frame1._frame2._frame73._labelframe10._frame127._canvas6._frame128._label28
>Using Python class name:
>._configdialog1._tabbedpageset1._frame1._frame61._labelframe10._verticalscrolledframe6._canvas6._frame105._label28

In the future, the last line might be shortened to
>._config1._notebook1._frame1._frame61._labelframe10._vscrollframe6._canvas6._frame105._label28
which is shorter that the current address-based name. Anyone who cares can either user shorted class names or explicitly gives instances shorter default names.

I don't know what to say about numbering, except that I would prefer any of the options to status quo.

----------
Added file: http://bugs.python.org/file43118/tknames.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27025>
_______________________________________


More information about the Python-bugs-list mailing list