TR_HIDE_ROOT not working

Hi,

I need to create my own Treebook and so went ahead and used splitter window and a treectrl. In order for this to look right the root has to be hidden. If I use windows, then the only thing that looks right is using the customtreectrl, otherwise there wont be any + buttons next to items that has children in the tree. If I use linux, then TR_HIDE_ROOT doesn’t work on customtreectrl… but it works on the standard TreeCtrl.

Did I hit a bug here? and is there a way to go around it apart from the obvious of checking what system I’m on and take appropriate measures?.

I’ve attached an example. OptionsTree is the standard wx.TreeCtrl and ConfigTree is the customtreectrl… you can switch between the two by commenting the lines out in the frame.

Thanks,
Soren

treetest.py (1.94 KB)

Hi,

Hi,

I need to create my own Treebook and so went ahead and used splitter window
and a treectrl. In order for this to look right the root has to be hidden.
If I use windows, then the only thing that looks right is using the
customtreectrl, otherwise there wont be any + buttons next to items that has
children in the tree. If I use linux, then TR_HIDE_ROOT doesn't work on
customtreectrl.. but it works on the standard TreeCtrl.

Did I hit a bug here? and is there a way to go around it apart from the
obvious of checking what system I'm on and take appropriate measures?.

I've attached an example. OptionsTree is the standard wx.TreeCtrl and
ConfigTree is the customtreectrl.. you can switch between the two by
commenting the lines out in the frame.

For the CustomTreeCtrl you need to use the style flags defined in the
customtreectrl module not the standard wx ones (though they mostly
share the same names.) Also the later releases 2.8.10+ (IIRC) the AGW
widgets uses a different parameter for some of the custom styles
(agwStyle instead of style).

CT.CustomTreeCtrl(self, ..., agwStyle=CT.TR_HIDE_ROOT|CT.TR_HAS_BUTTONS)

Cody

···

2010/8/3 Søren Nielsen <soren.skou.nielsen@gmail.com>:

Ah it has its own flags… ok thanks!!

Soren

···

On Tue, Aug 3, 2010 at 9:13 AM, Cody Precord codyprecord@gmail.com wrote:

Hi,

2010/8/3 Søren Nielsen soren.skou.nielsen@gmail.com:

Hi,

I need to create my own Treebook and so went ahead and used splitter window

and a treectrl. In order for this to look right the root has to be hidden.

If I use windows, then the only thing that looks right is using the

customtreectrl, otherwise there wont be any + buttons next to items that has

children in the tree. If I use linux, then TR_HIDE_ROOT doesn’t work on

customtreectrl… but it works on the standard TreeCtrl.

Did I hit a bug here? and is there a way to go around it apart from the

obvious of checking what system I’m on and take appropriate measures?.

I’ve attached an example. OptionsTree is the standard wx.TreeCtrl and

ConfigTree is the customtreectrl… you can switch between the two by

commenting the lines out in the frame.

For the CustomTreeCtrl you need to use the style flags defined in the

customtreectrl module not the standard wx ones (though they mostly

share the same names.) Also the later releases 2.8.10+ (IIRC) the AGW

widgets uses a different parameter for some of the custom styles

(agwStyle instead of style).

CT.CustomTreeCtrl(self, …, agwStyle=CT.TR_HIDE_ROOT|CT.TR_HAS_BUTTONS)

Cody

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

For the CustomTreeCtrl you need to use the style flags defined in the

customtreectrl module not the standard wx ones (though they mostly

share the same names.) Also the later releases 2.8.10+ (IIRC) the AGW

widgets uses a different parameter for some of the custom styles

(agwStyle instead of style).

CT.CustomTreeCtrl(self, …, agwStyle=CT.TR_HIDE_ROOT|CT.TR_HAS_BUTTONS)

Cody

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Btw, Is there a reason that TR_HAS_BUTTONS doesn’t work on Windows with the standard wx.TreeCtrl when TR_HIDE_ROOT is also enabled?

Soren

Hi,

For the CustomTreeCtrl you need to use the style flags defined in the
customtreectrl module not the standard wx ones (though they mostly
share the same names.) Also the later releases 2.8.10+ (IIRC) the AGW
widgets uses a different parameter for some of the custom styles
(agwStyle instead of style).

CT.CustomTreeCtrl(self, ..., agwStyle=CT.TR_HIDE_ROOT|CT.TR_HAS_BUTTONS)

Cody

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Btw, Is there a reason that TR_HAS_BUTTONS doesn't work on Windows with the
standard wx.TreeCtrl when TR_HIDE_ROOT is also enabled?

You need to set which items have children in order for the buttons to show:

Call:

wx.TreeCtrl.SetItemHasChildren(parent_treeitem, True)

After adding a child to a node. Not a 100% sure why this is necessary
it seems that it should happen automatically when a child is added to
a node. Would think this would only be necessary when virtualizing the
tree.

Cody

···

2010/8/3 Søren Nielsen <soren.skou.nielsen@gmail.com>:

Thanks Cody!

···

On Tue, Aug 3, 2010 at 10:14 AM, Cody Precord codyprecord@gmail.com wrote:

Hi,

2010/8/3 Søren Nielsen soren.skou.nielsen@gmail.com:

For the CustomTreeCtrl you need to use the style flags defined in the

customtreectrl module not the standard wx ones (though they mostly

share the same names.) Also the later releases 2.8.10+ (IIRC) the AGW

widgets uses a different parameter for some of the custom styles

(agwStyle instead of style).

CT.CustomTreeCtrl(self, …, agwStyle=CT.TR_HIDE_ROOT|CT.TR_HAS_BUTTONS)

Cody

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Btw, Is there a reason that TR_HAS_BUTTONS doesn’t work on Windows with the

standard wx.TreeCtrl when TR_HIDE_ROOT is also enabled?

You need to set which items have children in order for the buttons to show:

Call:

wx.TreeCtrl.SetItemHasChildren(parent_treeitem, True)

After adding a child to a node. Not a 100% sure why this is necessary

it seems that it should happen automatically when a child is added to

a node. Would think this would only be necessary when virtualizing the

tree.

Cody

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

hmm, that isn’t working for me :confused:

tried it on the example Soren provided, adding at the end of init:

wx.TreeCtrl.SetItemHasChildren(self, child, True)

and also tried (without success):
self.SetItemHasChildren(child, True)

I guess for now I’ll use the customtreectrl, thanks for that example, seems like it will get the job done!

···

On Tuesday, August 3, 2010 7:14:22 AM UTC-7, Cody Precord wrote:

You need to set which items have children in order for the buttons to show:

Call:

wx.TreeCtrl.SetItemHasChildren(parent_treeitem, True)

Oh, I just found that adding:
wx.TR_LINES_AT_ROOT

to the styles allows the + to be shown, though I guess the lines might not always be desired!

···

On Thursday, April 17, 2014 4:32:27 PM UTC-7, Nathan McCorkle wrote:

On Tuesday, August 3, 2010 7:14:22 AM UTC-7, Cody Precord wrote:

You need to set which items have children in order for the buttons to show:

Call:

wx.TreeCtrl.SetItemHasChildren(parent_treeitem, True)

hmm, that isn’t working for me :confused:

tried it on the example Soren provided, adding at the end of init:

wx.TreeCtrl.SetItemHasChildren(self, child, True)

and also tried (without success):
self.SetItemHasChildren(child, True)

I guess for now I’ll use the customtreectrl, thanks for that example, seems like it will get the job done!