[issue31552] IDLE: Convert browswers to use ttk.Treeview

Terry J. Reedy report at bugs.python.org
Thu Sep 28 00:22:43 EDT 2017


Terry J. Reedy <tjreedy at udel.edu> added the comment:

The main issue for conversion is expanding nodes.  tree.py does not define a widget class.  Rather, is uses a used a canvas and places images and text thereupon.  The latter is done with instances of TreeNode.  Each instance thereof is initialized with an instance of a subclass of TreeItem.  TreeItems can tell their TreeNode whether they can generate children without actually doing so.

Treeview *is* a widget which manages internal column and line structures.  Clicking a [+] or [-] icon generates a '<<TreeviwOpen>>' or '<<TreeviewClose>>' event.  Double clicking a line generates both a select and flip event.  The catch is that there is no [+] unless the node already has at least one child.

One solution would be to initially generate the whole tree of Treeview items from the pyclbr tree.  Another is to give items with children a dummy child and replace it on demand.  The item could be given its line number (as a string) as its id.  A subclass of Treeview (or a Frame containing one) could have a dict mapping ids to child dicts).

Since the browser TreeItem subclasses are used by pathbrowser, I would initially move them to that module rather than delete them.  Or I would combine the two modules.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31552>
_______________________________________


More information about the Python-bugs-list mailing list