ANN: HyperTreeList Control for wxPython :-D

Hi All,

    to celebrate my birthday ( :smiley: ), 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.

In addition to the standard wx.gizmos.TreeListCtrl behaviour, this
class supports:

* CheckBox-type items: checkboxes are easy to handle, just selected or
  unselected state with no particular issues in handling the item's children;

* RadioButton-type items: since I elected to put radiobuttons in
HyperTreeList, I
  needed some way to handle them, that made sense. So, I used the following
  approach:
     - All peer-nodes that are radiobuttons will be mutually
exclusive. In other words,
       only one of a set of radiobuttons that share a common parent
can be checked
       at once. If a radiobutton node becomes checked, then all of its peer
       radiobuttons must be unchecked;
     - If a radiobutton node becomes unchecked, then all of its child
nodes will
       become inactive.

* Hyperlink-type items: they look like an hyperlink, with the proper
mouse cursor on
  hovering.

* Multiline text items.

* Enabling/disabling items (together with their plain or grayed out icons).

* Whatever non-toplevel widget can be attached next to a tree item.

* Whatever non-toplevel widget can be attached next to a list item.

* Column headers are fully customizable in terms of icons, colour,
font, alignment etc...

* Default selection style, gradient (horizontal/vertical) selection
style and Windows
  Vista selection style.

* Customized drag and drop images built on the fly.

* Setting the HyperTreeList item buttons to a personalized imagelist.

* Setting the HyperTreeList check/radio item icons to a personalized imagelist.

* Changing the style of the lines that connect the items (in terms of
wx.Pen styles).

* Using an image as a HyperTreeList background (currently only in "tile" mode).

And a lot more. Check the demo for an almost complete review of the
functionalities.

The demo by itself is *very* huge, as I wanted to show the basic
functionalities and the new ones, as completely as possible (even if
the demo does not show all the possibilities). In the demo, you can
use the options on the left wx.ScrolledWindow and the right mouse
button on the HyperTreeList to activate other methods.

I appreciate any comment, suggestion, idea and bug report (patches are
far more welcomed :slight_smile: ). Noting that the code by itself is quite huge,
it is highly possible that some bug is loudly laughing at me and I
didn't spot it.

I tested the code on Windows XP, Python 2.5 and wxPython 2.8.3/2.8.4
pre-release. It should work also with older version of wxPython, but I
am not sure. I have no idea of its behavior on GTK and Mac, though I
am expecting (as usual) a gazillion of problems on that amazing
platform that is Mac. If someone is able to run it on other platforms
than Windows, I would like to ask him/her if he/she can please send me
some screenshots of it.

Note: the docs are still incomplete, but I will finish them as soon as
I fix the major bugs that some kind volunteers will find in my code.

You can find the source, the demo and some screenshots in the usual place:

http://xoomer.alice.it/infinity77/eng/freeware.html#hypertreelist

wxPython rules :smiley:

Andrea.

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

Hi Stani,

Hi Andrea!
Happy birthday!

Thank you :smiley: . Just turning on 30...

Unfortunately something went wrong with unwrapping your present on
Ubuntu 7.04. wxPen doesn't seem supported by GTK, as you suggested in
your comment:

<snip>
<snap>

   self._dottedPen = wxPen("grey", 0, 0) # Bitmap based pen is not
supported by GTK!
NameError: global name 'wxPen' is not defined

Well, that's a stupid mistake! It should be wx.Pen, not wxPen! I have
missed it when translating from the C++ source... would you mind
trying with wx.Pen and see if it works? I believe there are other
issues on GTK and Mac (namely drawing inconsistencies)...

Andrea.

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

···

On 5/9/07, Stani's Python Editor wrote:

Hi Andrea,
That did it. Now it seems to run fine on Ubuntu. The sidebar was a little too narrow, hiding most of the buttons. I didn't do any thourough testing, but at least now it starts fine. As a proof: a screenshot of your control in its full glory!
Thanks again,
Stani

Andrea Gavana wrote:

···

Hi Stani,

On 5/9/07, Stani's Python Editor wrote:

Hi Andrea!
Happy birthday!

Thank you :smiley: . Just turning on 30...

Unfortunately something went wrong with unwrapping your present on
Ubuntu 7.04. wxPen doesn't seem supported by GTK, as you suggested in
your comment:

<snip>
<snap>

   self._dottedPen = wxPen("grey", 0, 0) # Bitmap based pen is not
supported by GTK!
NameError: global name 'wxPen' is not defined

Well, that's a stupid mistake! It should be wx.Pen, not wxPen! I have
missed it when translating from the C++ source... would you mind
trying with wx.Pen and see if it works? I believe there are other
issues on GTK and Mac (namely drawing inconsistencies)...

Andrea.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi Chris,

Stani's Python Editor wrote:
> Hi Andrea!
> Happy birthday!
> Unfortunately something went wrong with unwrapping your present on
> Ubuntu 7.04. wxPen doesn't seem supported by GTK, as you suggested in
> your comment:

wouldn't that be wx.Pen (don't forget the dot!)

Yes, I completely overlooked that one... it should be wx.Pen.

I suspect Andrea didn't test on GTK, and thus this code didn't run.

Unfortunately I can't, I don't have GTK (nor Mac) and my Virtual
Machine is now *so* virtual that it doesn't work anymore. I have tried
with VMWare and VirtualBox to no avail. I can't connect to the
internet from the VM so I can't install wxPython. Game over.

Andrea.

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

···

On 5/9/07, Christopher Barker wrote:

Happy birthday Andrea!!

and thanks for the new widget :slight_smile:

···

On 5/9/07, Andrea Gavana andrea.gavana@gmail.com wrote:

Hi All,

to celebrate my birthday ( :smiley: ), I am happy to announce my latest
child, HyperTreeList.

Hi Robin & All,

Andrea Gavana wrote:
> Hi All,
>
> to celebrate my birthday ( :smiley: ), 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 :smiley:
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 :smiley:

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/

···

On 5/9/07, Robin Dunn wrote:

Hi Roee,

···

On 5/15/07, roee shlomo wrote:

Disabling TR_HAS_BUTTONS changes the position of the radio buttons to be on
top of the directory icons.

Thank you, I must be blind :smiley:

Andrea.

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

Hi Roee and All,

···

On 5/15/07, roee shlomo wrote:

Disabling TR_HAS_BUTTONS changes the position of the radio buttons to be on
top of the directory icons.

This bug should be fixed right now. Thank you a lot for your bug report.

Andrea.

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

Hi again,

No need to thank anyone for testing, its our duty :stuck_out_tongue:

this one is from the demo:

Traceback (most recent call last):
File “HyperTreeListDemo.py”, line 1843, in OnRightDown

pt = event.GetPosition()

AttributeError: ‘TreeEvent’ object has no attribute ‘GetPosition’

Thanks,
Roee.

···

On 5/16/07, Andrea Gavana andrea.gavana@gmail.com wrote:

Hi Roee and All,

On 5/15/07, roee shlomo wrote:

Disabling TR_HAS_BUTTONS changes the position of the radio buttons to be on

top of the directory icons.

This bug should be fixed right now. Thank you a lot for your bug report.

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”

http://xoomer.virgilio.it/infinity77/


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org



http://code.google.com/p/lh-abc