ANN: CustomTreeCtrl For wxPython ;-)

Hello NG,
I would like to announce my latest child, CustomTreeCtrl.

CustomTreeCtrl is a class that mimics the behavior of wx.TreeCtrl, 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 control.

Apart of the base functionalities of CustomTreeCtrl (described below), in addition to the standard wx.TreeCtrl behavior this class supports:

  • CheckBox-type items;

  • RadioButton-type items;

  • 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 an item;

  • Default selection style, gradient (horizontal/vertical) selection style and Windows Vista selection style;

  • Customized drag and drop images built on the fly;

  • Setting the CustomTreeCtrl item buttons to a personalized imagelist;

  • Setting the CustomTreeCtrl 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 CustomTreeCtrl 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 one, 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 CustomTreeCtrl 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 long, 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.3/2.4 and wxPython 2.6.3.2. 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.

You can find the source, the demo, the epydoc-generated documentation and some screenshots 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

Enjoy, and happy wxPythoning :wink:

Andrea.

P.S. Please don’t tell me it’s not Pythonic… it doesn’t mean anything to me, plus the code is heavily based on the C++ generic wxWidgets implementation :slight_smile:

···


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

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

On the Mac, CustomTreeCtrl.py is broken at line 1822. It should be

platform, major, minor = wx.GetOsVersion()

It will then run the demo. But it throws an exception:

LosOlivos:~/Downloads/CustomTreeCtrl/CustomTreeCtrl jjackson$ pythonw CTDemo.py

Traceback (most recent call last):

File “/Users/jjackson/Downloads/CustomTreeCtrl/CustomTreeCtrl/CustomTreeCtrl.py”, line 4494, in OnPaint

self.PaintLevel(self._anchor, dc, 0, y)

File “/Users/jjackson/Downloads/CustomTreeCtrl/CustomTreeCtrl/CustomTreeCtrl.py”, line 4321, in PaintLevel

pen = wx.Pen(((item.IsSelected() and self._hasFocus) and [self._borderPen] or [wx.TRANSPARENT])[0])

File “//Library/Python/2.3/wx-2.6-mac-ansi/wx/_gdi.py”, line 322, in init

newobj = gdi.new_Pen(*args, **kwargs)

TypeError: Expected a wxColour object or a string containing a colour name or ‘#RRGGBB’.

The tree doesn’t show at all on the Mac, and the buttons on the left don’t arrange properly after scrolling. Looks like a sizer problem for the buttons.

Shouldn’t the “Themes” buttons be a radio set rather than check buttons, as one of the themes is always active?

(I’ll send a screen shot to Andrea directly.)

···

On May 18, 2006, at 3:10 PM, Andrea Gavana wrote:

Hello NG,
I would like to announce my latest child, CustomTreeCtrl.

I tested the code on Windows XP, Python 2.3/2.4 and wxPython 2.6.3.2. 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.


John Jackson

Andrea Gavana wrote:

Hello NG,
   I would like to announce my latest child, CustomTreeCtrl.

WOW, fantastic control Andrea!
On linux (deb 3.1 + wx 2.6.x) all work except into the left side of demo where I see the buttons cut:

www.unipex.it/vario/problem_wx.png

Bye,
Michele

Hello Andrea,

i agree totally with Michele,

simply wow, such a complex and vast demo in addition!
and also the documentation.

One sentence about the control: the cursor movment is not optimal.
Waht I mean is (on Windows XP):
Start the demo => cursor down (item0 is marked), press cursor right to open
the subbranch => cursor down (item0-a is active) => cursor right.

1) So now if you press cursor down, nothing happens (I would expect to select item0-b.
2) if you press cursor left, I would expect to close the current branch but it jump to item0.

It could be of course:
1) it is intended to work so.
2) I oversaw some settings switch to adjust this.

You should have the wxPython contribution award (at least for the second quarter
of 2006 beside Robin of course) for your work! :slight_smile:

I think the wxWidgets users could be becoming envious
to see alle the wxPython controls you and some others
have created.

The Python binding can soon more than the C++ wxWidgets itself!!! :slight_smile:

···

On Fri, 19 May 2006 00:10:43 +0200, "Andrea Gavana" <andrea.gavana@gmail.com> wrote:

Hello NG,
   I would like to announce my latest child, CustomTreeCtrl.

CustomTreeCtrl is a class that mimics the behavior of wx.TreeCtrl, 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
control.

