Root of TreeControl

Hi there,

Thanks for your comment.

This is what Í'm doing I guess, but it won't work.
Would you be so kinf to have a look at the code?

Except for setting images and data on the root node, it looks like it
should work. Where are you getting exceptions (if any)?

- Josiah

···

"Math" <mathweijzen@home.nl> wrote:

import wx

#-------------------------------------------------------------------------
class MyTreeCtrl(wx.TreeCtrl):
    def __init__(self, parent, id, pos, size, style):
        wx.TreeCtrl.__init__(self, parent, id, pos, size, style)
#---------------------------------------------------------------------------

class TestTreeCtrlPanel(wx.Panel):
    def __init__(self, parent):
        # Use the WANTS_CHARS style so the panel doesn't eat the Return key.
        wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        
        tID = wx.NewId()

        self.tree = MyTreeCtrl(self, tID, wx.DefaultPosition, wx.DefaultSize,\
                               wx.TR_HIDE_ROOT)
                              # | wx.TR_EDIT_LABELS)
                                #| wx.TR_MULTIPLE
                               #| wx.TR_HIDE_ROOT)

        isz = (16,16)
        il = wx.ImageList(isz[0], isz[1])
        fldridx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz))
        fldropenidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz))
        fileidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, isz))

        self.tree.SetImageList(il)
        self.il = il

        self.root = self.tree.AddRoot("Evenement naamloos")
        self.tree.SetPyData(self.root, None)
        self.tree.SetItemImage(self.root, fldridx, wx.TreeItemIcon_Normal)
        self.tree.SetItemImage(self.root, fldropenidx, wx.TreeItemIcon_Expanded)
        
        childVolledigeEtappe = self.tree.AppendItem(self.root, "Volledige Etappes")
        self.tree.SetPyData(childVolledigeEtappe, None)
        self.tree.SetItemImage(childVolledigeEtappe, fldridx, wx.TreeItemIcon_Normal)
        self.tree.SetItemImage(childVolledigeEtappe, fldropenidx, wx.TreeItemIcon_Expanded)
    
        childDeelnemers = self.tree.AppendItem(self.root, "Deelnemers")
        self.tree.SetPyData(childDeelnemers, None)
        self.tree.SetItemImage(childDeelnemers, fldridx, wx.TreeItemIcon_Normal)
        self.tree.SetItemImage(childDeelnemers, fldropenidx, wx.TreeItemIcon_Expanded)
        
        self.tree.Expand(self.root)
        
----- Original Message -----
From: "Josiah Carlson" <jcarlson@uci.edu>
To: "Math" <mathweijzen@home.nl>; <wxPython-users@lists.wxwidgets.org>
Sent: Wednesday, January 18, 2006 9:21 AM
Subject: Re: [wxPython-users] Root of TreeControl

>
> "Math" <mathweijzen@home.nl> wrote:
>> Hi everybody,
>>
>> Can somebody please explain to me how to hide the Root-item of a TreeControl?
>> I'm having difficulties hiding using wx.TR_HIDE_ROOT, then I get the message
>> "can't retrieve virtual root item". Everything else is hidden to.
>> Please help me out....
>>
>> Thank you
>
> Create a wx.TreeCtrl with a style of wx.TR_HIDE_ROOT.
> Immediately after creating it, add a hidden root node:
>
> rootnode = tree.AddRoot("Unseen Root")
>
> Any time you need to add a "root item" to the tree, add it as a child to
> the above rootnode.
>
> - Josiah
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
>