wxPython 2.2.1
I can understand that, but this is requiered only on win98 SE,
on win95 I don't need keep a reference inside the wxTreeCtrl, but
only into the main frame.
The next code works great on win95,
but shows white images on win98:
···
##################
from wxPython.wx import *
class MyFrame(wxFrame):
def __init__(self, parent, id, title):
wxFrame.__init__(self, parent, id, title,wxPoint(100, 100),
wxSize(300, 300))
self.il = wxImageList(19,17,FALSE)
idx1 = self.il.Add(wxBitmap("close.bmp", wxBITMAP_TYPE_BMP))
idx2 = self.il.Add(wxBitmap("open.bmp", wxBITMAP_TYPE_BMP))
idx3 = self.il.Add(wxBitmap("b1.bmp", wxBITMAP_TYPE_BMP))
idx4 = self.il.Add(wxBitmap("b2.bmp", wxBITMAP_TYPE_BMP))
print wxNullBitmap.Ok()
self.explorer= wxTreeCtrl(self,1000,style=0)
self.explorer.SetImageList(self.il)
idp = self.explorer.AddRoot("Inicio",idx3,idx4)
lista = ["Chile","Brasil","Argentina","Uruguay","Colombia"]
for i in lista:
self.explorer.AppendItem(idp,i,idx1,idx2)
self.explorer.SetItemBold(idp)
EVT_TREE_ITEM_EXPANDED(self.explorer,1000,self.OnItemExpanded)
EVT_TREE_ITEM_COLLAPSED(self.explorer,1000,self.OnItemCollapsed)
def OnItemExpanded(self,event):
item = event.GetItem()
print item
print "OnItemExpanded: %s" % self.explorer.GetItemText(item)
def OnItemCollapsed(self,event):
print "collapsed"
def OnCloseWindow(self, event):
self.Destroy()
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, "Prueba Cheve 1")
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
#########################
-----Original Message-----
From: Robin Dunn [SMTP:robin@alldunn.com]
Sent: Sunday, August 27, 2000 10:57 PM
To: wxpython-users@wxwindows.org
Cc: wxpython-regusers@wxwindows.org
Subject: [wxPython] Re: [wxPyRU] Problem with wxTreeCtrl> Hi...
> Into the example code at the end of this message, if the wxImageList
> is not a member of the wxTreeCtrl, then the images are not displayed.
> Is somthing wrong with my code?
> Why wxTreeCtrl.SetImageList don't save a reference of the list?
>ImageLists are meant to be able to be reused by several components in an
application, so the components don't take ownership of them like in most
of
the rest of wxWindows. This means that you need to keep a reference to it
yourself and when your reference count goes to zero then the C++ object
will
be deleted as well.--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxpython.org Java give you jitters?
http://wxpros.com Relax with wxPython!_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users