Controling size and position for CustomTreeCtrl (Additional: Asymmetry between wnd keyword and SetWindow Function)

Thanks Mike!

My original plan was to use a TreeListCtrl, but how could I turn down
CustomTreeCtrl? The possibility to attached validators to my TextCtrl's,
adding spinbuttons, and easier event handling just looked all too
tempting. But if it comes down to it, I should be able to fall back to
TreeListCtrl's.

More importantly however, I just found a rather annoying Asymmetry
between the wnd keyword when adding a child, and the SetWindow Function.
When you add windows using the wnd keyword, they undraw as expected when
you reduce a node (reduce, unexpand, what's the proper word?). However,
if you add a window with the SetWindow function later, they don't! I've
only tested this on my current dev machine (Windows XP, Python 25,
WxPython 2.8.4.0), so it might just be something local. Example code
(slightly modified from my previous example) follows:

···

#====================================================================#
import wx
import wx.lib.customtreectrl as CT

class Frame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "Tree Test")
        self.Panel = wx.Panel(self, id=-1,
              pos=wx.Point(640, 300), size=wx.Size(500, 400),
              style=0)
        self.Tree = CustomTreeCtrl(parent=self, id = -1)
        self.BoxSizer = wx.BoxSizer(orient=wx.VERTICAL)
        self.BoxSizer.AddWindow(self.Tree, 1, flag=wx.GROW)
        self.SetSizer(self.BoxSizer)

class CustomTreeCtrl(CT.CustomTreeCtrl):
    def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.SUNKEN_BORDER | CT.TR_HAS_BUTTONS):

        CT.CustomTreeCtrl.__init__(self, parent, id, pos, size,
                                   (style |
CT.TR_HAS_VARIABLE_ROW_HEIGHT))

        self.Root = self.AddRoot("Root")
        self.SetPyData(self.Root, None)
        
        for i in range(3):
            newpanel = ParameterPanel(self, i)
            child = self.AppendItem(self.Root, "Parameter " + repr(i))
            self.SetPyData(child, None)

            #These Windows Will Not Undraw
            child.SetWindow(newpanel)
            
        for i in range(3):
            node = self.AppendItem(self.Root, "Node " + repr(i))
            self.SetPyData(node, None)
            for j in range(3):
                newpanel = ParameterPanel(self, j)

                #These Will
                child = self.AppendItem(node, "Parameter " + repr(j),
                                        wnd=newpanel)
                self.SetPyData(child, None)

class ParameterPanel(wx.Panel):
    def __init__(self, parent, value):
        wx.Panel.__init__(self, id=-1, parent=parent)
        self.textctrl = wx.TextCtrl(self, -1, repr(value))
        self.BoxSizer = wx.BoxSizer(orient=wx.HORIZONTAL)
        self.BoxSizer.AddWindow(self.textctrl, 1)
        self.SetSizer(self.BoxSizer)

class App(wx.App):
    def OnInit(self):
        self.frame = Frame(parent = None)
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True

if __name__ == '__main__':
    app = App()
    app.MainLoop()
#====================================================================#

P.S. Still looking for help with the size/position problem. Any more
advice?

-Greg