473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problems with wx.TreeCtrl

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
1 2090
MrQ
5
Nobody ? Not even a hint, idea or something ?
May 17 '07 #2

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

Similar topics

2
by: Martin Drautzburg | last post by:
In the wx demoy TreeCtrl.py I find the following code, that should have no effect but seems to be needed nevertheless. class TestTreeCtrlPanel(wx.Panel): def __init__(self, parent, log): , isz)...
1
by: Saketh | last post by:
Hello, everyone. I am a writing an application that I want to make a stripped-down framework of Leo for Cornell note-taking. I have one TreeCtrl, a menu, and a status bar. There are two...
0
by: raja11112222 | last post by:
Hi, I am Using MFC, In that, I used Icon in the treeCtrl , My problem is I need to place two icons continously in the tree . Is there any possible way to do. Thanks
0
by: tarun | last post by:
Hello All, Please find the code for a simple wx.TreeCtrl code. Whenever I right click on any item in the Tree, I see the function, 'OnSelChanged' gets called twice. What I've just done is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.