A wx.ImageList contains a list of images, which are stored in an unspecified form.
Images can use alpha channel or masks for transparent drawing, and can be made from a variety of sources including bitmaps and icons.
wx.ImageList is used principally in conjunction with wx.TreeCtrl and wx.ListCtrl classes.
Use of this class is not recommended in the new code as it doesn’t support showing DPI-dependent bitmaps. Please use wx.WithImages.SetImages
instead of wx.WithImages.SetImageList
.
See also
Default constructor. |
|
Adds a new image or images using a bitmap and optional mask bitmap. |
|
Initializes the list. |
|
Destroys the current list. |
|
Draws a specified image onto a device context. |
|
Returns the bitmap corresponding to the given index. |
|
Returns the icon corresponding to the given index. |
|
Returns the number of images in the list. |
|
Retrieves the size of the images in the list. |
|
Removes the image at the given position. |
|
Removes all the images in the list. |
|
Replaces the existing image with the new image. |
See |
|
See |
wx.
ImageList
(Object)¶Possible constructors:
ImageList()
ImageList(width, height, mask=True, initialCount=1)
A ImageList contains a list of images, which are stored in an unspecified form.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
__init__ (self, width, height, mask=True, initialCount=1)
Constructor specifying the image size, whether image masks should be created, and the initial size of the list.
Note that the size is specified in logical pixels.
width (int) – Width of the images in the list.
height (int) – Height of the images in the list.
mask (bool) – If True
, all images will have masks, with the mask being created from the light grey pixels if not specified otherwise, i.e. if the image doesn’t have neither alpha channel nor mask and no mask is explicitly specified when adding it. Note that if an image does have alpha channel or mask, it will always be used, whether this parameter is True
or False
.
initialCount (int) – The initial size of the list.
Add
(self, *args, **kw)¶Add (self, bitmap, mask=NullBitmap)
Adds a new image or images using a bitmap and optional mask bitmap.
The logical size of the bitmap should be the same as the size specified when constructing wx.ImageList. If the logical width of the bitmap is greater than the image list width, bitmap is split into smaller images of the required width.
int
The new zero-based image index.
Add (self, bitmap, maskColour)
Adds a new image or images using a bitmap and mask colour.
The logical size of the bitmap should be the same as the size specified when constructing wx.ImageList. If the logical width of the bitmap is greater than the image list width, bitmap is split into smaller images of the required width.
int
The new zero-based image index.
Add (self, icon)
Adds a new image using an icon.
The logical size of the icon should be the same as the size specified when constructing wx.ImageList.
icon (wx.Icon) – Icon to use as the image.
int
The new zero-based image index.
Availability
Only available for MSW, OSX.
Create
(self, width, height, mask=True, initialCount=1)¶Initializes the list.
See wx.ImageList for details.
This function can be called only once after creating the object using its default constructor or after calling Destroy
.
width (int) –
height (int) –
mask (bool) –
initialCount (int) –
bool
Destroy
(self)¶Destroys the current list.
This function resets the object to its initial state and does more than just RemoveAll
in the native wxMSW version.
After calling it, Create
may be called again to recreate the image list, e.g. using a different size.
New in version 4.1/wxWidgets-3.1.6.
Draw
(self, index, dc, x, y, flags=IMAGELIST_DRAW_NORMAL, solidBackground=False)¶Draws a specified image onto a device context.
index (int) – Image index, starting from zero.
dc (wx.DC) – Device context to draw on.
x (int) – X position on the device context.
y (int) – Y position on the device context.
flags (int) – How to draw the image. A bitlist of a selection of the following:
wx.IMAGELIST_DRAW_NORMAL
: Draw the image normally.
wx.IMAGELIST_DRAW_TRANSPARENT
: Draw the image with transparency.
wx.IMAGELIST_DRAW_SELECTED
: Draw the image in selected state.
wx.IMAGELIST_DRAW_FOCUSED
: Draw the image in a focused state.
solidBackground (bool) – For optimisation - drawing can be faster if the function is told that the background is solid.
bool
GetBitmap
(self, index)¶Returns the bitmap corresponding to the given index.
index (int) –
GetIcon
(self, index)¶Returns the icon corresponding to the given index.
index (int) –
GetImageCount
(self)¶Returns the number of images in the list.
int
GetSize
(self, *args, **kw)¶GetSize (self, index)
Retrieves the size of the images in the list.
Currently, the index parameter is ignored as all images in the list have the same size.
index (int) – currently unused, should be 0
tuple
( width, height )
GetSize (self)
Retrieves the size of the image list as passed to Create
.
the size of the image list, which may be zero if the image list was not yet initialised.
Remove
(self, index)¶Removes the image at the given position.
index (int) –
bool
RemoveAll
(self)¶Removes all the images in the list.
bool
Replace
(self, *args, **kw)¶Replace (self, index, bitmap, mask=NullBitmap)
Replaces the existing image with the new image.
bool
True
if the replacement was successful, False
otherwise.
Note
The original bitmap or icon is not affected by the Replace
operation, and can be deleted afterwards.
Replace (self, index, icon)
Replaces the existing image with the new image.
index (int) – The index of the bitmap to be replaced.
icon (wx.Icon) – Icon to use as the image.
bool
True
if the replacement was successful, False
otherwise.
Note
The original bitmap or icon is not affected by the Replace
operation, and can be deleted afterwards.
Availability
Only available for MSW, OSX.
ImageCount
¶See GetImageCount