Some problems with wx.TreeCtrl

Hi, I have a problem with tree control and i don’t know how to solve it, maybe someone can help me. What i’m trying to do is display widgets in a staticbox plus a help text when i select different items in a tree.
For example when i select item1 in a a tree control i want to display two checkboxes in Demo staticbox control. When i select item2 display only two radio buttons in the same control and so on. Plus for every item selected in the tree control display some help text in text control. If someone can help with that or give me an idea to start i will be very grateful. From what I read it seems to be a rather advanced topic because i tried to find the answer but nobody seems to know how i can solve this problem. Of course the real problem is not to create controls when i select item1, item 2 etc but to display only certain controls when navigating through TreeCtrl items. Something like wxpython demo perhaps.
Thank you.

Here is the demo code (it’s not very organized but it’s only for testing):

import wx

class DemoFrame(wx.Frame):
def init(self, parent, id):

wx.Frame.init(self, parent, id, ‘Demo’, size=(600, 400), pos=(300,300))
self.panel1=wx.Panel (self, -1)
self.panel1.SetBackgroundColour (“white”)

self.DoLayout ()

      def DoLayout (self):
 #sizers
                mainsizer = wx.BoxSizer(wx.VERTICAL)
                panelsizer = wx.BoxSizer(wx.VERTICAL )
                sizer1 = wx.BoxSizer(wx.VERTICAL)
                sizer2 = wx.BoxSizer(wx.VERTICAL)
···

####################################################################
#create splitter windows
self.splitter = wx.SplitterWindow(self, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
self.splitter2 = wx.SplitterWindow(self.splitter, -1, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)

self.mainpanel = wx.Panel(self.splitter, -1)
self.leftpanel2 = wx.Panel(self.splitter2, -1, style=wx.WANTS_CHARS)
self.mainpanel.SetBackgroundColour (“white”)
####################################################################

#create tree control
self.tree = wx.TreeCtrl(self.mainpanel, -1, wx.Point(0, 0), wx.Size (160, 250),
wx.TR_DEFAULT_STYLE | wx.NO_BORDER)
self.root = self.tree.AddRoot(“Root Demo Item”)
item1 = self.tree.AppendItem (self.root , “Item1”,0)
item2 = self.tree.AppendItem (self.root, “Item2”,0)

self.tree.Expand(self.root)
###################################################################################
#add other widgets
self.help = wx.TextCtrl(self.splitter2, -1,
style = wx.TE_MULTILINE|wx.TE_READONLY | wx.HSCROLL)
staticboxstyles = wx.StaticBox(self.leftpanel2, -1, “Demo”, size=(485, 240))
self.splitter2.SetBackgroundColour (wx.SystemSettings_GetColour
(wx.SYS_COLOUR_3DFACE))
#################################################################################
#add widgets to sizers
panelsizer.Add(self.splitter, 1, wx.EXPAND, 0)

sizer1.Add(self.tree, 1, wx.EXPAND)
sizer2.Add(staticboxstyles, 1, wx.BOTTOM|wx.EXPAND|wx.ALIGN_BOTTOM , 60 )
########################################################################################
#set sizers
self.mainpanel.SetSizer(sizer1)
self.leftpanel2.SetSizer (sizer2)
self.SetSizer(panelsizer)
mainsizer.Layout()

self.Layout()

#######################################################################
#set splitters
self.splitter.SplitVertically(self.mainpanel, self.splitter2, 300)

self.splitter2.SplitHorizontally(self.leftpanel2, self.help, -160)
self.splitter.SetSashPosition (200)

if name == ‘main’:
app = wx.PySimpleApp()
frame = DemoFrame(parent=None, id=-1)

      frame.Show()
      app.MainLoop()

For every "page" you want to display depending on what someone clicks on,
create a wx.Panel() instance. Put the relevant controls on that panel.

Add all of these panels to a single sizer. Call panel.Hide() on all the
panels you don't want to see and panel.Show() on the one you do want to
see. Call sizer.Layout() to force everything to lay themselves out
again.

When you switch tree selection, .Hide() the panel that was showing,
.Show() the panel you want to show, and call sizer.Layout() .

This isn't theoretical. All of the custom notebook-like controls do
this. I've done this. It works.

- Josiah

···

"michael michael" <pythonmg@gmail.com> wrote:

Hi, I have a problem with tree control and i don't know how to solve it,
maybe someone can help me. What i'm trying to do is display widgets in a
staticbox plus a help text when i select different items in a tree.
For example when i select item1 in a a tree control i want to display two
checkboxes in Demo staticbox control. When i select item2 display only two
radio buttons in the same control and so on. Plus for every item selected in
the tree control display some help text in text control. If someone can help
with that or give me an idea to start i will be very grateful. From what I
read it seems to be a rather advanced topic because i tried to find the
answer but nobody seems to know how i can solve this problem. Of course the
real problem is not to create controls when i select item1, item 2 etc but
to display only certain controls when navigating through TreeCtrl items.
Something like wxpython demo perhaps.
Thank you.