ANN: CustomTreeCtrl For wxPython ;-)

Hello NG,

  thank you for your answers :slight_smile:

From: news [mailto:news@sea.gmane.org] On Behalf Of Franz
Steinhaeusler

<snip>

1) So now if you press cursor down, nothing happens (I would
expect to select item0-b.

Yes, you are right. The problem is, in a normal wx.TreeCtrl, you don't have inactive items, so pressing cursor down would simply select item0-a-0. In the demo, this item is inactive (because its parent is a radiobutton non selected), so it should jump to the next active sibling. I am trying to find a way to efficiently implement some method like GetNextActiveItem() to handle that. I am working on it.

2) if you press cursor left, I would expect to close the
current branch but it jump to item0.

Right, this is the default behavior on MSW and, unless I am missing something, the C++ implementation is buggy here. I have fixed it now, thanks.

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

Hehehehehehe, thank you... Unfortunately, I don't think that such award exists ;-). I was in the need of having a TreeCtrl with radio and check buttons: I started by tweaking the Ricardo's CheckTreeCtrl , but I was unable to adapt it to my needs. So I started implementing this new control and, as usual when I code new things, I became an overblown coder :wink:

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

I think it already is... Not only for the contributions: Python itself is infinitely superior to C++, so coding in Python can be a joy while doing it in C++ can easily turn into a PITA... Not talking about compiling, debugging, spot the errors, recompiling... That's a nightmare :slight_smile:

From: Michele Petrazzo [mailto:michele.petrazzo@unipex.it]
On linux (deb 3.1 + wx 2.6.x) all work except into the left
side of demo where I see the buttons cut:

Thanks for this Michele, I think I have fixed it now. Unfortunately, I can't test it because I don't have a *nix machine. If it's possible, I would like to ask you if you can please send me a screenshot of the control... The picture in that web site doesn't show the tree control itself, only the problem with the demo. I am interested in seeing the control expanded to show the attached windows. Thank you.

From: John Jackson [mailto:jjackson@pobox.com]
On the Mac, CustomTreeCtrl.py is broken at line 1822. It should be

           platform, major, minor = wx.GetOsVersion()

Thanks, fixed it.

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'.

Thank you, that was my misenterpretation of the C++ code. I have fixed it now.

The tree doesn't show at all on the Mac

I was expecting that, as usual. I wonder why Mac is *so* hostile versus owner-drawn controls. In every new control (as PyAUI, NotebookCtrl, and so on), the most awkward "if" switches are there just to keep Mac running. Platform independency and Apple are surely not synonyms.

and the buttons on the left don't arrange properly after scrolling.
Looks like a sizer problem for the buttons.

This seems to me a wxMac bug. Here I don't see any problem, and from the screenshot Michele posted, also on GTK everything seems to work fine for the checkboxes on the left. Sounds like you can't correctly put controls in a wx.StaticBoxSizer inside a wx.ScrolledWindow.

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

Mhm... Does that disturb you so much? By using radiobuttons I would end up having nested RB_GROUP radiobuttons, which I prefer to avoid.

Thanks to everyone for your comments! And please, if you can, I would appreciate to receive a screenshot of the control running on your machine :wink: . I am just curious, nothing more.

Andrea.

···

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Hi Andrea,

[snip]

The tree doesn't show at all on the Mac

I was expecting that, as usual. I wonder why Mac is *so* hostile versus owner-drawn controls. In every new control (as PyAUI, NotebookCtrl, and so on), the most awkward "if" switches are there just to keep Mac running. Platform independency and Apple are surely not synonyms.

It's not totally Mac's fault here - the issue is that wx generic controls were often built before Mac was around, and never really made to work with Mac,. Plus, there is Mac OS 9 and OS X which are very different. For example, a generic control may not consider that the native control has a highlight around it, and when it invalidates the region, it doesn't invalidate a large enough region (say, on OS X) to get the highlight erased too. Or that the default size of the editable text ctrl that wxListCtrl pops up is bigger than on other platforms, but wxListCtrl assumes a certain size. Lots of little details like that. A big aspect of all this is that most of the generic control developers don't have Macs, and/or don't test on them often. ;-/ I'm pretty sure we'd have similar problems with Win/Linux if they got that same amount of exposure and testing...

BTW, if you're curious, the way to do this on Mac would be to use the OS X DataBrowser control, which would allow you to create "owner drawn" controls based around tree/list controls and is very flexible. You can also add in native controls, like progress bars, and the OS will handle the drawing/invalidation issues. The problem is, wx hasn't wrapped the DataBrowser control yet, and there've been debates about whether wxListCtrl/wxTreeCtrl should be implemented using it. (The new wxDataViewCtrl will most certainly use it, whenever someone gets around to finishing that...) I wish someone would implement these controls using the DataBrowser, because the 'generic' wxTreeCtrl and wxListCtrl just have so many little glitches in them that using the DataBrowser control would fix, and it would make the list/tree controls *so* much slicker on OS X to boot.

Anyways, sorry for the rant. :wink: But I just wanted to point out that yes, Mac is different, but that it's not that there aren't solutions to make these things work well. It's just that what we're really doing, in many cases, is porting the "Windows/Linux way" over to Mac, rather than designing with Mac in mind (<cough>MDI/DocView</cough>), which is somewhat like using Babelfish to translate. :wink: You might be able to get the gist, but it certainly looks awkward. :wink:

Regards,

Kevin

···

On May 19, 2006, at 2:19 AM, Gavana, Andrea wrote:

and the buttons on the left don't arrange properly after scrolling.
Looks like a sizer problem for the buttons.

This seems to me a wxMac bug. Here I don't see any problem, and from the screenshot Michele posted, also on GTK everything seems to work fine for the checkboxes on the left. Sounds like you can't correctly put controls in a wx.StaticBoxSizer inside a wx.ScrolledWindow.

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

Mhm... Does that disturb you so much? By using radiobuttons I would end up having nested RB_GROUP radiobuttons, which I prefer to avoid.

Thanks to everyone for your comments! And please, if you can, I would appreciate to receive a screenshot of the control running on your machine :wink: . I am just curious, nothing more.

Andrea.

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: 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

Andrea's changes fixed the problems with the display of the tree on the Mac. Looks great. Do you need a screen snapshot?

and the buttons on the left don't arrange properly after scrolling.
Looks like a sizer problem for the buttons.

This seems to me a wxMac bug. Here I don't see any problem, and from the screenshot Michele posted, also on GTK everything seems to work fine for the checkboxes on the left. Sounds like you can't correctly put controls in a wx.StaticBoxSizer inside a wx.ScrolledWindow.

The problems with the demo's CustomTreeCtrl Styles checkboxes are a wxMac bug. I played around with the code, and always the fifth item is the one that greats messed up. A resize event always clears it.

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

Mhm... Does that disturb you so much? By using radiobuttons I would end up having nested RB_GROUP radiobuttons, which I prefer to avoid.

It is bothersome, because that's what radio buttons are for: to indicate that one, and only one, of a group is selected. Checkboxes are independent, unless they are used in a hierarchy.

Does your control properly handle KeyEvents passed with EVT_TREE_SEL_CHANGING? The wxTreeCtrl has a long-standing (one year) bug that it doesn't pass Shift/Ctrl/Alt as part of the KeyEvents. (Hint to Robin: any idea when that might get fixed? I was going to use it...)

Thanks for the new control!

···

On May 19, 2006, at 2:19 AM, Gavana, Andrea wrote:
______________
John Jackson

John Jackson wrote:

Does your control properly handle KeyEvents passed with EVT_TREE_SEL_CHANGING? The wxTreeCtrl has a long-standing (one year) bug that it doesn't pass Shift/Ctrl/Alt as part of the KeyEvents. (Hint to Robin: any idea when that might get fixed? I was going to use it...)

I don't know. I haven't heard about anybody working on it. Is there a bug report for it?

···

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

The bug report is #1244537, assigned to a Robin Dunn. :slight_smile:

I have checked Andrea's source and he hasn't implemented it either. I think I can work around it by binding to key press events.

···

On May 19, 2006, at 12:17 PM, Robin Dunn wrote:

John Jackson wrote:

Does your control properly handle KeyEvents passed with EVT_TREE_SEL_CHANGING? The wxTreeCtrl has a long-standing (one year) bug that it doesn't pass Shift/Ctrl/Alt as part of the KeyEvents. (Hint to Robin: any idea when that might get fixed? I was going to use it...)

I don't know. I haven't heard about anybody working on it. Is there a bug report for it?

--
Robin Dunn

______________
John Jackson

John Jackson wrote:

John Jackson wrote:

Does your control properly handle KeyEvents passed with EVT_TREE_SEL_CHANGING? The wxTreeCtrl has a long-standing (one year) bug that it doesn't pass Shift/Ctrl/Alt as part of the KeyEvents. (Hint to Robin: any idea when that might get fixed? I was going to use it...)

I don't know. I haven't heard about anybody working on it. Is there a bug report for it?

--Robin Dunn

The bug report is #1244537, assigned to a Robin Dunn. :slight_smile:

Oops! Thanks.

···

On May 19, 2006, at 12:17 PM, Robin Dunn wrote:

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

Hello John,

Andrea’s changes fixed the problems with the display of the tree on
the Mac. Looks great. Do you need a screen snapshot?

I am happy you liked it :slight_smile: Yes, if you could send me a screenshot with the tree expanded to show the controls, it would be nice.

Does your control properly handle KeyEvents passed with
EVT_TREE_SEL_CHANGING? The wxTreeCtrl has a long-standing (one year)
bug that it doesn’t pass Shift/Ctrl/Alt as part of the KeyEvents.

Mhm, I didn’t know anything about that bug, what the shift/ctrl/alt are supposed to do? For multiple item selection? Or something else?

Andrea.

Hello John,

>Andrea's changes fixed the problems with the display of the tree on
>the Mac. Looks great. Do you need a screen snapshot?

I am happy you liked it :slight_smile: Yes, if you could send me a screenshot with the tree expanded to show the controls, it would be nice.

A screenshot from the Mac is at http://www.sonic.net/~jginc/software/mac_customtreectrl.jpg

>Does your control properly handle KeyEvents passed with
>EVT_TREE_SEL_CHANGING? The wxTreeCtrl has a long-standing (one year)
>bug that it doesn't pass Shift/Ctrl/Alt as part of the KeyEvents.

Mhm, I didn't know anything about that bug, what the shift/ctrl/alt are supposed to do? For multiple item selection? Or something else?

It should (I think) include a KeyEvent in with the event, so one can test if the modifier keys are down. You should be able to get the event, call GetKeyEvent() on it, and then call the KeyEvent methods to get the information you need.

It goes in your code around line 3554, where you say:

# TODO : Here we don't send any selection mode yet !

···

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

______________
John Jackson