--

Franz Steinhaeusler

Andrea Gavana wrote:

Hello NG,
    I would like to announce my latest child, CustomTreeCtrl.

All I can say is, "Wow!"

Ok ok, maybe I can say a bit more. :wink:

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've seen it happen in a few other apps too, although not quite as bad, so it may be some funky configuration issue for my system. but it would still be nice to figure out why it happens and see if a workaround would be possible.

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.

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.

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.

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.

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

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.

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

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

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

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

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

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.

Uh oh... I just noticed that you do it the same way as the generic C++ tree control, so wxMac has the same problem there too!

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hello Robin & NG,

All I can say is, “Wow!”

Hehehehehe, this is probably the first time that you say “wow” to one of my controls :slight_smile:

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?

Yes, there is a constant call to self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) to try to handle the hyperlink items. I will see if I can get rid of it.

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.

Ok, I will do it.

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.

Ah, another Mac surprise… I have never used wx.lib.colourselect, I will give it a try.

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.

Mhm, this is not very clear to me… do you mean I should get rid of all the:

wxEVT_TREE_ITEM_HYPERLINK = wx.NewEventType()

And:

EVT_TREE_BEGIN_DRAG = wx.PyEventBinder(wxEVT_TREE_BEGIN_DRAG, 1)

? (I put these events as an example). Should I remove all of them? And what about the events that does not exist in wx, like wxEVT_TREE_ITEM_CHECKING and wxEVT_TREE_ITEM_HYPERLINK? I would end up in having mixed things, like wx.EVT_TREE_SEL_CHANGED and CustomTreeCtrl.EVT_TREE_ITEM_HYPERLINK in the demo and in the applications that used this control… or have I misunderstood what you meant?

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.

Mhm, ok, I will change things like NO_IMAGE to _NO_IMAGE.

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

Not at the moment, but I was thinking about it… the problem is that the spacebar char is already used to send wxEVT_TREE_ITEM_ACTIVATED together with the return key… should I use the spacebar also to check the check/radio items and sending the appropriate event?

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.

No problem, will do it.

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

Ok, I will make a switch to do that on Mac, because on Windows I like the dashed pen.

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

Ah, I am sorry for that, I am still to used in writing docstrings that way, but I understand that is wrong. I will change them accordingly.

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

Ok, will do it.

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

Thank you, I am happy to contribute to the community… I only wish that, if someone makes improvements/patches to those owner-drawn controls, he/she will contribute them back.

Thank you very much for your useful comments!

Andrea.

Andrea Gavana wrote:

Hello Robin & NG,
  >All I can say is, "Wow!"

Hehehehehe, this is probably the first time that you say "wow" to one of my controls :slight_smile:
  >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?
Yes, there is a constant call to self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) to try to handle the hyperlink items. I will see if I can get rid of it.

Ah, I didn't look in that part. You can probably set a flag or two that will help you only change the cursor when entering or leaving the area where a hyperlink item is located.

>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.
Mhm, this is not very clear to me... do you mean I should get rid of all

Not get rid of them, just initialize them from their wx counterparts so they have the same values. Like this:

wxEVT_TREE_BEGIN_DRAG = wx.wxEVT_TREE_BEGIN_DRAG

and

EVT_TREE_BEGIN_DRAG = wx.EVT_TREE_BEGIN_DRAG

> And

what about the events that does not exist in wx, like

Leave them as they are.

> Is there a way to toggle check or radio items with the keyboard?
Not at the moment, but I was thinking about it... the problem is that the spacebar char is already used to send wxEVT_TREE_ITEM_ACTIVATED together with the return key... should I use the spacebar also to check the check/radio items and sending the appropriate event?

I think that is what most people would expect.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hello Robin,

thank you for your suggestions. I am probably missing something here:

Not get rid of them, just initialize them from their wx counterparts so
they have the same values. Like this:

wxEVT_TREE_BEGIN_DRAG = wx.wxEVT_TREE_BEGIN_DRAG

and

EVT_TREE_BEGIN_DRAG = wx.EVT_TREE_BEGIN_DRAG

import wx
wx.wxEVT_TREE_BEGIN_DRAG

Traceback (most recent call last):
File “”, line 1, in ?
AttributeError: ‘module’ object has no attribute ‘wxEVT_TREE_BEGIN_DRAG’

