[wxPython-users] ANN: HyperTreeList Control for wxPython :-D

Andrea Gavana andrea.gavana at gmail.com
Wed May 9 08:56:15 PDT 2007


Hi Robin & All,

On 5/9/07, Robin Dunn wrote:
> Andrea Gavana wrote:
> > Hi All,
> >
> >    to celebrate my birthday ( :-D ), I am happy to announce my latest
> > child, HyperTreeList.
> >
> > HyperTreeList is a class that mimics the behaviour of
> > wx.gizmos.TreeListCtrl, with almost the same base functionalities plus
> > some more enhancements. This class does not rely on the native
> > control, as it is a full owner-drawn tree-list control.
> >
> > HyperTreeList is somewhat an hybrid between CustomTreeCtrl and
> > wx.gizmos.TreeListCtrl.
>
> I'll try to get time to browse through the source code in a day or two,
> but one question I have right off is what is the relationship between
> this and CustomTreeCtrl code?  Does it reuse that code in some way?
> (Derive from, embed, sibling, etc.)  Or is it a complete
> reimplementation that just adds columns to the tree like
> gizmos.TreeListCtrl is a reimplementation of the generic wxTreeCtrl class?
>
> IIRC that was the main reason that wxTreeListCtrl was never moved into
> the core wxWidgets, because it duplicated and slightly modified all of
> the treectrl code instead of refactoring so they both could share the
> common code.

Ok, I refactored a bit the implementation:

1) Now HyperTreeList is a subclass of CustomTreeCtrl, except for the
drawing functions and mouse event handling;
2) TreeListItem is a subclass of GenericTreeItem (that is implemented
in CustomTreeCtrl) plus some other attributes/methods;
3) The DragImage, TreeEvent, TreeItemAttr, TreeRenameTimer classes are
taken directly from CustomTreeCtrl.

Plus some other tweaks. The original HyperTreeList implementation is
6400 lines long, and I was able to kick it down to 3100. It should be
possible to hack it more in order to share (part of) the drawing and
mouse handling code between the two classes, but that would require
medium-sized modifications to CustomTreeCtrl and major tweaks to
HyperTreeList. It can be done, but I don't have much time right now
and most of all I am worried to screw up something :-D
I am not that expert in Python so I may also miss useful tricks for
subclassing, refactoring, sharing code and so on... but the current
implementation is a start :-D

I'll upload the source code and demo this evening, if someone is
interested in trying the new version.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/




More information about the wxpython-users mailing list