ANN: CustomTreeCtrl For wxPython ;-)

Hello NG,

    just a note to say that a new version of CustomTreeCtrl is
available (0.4). This version include the fixes that John sent me,
and:

On Linux I'm getting a strange effect where the mouse cursor momentarily
disappears each time the mouse moves over the tree window. When moving
fast the cursor ends up not being visible at all. Are you doing
anything on mouse move events or in idle handlers that could possibly
have an affect like that? (Perhaps forcing a refresh, changing cursor,
etc.)

I have got rid of that SetCursor, you may try it now and see if the
problem persists...

In the demo you should really let the buttons have their default height.
There are too many variations of themes to be able to guess ahead of
time how tall is tall enough.

Done. Now the buttons have their default size.

On Mac you can't set the background colour of wx.Buttons so the ones
that you are using for colour selection are just ugly.
wx.lib.colourselect would work better.

Done.

I think that it would be better to not create new values for the TR_*,
wxEVT_*, EVT_* and etc. that have the same names as used with the
wx.TreeCtrl. Instead just make assignments from the values that already
exist in the wx module. This way if somebody mistakenly uses
wx.EVT_TREE_ITEM_ACTIVATED instead of
CustomTreeCtrl.EVT_TREE_ITEM_ACTIVATED the event will still be caught by
their handler because the event types will be equivalent.

Done. I used the existing events where applicable, and cutom events otherwise.

For other constants and such in the module that are for internal use
only, it would be nice to rename them with a leading underscore so
epydoc won't make an entry for them in the document.

Done.

Is there a way to toggle check or radio items with the keyboard?

Yes, now there is. You can press the space bar to toggle/untoggle the
check or radio items. I hope this is what you intended.

On Mac there is a bug where the cursor keys are not reporting their WXK_
values in the EVT_CHAR event. You should use EVT_KEY_DOWN instead.

Done.

Mac doesn't support user-dash pens very well. A better default may be a
solid line, with a lighter grey colour.

Ok, I made a switch for the Mac: by default, it now uses a continuous
medium grey pen, while on MSW and GTK it still uses the user-dash pen.

In Your Docstrings And Comments The Every Word Is Capitalized Style Is
Difficult To Read. :slight_smile:

Done. Sorry for that.

For consistency with the other events EVT_TREE_ITEM_CHECK should
probably be EVT_TREE_ITEM_CHECKED.

Done.

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

http://xoomer.virgilio.it/infinity77/eng/freeware.html#customtree

Or, if you prefer in italian:

http://xoomer.virgilio.it/infinity77/ita/freeware.html#customtree

I guess that's it for now. Once again Andrea you've amazed us all!

Thank you :slight_smile:

···

--
"Imagination Is The Only Weapon In The War Against Reality."

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

Hello NG,

    just an update about the newest version of CustomTreeCtrl (0.7),
which can be found in the usual places:

http://xoomer.virgilio.it/infinity77/eng/freeware.html#customtree

Or, if you prefer in italian:

http://xoomer.virgilio.it/infinity77/ita/freeware.html#customtree

This update fixes some typos in the docstrings and other problems
identified by John Jackson:

1) GetItemFont returns now wx.NullFont instead of None if an item does
not have a font assigned;
2) Added a new method SetItemItalic (with his companion IsItalic);
3) Fix for a bug in GetNextVisible();

About the following problem:

<John Jackson>
I have been able to reproduce the problem on Windows. It happens if
you hide the root, and set both the style and the ctstyle to include
wx.TR_HIDE_ROOT.
Perhaps you can get rid of the ctstyle and just use a single style.

You should not do something like this. The "style" parameter is
reserved for the underlying wx.ScrolledWindow, while "ctstyle" is for
the TreeCtrl itself. Using a single style and setting up the things as
in the demo:

style=wx.SUNKEN_BORDER|CT.TR_HAS_BUTTONS|CT.TR_HAS_VARIABLE_ROW_HEIGHT

Will result in a clashing of styles between the tree and the
scrolledwindow, and you will experience the problem you exposed. Plus,
the Window style for the scrolledwindow is interfering with the tree
style. Just use the ctstyle parameter as it is, without setting the
style parameter if you are happy with the default behaviour of
wx.ScrolledWindow.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

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

Yes! It works just fine now.

Thanks!

···

On May 26, 2006, at 1:05 PM, Andrea Gavana wrote:

Hello John,

If I use

       self.tree = CT.CustomTreeCtrl(self, -1, ctstyle=wx.TR_HIDE_ROOT)

then I still see the problem on both Windows and Mac OS X: the scroll
bar set incorrectly.

   you are right, thanks for pointing this out. . I was calling twice
a recursive function when the style was TR_HIDE_ROOT, so the scrollbar
calculations were wrong. Could you please try the newer version
(downloadable from my website)? I have just uploaded it...

Thank you.

Andrea.

______________
John Jackson