Like subject line says, I am sort of trying to generate the structure of a wx.TreeCtrl manually, by adding elements/children piece by piece, but, since I would like to have them represent objects/elements in another data structure/collection - have thus far avoided trying to actually use any form of automated data binding - I need/want some way to link the elements in the tree view to items stored in something like a dictionary collection, but, was trying to use something like the string version of the TreeItemId returned from AppendItem(), but, it doesn’t seem to want to cooperate.
Also tried just assigning an additional attribute/property to a child item after adding it, but, those don’t seem to then be retrievable later on, but, in the AppendItem() function/method, I see it offers another parameter, called TreeItemData, and not sure if this would be relevant?
Was just trying to keep the actual TreeCtrl as sort of purely representative, with just labelling, and thus store other actual objects in another, simpler collection/data structure, but, thus need to be able to sort of link them to then be able to remove an item from that other collection, or update it, etc.
Am I just approaching this in completely the wrong way, or am I (little bit late on a Sunday evening/early on a Monday morning) missing something a bit obvious?
TIA
Jacob Kruger
Blind Biker
Skype: BlindZA
‘…fate had broken his body, but not his spirit…’
Ok, sorted it out this morning - sort of simplified version of code to give you an idea:
self.tree = wx.TreeCtrl(panel, style=wx.EXPAND)
self.root = self.tree.AddRoot(“rootElement”)
anItem = self.tree.AppendItem(self.root, “one”)
self.tree.SetItemData(anItem, wx.TreeItemData(1))
#…and to then retrieve value later on…
self.tree.GetItemData(self.tree.GetSelection()).GetData()
Jacob Kruger
Blind Biker
Skype: BlindZA
‘…fate had broken his body, but not his spirit…’
···
----- Original Message -----
From:
Jacob Kruger
To: wxpython-users@googlegroups.com
Sent: Monday, 03 March, 2014 1:02 AM
Subject: [wxPython-users] Linking an additional value/object to a wx.TreeCtrl item
Like subject line says, I am sort of trying to generate the structure of a wx.TreeCtrl manually, by adding elements/children piece by piece, but, since I would like to have them represent objects/elements in another data structure/collection - have thus far avoided trying to actually use any form of automated data binding - I need/want some way to link the elements in the tree view to items stored in something like a dictionary collection, but, was trying to use something like the string version of the TreeItemId returned from AppendItem(), but, it doesn’t seem to want to cooperate.
Also tried just assigning an additional attribute/property to a child item after adding it, but, those don’t seem to then be retrievable later on, but, in the AppendItem() function/method, I see it offers another parameter, called TreeItemData, and not sure if this would be relevant?
Was just trying to keep the actual TreeCtrl as sort of purely representative, with just labelling, and thus store other actual objects in another, simpler collection/data structure, but, thus need to be able to sort of link them to then be able to remove an item from that other collection, or update it, etc.
Am I just approaching this in completely the wrong way, or am I (little bit late on a Sunday evening/early on a Monday morning) missing something a bit obvious?
TIA
Jacob Kruger
Blind Biker
Skype: BlindZA
‘…fate had broken his body, but not his spirit…’
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.