[wxPython-users] ANN: FlatNotebook Control For wxPython ;-)

Nitro nitro at dr-code.org
Wed Oct 11 03:05:48 PDT 2006


> 6) @Matthias: The issue of DnD with icons should be fixed. Now if you
> drag a tab that contains an image from a notebook to another notebook,
> that image is reassigned in the dropped tab in the new notebook,
> whether by creating a new wx.ImageList (if the second notebook does
> not hold one) or by adding the tab image to the second notebook's
> imagelist.
>
> NB: this part of the code has a drawing problem:
>
> a) By Drag 'n' Drop from an oldNotebook to a newNotebook, from this
> snippets of code:
>
> # Get the bitmap of the dragged tab
> bmp = oldNotebook.GetImageList().GetBitmap(imageindex)
>
> # Get the wx.ImageList of the target notebook
> newImageList = newNotebook.GetImageList()
>
> if not newImageList:
>     # Target notebook has no ImageList, so create one
>     xbmp, ybmp = bmp.GetWidth(), bmp.GetHeight()
>     newImageList = wx.ImageList(xbmp, ybmp)
>     imageindex = 0
> else:
>     imageindex = newImageList.GetImageCount()
>
> newImageList.Add(bmp)
> newNotebook.SetImageList(newImageList)
>
> Ok, from now on, the added bitmap to the second notebook does *not*
> paint transparent anymore, whatever trick I use. I get the bitmap with
> a black background. Is it possible that retrieving a bitmap from an
> imagelist and putting it to another screws up the imagelist drawing?
> Please note that I use:
>
> wx.ImageList.Draw(imageIndex, dc, xpos, ypos,
> wx.IMAGELIST_DRAW_TRANSPARENT, True)
>
> For this problem, I don't have a solution right now.

Hey, thanks for implementing this! I modified your code to read as follows:

                             bmp =  
oldNotebook.GetImageList().GetIcon(imageindex)
                             newImageList = newNotebook.GetImageList()

                             if not newImageList:
                                 xbmp, ybmp = bmp.GetWidth(),  
bmp.GetHeight()
                                 newImageList = wx.ImageList(xbmp, ybmp)
                                 imageindex = 0
                             else:
                                 imageindex = newImageList.GetImageCount()

                             newImageList.AddIcon(bmp)
                             newNotebook.SetImageList(newImageList)

and this seems to keep the transparent parts. I don't know if it's the  
method of choice though.

-Matthias




More information about the wxpython-users mailing list