Bug in TreeCtrl?

I noticed that wx.TR_TWIST_BUTTONS, wx.TR_ROW_LINES have no effect on the TreeCtrl's style. Also, using wx.TR_HIDE_ROOT raises an error with TreeCtrl. Strangely, TreeListCtrl has none of these problems. Are these bugs, or am I misusing the TreeCtrl in some way?

I'm using wx.TR_HIDE_ROOT without any problems, but I don't have the
latest release of wxPython. 2.4.1.2, gtk.

···

On Tue, 23 Mar 2004 01:00:45 -0500 Alex Zeiger <zeiger@nospam.snowbird.net> wrote:

I noticed that wx.TR_TWIST_BUTTONS, wx.TR_ROW_LINES have no effect on
the TreeCtrl's style. Also, using wx.TR_HIDE_ROOT raises an error with
TreeCtrl. Strangely, TreeListCtrl has none of these problems. Are
these bugs, or am I misusing the TreeCtrl in some way?

Alex Zeiger wrote:

I noticed that wx.TR_TWIST_BUTTONS, wx.TR_ROW_LINES have no effect on the TreeCtrl's style.

It depends on the platform. If you're on windows then the native treeview control is used and so the styles that it can't support will be ignored.

Also, using wx.TR_HIDE_ROOT raises an error with TreeCtrl.

What errors?

Strangely, TreeListCtrl has none of these problems.

Because it is generic code.

···

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

Scott wrote:

···

On Tue, 23 Mar 2004 01:00:45 -0500 > Alex Zeiger <zeiger@nospam.snowbird.net> wrote:

I noticed that wx.TR_TWIST_BUTTONS, wx.TR_ROW_LINES have no effect on the TreeCtrl's style. Also, using wx.TR_HIDE_ROOT raises an error with
TreeCtrl. Strangely, TreeListCtrl has none of these problems. Are
these bugs, or am I misusing the TreeCtrl in some way?

I'm using wx.TR_HIDE_ROOT without any problems, but I don't have the
latest release of wxPython. 2.4.1.2, gtk.

Yeah, I'm using 2.4.2.

Alex Zeiger wrote:

Also, using wx.TR_HIDE_ROOT raises an error with TreeCtrl.

What errors?

Here's the traceback:

    self.tree.SetPyData(self.root, data)

Aha. I encountered this before. IIRC, I seem to remember that if you are hiding the root item, don't try to manipulate it. I'm sure Robin will set me right if I'm off base :slight_smile:

... Rule of Acquisition #59: Free advice is seldom cheap.

Alex Zeiger wrote:

Robin Dunn wrote:

Also, using wx.TR_HIDE_ROOT raises an error with TreeCtrl.

What errors?

Here's the traceback:

[...]

    val = controls2c.wxTreeCtrl_SetPyData(self, *_args, **_kwargs)
wxPyAssertionError: C++ assertion "wxAssertFailure" failed in e:\Projects\wx2.4\src\msw\treectrl.cpp(750): can't retrieve virtual root item

As Jeff mentioned, you can't do anything with the root tree item in Windows. The native control doesn't allow it.

Strangely, TreeListCtrl has none of these problems.

Because it is generic code.

But isn't TreeListCtrl based on TreeCtrl and ListCtrl? You'd think it would inheret the problems of its parents.

Based on, but not derived from. The native tree and list controls on windows can't be used that way. The TreeListCtrl is a copy of the generic treectrl code used on non-MSW platforms and hacked to add-in the list ctrl functionality. I'd like to see the generic treectrl refactored such that the TreeListCtrl could be derived from it, but nobody has worked on it yet.

BTW, it looks like there will be a native verson of a control similar to the TreeListCtrl for GTK2 and OSX and that the current wxTreeCtrl and wxListCtrl may be reimplemented by using it so there will be native versions of those controls for those platforms. Should be interesting.

···

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

Jeff Grimmett wrote:

Robin Dunn wrote:

Also, using wx.TR_HIDE_ROOT raises an error with TreeCtrl.

As Jeff mentioned, you can't do anything with the root tree item in Windows. The native control doesn't allow it.

You mean "if using the wx.TR_HIDE_ROOT style flag" I hope,

Yes.

···

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