A PyImageList
contains a list of images. Images can have masks for
transparent drawing, and can be made from a variety of sources including
bitmaps and icons.
PyImageList
is used in conjunction with UltimateListCtrl
.
Note
The main improvements that PyImageList
introduces is the removal
of the limitation of same-size images inside the image list. If you use
the style IL_VARIABLE_SIZE
then each image can have any size (in terms
of width and height).
Default class constructor. |
|
Adds a new image or images using a bitmap. |
|
Adds a new image using an icon. |
|
Adds a new image or images using a bitmap and a colour mask. |
|
Draws a specified image onto a device context. |
|
Returns the bitmap corresponding to the given index, or |
|
Returns the icon corresponding to the given index, or |
|
Returns the number of images in the list. |
|
Retrieves the size of an image in the list. |
|
Removes the image at the given position. |
|
Removes all the images in the list. |
|
Replaces the existing image with the new bitmap. |
|
Replaces the existing image with the new icon. |
PyImageList
(object)¶A PyImageList
contains a list of images. Images can have masks for
transparent drawing, and can be made from a variety of sources including
bitmaps and icons.
PyImageList
is used in conjunction with UltimateListCtrl
.
Note
The main improvements that PyImageList
introduces is the removal
of the limitation of same-size images inside the image list. If you use
the style IL_VARIABLE_SIZE
then each image can have any size (in terms
of width and height).
__init__
(self, width, height, mask=True, initialCount=1, style=IL_VARIABLE_SIZE)¶Default class constructor.
width – the width of the images in the image list, in pixels (unused
if you specify the IL_VARIABLE_SIZE
style;
height – the height of the images in the image list, in pixels (unused
if you specify the IL_VARIABLE_SIZE
style;
mask – True
if masks should be created for all images (unused in
PyImageList
);
initialCount – the initial size of the list (unused in PyImageList
);
style – can be one of the following bits:
Style Flag |
Value |
Description |
---|---|---|
|
0 |
All the images in |
|
1 |
Each image can have any size (in terms of width and height) |
Add
(self, bitmap)¶Adds a new image or images using a bitmap.
bitmap – a valid wx.Bitmap
object.
The new zero-based image index.
Note
If the bitmap is wider than the images in the list and you are not using
the IL_VARIABLE_SIZE
style, then the bitmap will automatically be split
into smaller images, each matching the dimensions of the image list.
AddIcon
(self, icon)¶Adds a new image using an icon.
icon – a valid Icon
object.
The new zero-based image index.
Note
If the icon is wider than the images in the list and you are not using
the IL_VARIABLE_SIZE
style, then the icon will automatically be split
into smaller images, each matching the dimensions of the image list.
AddWithColourMask
(self, bitmap, maskColour)¶Adds a new image or images using a bitmap and a colour mask.
The new zero-based image index.
Note
If the bitmap is wider than the images in the list and you are not using
the IL_VARIABLE_SIZE
style, then the bitmap will automatically be split
into smaller images, each matching the dimensions of the image list.
Draw
(self, index, dc, x, y, flags, solidBackground=True)¶Draws a specified image onto a device context.
index – the image index, starting from zero;
dc – an instance of wx.DC
;
x – x position on the device context;
y – y position on the device context;
flags – how to draw the image. A bitlist of a selection of the following:
Flag Paarameter |
Description |
---|---|
|
Draw the image normally |
|
Draw the image with transparency |
|
Draw the image in selected state |
|
Draw the image in a focused state |
solidBackground – currently unused.
GetBitmap
(self, index)¶Returns the bitmap corresponding to the given index, or NullBitmap
if the index is invalid.
index – the bitmap index.
GetIcon
(self, index)¶Returns the icon corresponding to the given index, or NullIcon
if the index is invalid.
index – the icon index.
GetImageCount
(self)¶Returns the number of images in the list.
GetSize
(self, index)¶Retrieves the size of an image in the list.
index – the zero-based index of the image.
a tuple of (width, height) properties of the chosen bitmap.
Remove
(self, index)¶Removes the image at the given position.
index – the zero-based index of the image to be removed.
RemoveAll
(self)¶Removes all the images in the list.
Replace
(self, index, bitmap)¶Replaces the existing image with the new bitmap.
index – the index at which the image should be replaced;
bitmap – the new bitmap to add to the image list, an instance of
wx.Bitmap
.
ReplaceIcon
(self, index, icon)¶Replaces the existing image with the new icon.
index – the index at which the image should be replaced;
icon – the new icon to add to the image list, an instance of
Icon
.