Huh??? None of the wx.wxEVT_TREE* exist… I am surely misunderstanding something…

···


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

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

Me too. I tried to fix this, and ended up with this (there are three new event types):

wxEVT_TREE_BEGIN_DRAG = wx.EVT_TREE_BEGIN_DRAG.evtType[0]
...
wxEVT_TREE_ITEM_MENU = wx.EVT_TREE_ITEM_MENU.evtType[0]
wxEVT_TREE_ITEM_CHECKING = wx.NewEventType()
wxEVT_TREE_ITEM_CHECK = wx.NewEventType()
wxEVT_TREE_ITEM_HYPERLINK = wx.NewEventType()

and

EVT_TREE_BEGIN_DRAG = wx.EVT_TREE_BEGIN_DRAG
...
EVT_TREE_ITEM_MENU = wx.EVT_TREE_ITEM_MENU
EVT_TREE_ITEM_CHECKING = wx.PyEventBinder(wxEVT_TREE_ITEM_CHECKING, 1)
EVT_TREE_ITEM_CHECK = wx.PyEventBinder(wxEVT_TREE_ITEM_CHECK, 1)
EVT_TREE_ITEM_HYPERLINK = wx.PyEventBinder(wxEVT_TREE_ITEM_HYPERLINK, 1)

I've also run into these problems -- I'm trying to use the control as a drop-in replacement for wxTreeCtrl:

-- There's no IsOk method: (maybe no longer needed):

     def IsOk(self):
         """ Returns Whether The Item Is Ok Or Not. """

         return True

-- TRs needed redefining:

TR_MULTIPLE = wx.TR_MULTIPLE
TR_HAS_BUTTONS = wx.TR_HAS_BUTTONS
TR_HIDE_ROOT = wx.TR_HIDE_ROOT
TR_FULL_ROW_HIGHLIGHT = wx.TR_FULL_ROW_HIGHLIGHT

-- In the demo, if you hide the root, and then push the recreate button:

[Session started at 2006-05-20 06:29:12 -0700.]
Traceback (most recent call last):
   File "CTDemo.py", line 1079, in OnRecreateTree
     self.tree = CustomTreeCtrl(self.treeParentPanel, -1, log=self.log)
   File "CTDemo.py", line 1594, in __init__
     self.Expand(self.root)
   File "/Volumes/Banff-5/2983/beta 1.0.9.5 build 1095/CustomTreeCtrl/CustomTreeCtrl.py", line 3391, in Expand
     raise "\nERROR: Can't Expand An Hidden Root. "

ERROR: Can't Expand An Hidden Root.

  if something goes wrong in the demo, it doesn't recover very well because the tree gets destroyed in OnRecreate:

     def OnRecreateTree(self, event):
  ...

I've added things such as:

     def OnCheckStyle(self, event):
         if hasattr(self, 'tree'):
             self.tree.ChangeStyle(self.treestyles)
         event.Skip()

but that doesn't always solve the problem.

I haven't been able to get drag 'n drop working.

···

On May 20, 2006, at 6:12 AM, Andrea Gavana wrote:

Hello Robin,

    thank you for your suggestions. I am probably missing something here:

>Not get rid of them, just initialize them from their wx counterparts so
>they have the same values. Like this:
>
>wxEVT_TREE_BEGIN_DRAG = wx.wxEVT_TREE_BEGIN_DRAG
>
>and
>
>EVT_TREE_BEGIN_DRAG = wx.EVT_TREE_BEGIN_DRAG

>>> import wx
>>> wx.wxEVT_TREE_BEGIN_DRAG
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
AttributeError: 'module' object has no attribute 'wxEVT_TREE_BEGIN_DRAG'

Huh?!?!? None of the wx.wxEVT_TREE* exist... I am surely misunderstanding something...

______________
John Jackson

I've started using the control in my project, and I found that you have changed a couple of methods for

     SetItemPyData = SetPyData
     GetItemPyData = GetPyData

Since it would be nice if this were a drop-in replacement for the wx control, perhaps add these two lines?

···

On May 19, 2006, at 4:23 PM, Andrea Gavana wrote:

______________
John Jackson

Hello John,

thanks for the info on the events. I will modify them.

I’ve also run into these problems – I’m trying to use the control as
a drop-in replacement for wxTreeCtrl:

– There’s no IsOk method: (maybe no longer needed):

