[issue27025] More human readable generated widget names

Terry J. Reedy report at bugs.python.org
Wed Jun 1 20:50:35 EDT 2016


Terry J. Reedy added the comment:

To make the experiment easy to repeat, say after the patch, I wrote this.  (Perhaps inspired by Ned Batchelder's 'machete debugging' PyCon talk.)

import tkinter as tk
from idlelib.configdialog import ConfigDialog
_realsetup = tk.BaseWidget._setup
def _wrapsetup(self, master, cnf):
    _realsetup(self, master, cnf)
    print(self.widgetName, self._w)
tk.BaseWidget._setup = _wrapsetup
root = tk.Tk()
ConfigDialog(roo)
ttk.BaseWidget._setup = _realsetup

Observations: the longest path rather long: .<num1>.....<num9>.  The root to widget paths collectively represent a tree and, sorted, could be used to populate a tree widget, such as a Treeview.  With the proposed new names, this would give one a useful overview of the total gui, or a part thereof.

If one subclasses a widget, such as class MyFrame(Frame, would the instance .widgetName used in the patch 'Frame' or 'MyFrame'?  The latter would make the treeview really useful, and reward judicious subclassing.

----------

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


More information about the Python-bugs-list mailing list