473,698 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with wx.TreeCtrl

5 New Member
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 2098
MrQ
5 New Member
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
2333
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) fldridx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART... self.tree.SetImageList(il)
1
3195
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 classes currently - the Application class and the Frame class. The Frame class contains all of the event handling, such as OnAbout and OnExit. I am trying to add keyboard shortcuts. When someone hits Ctrl-I, I want a new node to be added at the...
0
1116
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
1065
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 that I've associated the function 'OnRightClick' with wx.EVT_TREE_ITEM_RIGHT_CLICK. And in this function, I say self.tree.SelectItem(evt.GetItem(),True) to select the item and then so some action for right click.
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.