You don’t need it anymore. It does not make any sense in Python to check if an item is Ok or not: if the item exist, then it is Ok, otherwise you will get “None” as answer. In this respect, every time that you wrote something like this in wx.TreeCtrl:

if item.IsOk():

do something

Now you will have in CustomTreeCtrl:

if item:

do something

– TRs needed redefining:

TR_MULTIPLE = wx.TR_MULTIPLE
TR_HAS_BUTTONS = wx.TR_HAS_BUTTONS
TR_HIDE_ROOT = wx.TR_HIDE_ROOT
TR_FULL_ROW_HIGHLIGHT = wx.TR_FULL_ROW_HIGHLIGHT

Yes, Robin already suggested it, I am doing the conversion right now.

– In the demo, if you hide the root, and then push the recreate button:

Traceback (most recent call last):
File “CTDemo.py”, line 1079, in OnRecreateTree
self.tree
= CustomTreeCtrl(self.treeParentPanel, -1, log=self.log)
File “CTDemo.py”, line 1594, in init
self.Expand(self.root)
File “/Volumes/Banff-5/2983/beta
1.0.9.5
build 1095/CustomTreeCtrl/
CustomTreeCtrl.py”, line 3391, in Expand
raise "\nERROR: Can’t Expand An Hidden Root. "

ERROR: Can’t Expand An Hidden Root.

Yes, this was a flaw in my demo: before calling self.Expand(self.root), I should check if the control has TR_HIDE_ROOT flag activated. It just take an “if” condition to do that. I will do it.

I haven’t been able to get drag 'n drop working.

Ah, this one I don’t know… here it is working. Do you see the “Beginning Drag…” text string in the log window whan you start dragging? Have you enabled the events EVT_TREE_BEGIN_DRAG and EVT_TREE_END_DRAG in the checkboxes?

I’ve started using the control in my project, and I found that you
have changed a couple of methods for

SetItemPyData = SetPyData
GetItemPyData = GetPyData

Since it would be nice if this were a drop-in replacement for the wx

control, perhaps add these two lines?

That’s the first time that I have heard about SetItemPyData and GetItemPyData. I always use SetPyData and GetPyData. The wxPython demo uses them, and also the docs shows that:

void SetItemData(const wxTreeItemId& item, wxTreeItemData* data)

Sets the item client data.

wxPython note: wxPython provides the following shortcut method:
SetPyData(item, obj) Associate the given Python Object with the wxTreeItemData for the given item Id.

I see that the two methods you mentioned actually exist, so I will add them.

Andrea.

I should correct this. I haven't been able to get it working in my code, where I've dropped in your control.

It does work in the demo, at least as far as the drag. I don't see the drop working -- the order of the items isn't changing. Is that because it isn't implemented in the demo?

···

On May 20, 2006, at 6:51 AM, Andrea Gavana wrote:

>I haven't been able to get drag 'n drop working.

Ah, this one I don't know... here it is working. Do you see the "Beginning Drag..." text string in the log window whan you start dragging? Have you enabled the events EVT_TREE_BEGIN_DRAG and EVT_TREE_END_DRAG in the checkboxes?

______________
John Jackson

Andrea,

OK, I found what I was doing. For some reason, in the wx.TreeCtrl, the begin drag handler only required an event.Allow() to work. It worked without an event.Skip().

Adding an event.Skip() solved the problem.

But I'm wondering if this is the correct design -- shouldn't event.Allow() be enough?

···

On May 20, 2006, at 8:57 AM, John Jackson wrote:

I should correct this. I haven't been able to get it working in my code, where I've dropped in your control.

It does work in the demo, at least as far as the drag. I don't see the drop working -- the order of the items isn't changing. Is that because it isn't implemented in the demo?

On May 20, 2006, at 6:51 AM, Andrea Gavana wrote:

>I haven't been able to get drag 'n drop working.

Ah, this one I don't know... here it is working. Do you see the "Beginning Drag..." text string in the log window whan you start dragging? Have you enabled the events EVT_TREE_BEGIN_DRAG and EVT_TREE_END_DRAG in the checkboxes?

______________
John Jackson

Hello John,

It does work in the demo, at least as far as the drag. I don’t see
the drop working – the order of the items isn’t changing. Is that
because it isn’t implemented in the demo?

Correct. I have not implemented the actual operation that the DnD should do. To do that, I should take some code from the wiki and implement the actual DnD operation… I don’t think this is strictly related to the control itself…

