Is it possible to set an icon to be displayed by each note book tab?
I've read the docs and it seem's that it should be very similar to setting
the icons for a tree control. I create and set the image list, and the assign
the page image. It runs without faulting but does not display the image, any
hints much appreciated?
Is it possible to set an icon to be displayed by each note book tab?
I've read the docs and it seem's that it should be very similar to setting the icons for a tree control. I create and set the image list, and the assign the page image. It runs without faulting but does not display the image, any hints much appreciated?
Yes, it's supposed to work. Do you use SetImageLIst or AssignImageList? If you use the former then you need to save a reference to the image list otherwise it will get garbage collected and the bitmaps will be destroyed.
wxImageList is one of the few things in wxWindows that isn't always owned by something else because it is designed to be shared amongst multiple controls. So it has a __del__ in wxPython that destroys the C++ object too. If you use AssignImageList then the notebook (ot listctrl or treectrl) will take owership of the imagelist and the wxPython wrapper does some housekeeping so the __dell__ doesn't destroy the C++ object.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Brian Bates wrote:
> Hi all,
>
> Using wxPython 2.3.2, and python 2.1, on Debian.
>
> Is it possible to set an icon to be displayed by each note book tab?
>
> I've read the docs and it seem's that it should be very similar to
> setting the icons for a tree control. I create and set the image list,
> and the assign the page image. It runs without faulting but does not
> display the image, any hints much appreciated?
Yes, it's supposed to work. Do you use SetImageLIst or AssignImageList?
If you use the former then you need to save a reference to the image
list otherwise it will get garbage collected and the bitmaps will be
destroyed.
wxImageList is one of the few things in wxWindows that isn't always
owned by something else because it is designed to be shared amongst
multiple controls. So it has a __del__ in wxPython that destroys the
C++ object too. If you use AssignImageList then the notebook (ot
listctrl or treectrl) will take owership of the imagelist and the
wxPython wrapper does some housekeeping so the __dell__ doesn't destroy
the C++ object.
Yes, it's supposed to work. Do you use SetImageLIst or AssignImageList?
Good thing to watch for - could explain a problem I've been having.
Speaking of wxImageList, here's an extension I made of it. Anybody else see the need for something like this? In this example I'm using it to implement an easier 'OnGetItemImage' by subclassing wxListCtrl and using the template method design pattern:
def OnGetItemImage(self, row):
if row not in self.imageList:
image = self.getItemImage(row)
self.imageList.add(row, image)
return self.imageList.getIndex(row)
def getItemImage(self, row):
"""
An abstract method: must be implemented by subclasses.
Return a wxBitmap, wxImage, or None.
"""
raise NotImplementedError
Is it possible to set an icon to be displayed by each note book tab?
I've read the docs and it seem's that it should be very similar to
setting the icons for a tree control. I create and set the image list,
and the assign the page image. It runs without faulting but does not
display the image, any hints much appreciated?
Yes, it's supposed to work. Do you use SetImageLIst or AssignImageList?
I've just made a similar change to the demo (in my 2.4.0pre workspace) and it works fine, so if there is a bug I expext that it's been fixed. There are still a couple things for you to try though, first ensure that the bitmap object is good with myImage.Ok(), second you should use the return value of self.imgList.Add(...) as the image index used for SetPageImage. The value probably is zero but it is an implementation detail that could change.
···
On Sat, 04 Jan 2003 10:06, you wrote:
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!