Hi I want to put a selected image an image in the treeItemsCtrl but i cant find how i tried
fileopen = wx.Image("../iconos/folder-cerrado.png", wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()
fileClose = wx.Image("../iconos/folder-abierto.png", wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()
self.tree = wx.TreeCtrl(panel1, 1, wx.DefaultPosition, (-1,-1), wx.TR_HIDE_ROOT)
root = self.tree.AddRoot('Home')
os = self.tree.AppendItem(root, 'Documentos', image=fileAbierto, selectedImagefileCerrado)
but it didnt work I have that this error when I try to run it
os = self.tree.AppendItem(root, 'Documentos',fileAbierto,fileCerrado)
File "/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode/wx/_controls.py", line 5469, in AppendItem return controls.TreeCtrl_AppendItem(*args, **kwargs) TypeError: in method 'TreeCtrl_AppendItem', expected argument 4 of type 'int'
I want to do this in the Append Function because I am adding the items in a function thanks
The wxPython demo has an example. It looks like you need to create an ImageList and extract the ids. Then when you set up the tree's items, you will want to use the SetItemImage method to add the selected icon:
self.tree.SetItemImage(item, fileidx, wx.TreeItemIcon_Normal)
self.tree.SetItemImage(item, smileidx, wx.TreeItemIcon_Selected)
So in the demo it shows a folder icon when it's unselected. Then when it IS selected, it shows a smiley instead.