Andrea.

···


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

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

Hello John,

Adding an event.Skip() solved the problem.

But I’m wondering if this is the correct design – shouldn’t
event.Allow() be enough?

I don’t know, I have never used DnD in wx.TreeCtrl. The implementation of CustomTreeCtrl in this respect is the same as the generic C++ version of wx.TreeCtrl… maybe Robin could explain better which the default behaviour should be…

Andrea.

···


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

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

Andrea Gavana wrote:

Hello Robin,
     thank you for your suggestions. I am probably missing something here:

>Not get rid of them, just initialize them from their wx counterparts so
>they have the same values. Like this:
>
>wxEVT_TREE_BEGIN_DRAG = wx.wxEVT_TREE_BEGIN_DRAG
>
>and
>
>EVT_TREE_BEGIN_DRAG = wx.EVT_TREE_BEGIN_DRAG
  >>> import wx
>>> wx.wxEVT_TREE_BEGIN_DRAG
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
AttributeError: 'module' object has no attribute 'wxEVT_TREE_BEGIN_DRAG'
Huh?!?!? None of the wx.wxEVT_TREE* exist... I am surely misunderstanding something...

No, it was my fault. I had forgotten that the tree event constants in the wx package all have a _COMMAND_ in the name. Here is the full list:

%constant wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG;
%constant wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG;
%constant wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT;
%constant wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT;
%constant wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM;
%constant wxEventType wxEVT_COMMAND_TREE_GET_INFO;
%constant wxEventType wxEVT_COMMAND_TREE_SET_INFO;
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED;
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING;
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED;
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING;
%constant wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED;
%constant wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING;
%constant wxEventType wxEVT_COMMAND_TREE_KEY_DOWN;
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED;
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK;
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK;
%constant wxEventType wxEVT_COMMAND_TREE_END_DRAG;
%constant wxEventType wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK;
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP;
%constant wxEventType wxEVT_COMMAND_TREE_ITEM_MENU;

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Andrea Gavana wrote:

>I've started using the control in my project, and I found that you
>have changed a couple of methods for
>
> SetItemPyData = SetPyData
> GetItemPyData = GetPyData
>
>Since it would be nice if this were a drop-in replacement for the wx
>control, perhaps add these two lines?
That's the first time that I have heard about SetItemPyData and GetItemPyData. I always use SetPyData and GetPyData. The wxPython demo uses them, and also the docs shows that:

The Get/SetItemPyData were added a while back in order to be more consistent with the names of other methods, and the Get/SetPyData were left as aliases for compatibility.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Andrea Gavana wrote:

Hello John,
  >Adding an event.Skip() solved the problem.
>
>But I'm wondering if this is the correct design -- shouldn't
>event.Allow() be enough?
I don't know, I have never used DnD in wx.TreeCtrl. The implementation of CustomTreeCtrl in this respect is the same as the generic C++ version of wx.TreeCtrl... maybe Robin could explain better which the default behaviour should be...

I think you may have misread the generic treectrl code. It has this line:

  if ( GetEventHandler()->ProcessEvent(nevent) && nevent.IsAllowed() )

And you have this:

  if not self.GetEventHandler().ProcessEvent(nevent) and nevent.IsAllowed():

So you need to drop the "not". The code is different, but the MSW treectrl behaves the same way.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin, that was great. Fixed things up.

Andrea, thanks for the great control. It's working very nicely. I've been able to fix the problems I was having with the C++ native control.

···

On May 20, 2006, at 9:45 AM, Robin Dunn wrote:

Andrea Gavana wrote:

Hello John,
  >Adding an event.Skip() solved the problem.
>
>But I'm wondering if this is the correct design -- shouldn't
>event.Allow() be enough?
I don't know, I have never used DnD in wx.TreeCtrl. The implementation of CustomTreeCtrl in this respect is the same as the generic C++ version of wx.TreeCtrl... maybe Robin could explain better which the default behaviour should be...

I think you may have misread the generic treectrl code. It has this line:

  if ( GetEventHandler()->ProcessEvent(nevent) && nevent.IsAllowed() )

And you have this:

  if not self.GetEventHandler().ProcessEvent(nevent) and nevent.IsAllowed():

So you need to drop the "not". The code is different, but the MSW treectrl behaves the same way.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

______________
John Jackson