By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,994 Members | 1,166 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,994 IT Pros & Developers. It's quick & easy.

Problems with wx.TreeCtrl

P: 5
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.
Here is the demo code (it's not very organized but it's only for testing):
(I don't know what's the problem but when i use tags code is messed up so i have to manually enter tags)

Expand|Select|Wrap|Line Numbers
  1. import wx
  2.  
  3.  
  4. class DemoFrame(wx.Frame):
  5.  
  6.     def __init__(self, parent, id):
  7.  
  8.         wx.Frame.__init__(self, parent, id, 'Demo', size=(600, 400), pos=(300,300))
  9.  
  10.         self.panel1=wx.Panel (self, -1)
  11.         self.panel1.SetBackgroundColour ("white")
  12.         self.DoLayout ()
  13.  
  14.  
  15.  
  16.     def DoLayout (self):
  17.  
  18.         #sizers
  19.         mainsizer = wx.BoxSizer(wx.VERTICAL)
  20.         panelsizer = wx.BoxSizer(wx.VERTICAL)
  21.         sizer1 = wx.BoxSizer(wx.VERTICAL)
  22.         sizer2 = wx.BoxSizer(wx.VERTICAL)
  23.  
  24. ####################################################################        
  25.         #create splitter windows
  26.         self.splitter = wx.SplitterWindow(self, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
  27.         self.splitter2 = wx.SplitterWindow(self.splitter, -1, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
  28.  
  29.         self.mainpanel = wx.Panel(self.splitter, -1)
  30.         self.leftpanel2 = wx.Panel(self.splitter2, -1, style=wx.WANTS_CHARS)
  31.         self.mainpanel.SetBackgroundColour ("white")
  32.  
  33. ####################################################################
  34.  
  35.         #create tree control
  36.         self.tree = wx.TreeCtrl(self.mainpanel, -1, wx.Point(0, 0), wx.Size(160, 250),
  37.                             wx.TR_DEFAULT_STYLE | wx.NO_BORDER)
  38.         self.root = self.tree.AddRoot("Root Demo Item")
  39.         item1 = self.tree.AppendItem (self.root, "Item1",0)
  40.         item2 = self.tree.AppendItem (self.root, "Item2",0)
  41.         self.tree.Expand(self.root)
  42.  
  43. ###################################################################################
  44.         #add other widgets
  45.         self.help = wx.TextCtrl(self.splitter2, -1,
  46.                                style = wx.TE_MULTILINE|wx.TE_READONLY | wx.HSCROLL)
  47.         staticboxstyles = wx.StaticBox(self.leftpanel2, -1, "Demo", size=(485, 240))
  48.         self.splitter2.SetBackgroundColour (wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))
  49. #################################################################################        
  50.         #add widgets to sizers
  51.         panelsizer.Add(self.splitter, 1, wx.EXPAND, 0)
  52.         sizer1.Add(self.tree, 1, wx.EXPAND)
  53.         sizer2.Add(staticboxstyles, 1, wx.BOTTOM|wx.EXPAND|wx.ALIGN_BOTTOM, 60 )
  54.  
  55.  
  56. ########################################################################################        
  57.         #set sizers
  58.         self.mainpanel.SetSizer(sizer1)
  59.         self.leftpanel2.SetSizer(sizer2)
  60.         self.SetSizer(panelsizer)
  61.         mainsizer.Layout()
  62.         self.Layout()
  63.  
  64. #######################################################################
  65.  
  66.         #set splitters
  67.         self.splitter.SplitVertically(self.mainpanel, self.splitter2, 300)
  68.         self.splitter2.SplitHorizontally(self.leftpanel2, self.help, -160)
  69.         self.splitter.SetSashPosition (200)
  70.  
  71.  
  72. if __name__ == '__main__':
  73.     app = wx.PySimpleApp()
  74.     frame = DemoFrame(parent=None, id=-1)
  75.     frame.Show()
  76.     app.MainLoop()
May 16 '07 #1
Share this Question
Share on Google+
1 Reply


P: 5
MrQ
Nobody ? Not even a hint, idea or something ?
May 17 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.