AGW Logo

agw_title PyImageList

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).

hierarchy Inheritance Diagram

Inheritance diagram for: PyImageList

Inheritance diagram of PyImageList


method_summary Methods Summary

__init__Default class constructor.
AddAdds a new image or images using a bitmap.
AddIconAdds a new image using an icon.
AddWithColourMaskAdds a new image or images using a bitmap and a colour mask.
DrawDraws a specified image onto a device context.
GetBitmapReturns the bitmap corresponding to the given index, or wx.NullBitmap
GetIconReturns the icon corresponding to the given index, or wx.NullIcon
GetImageCountReturns the number of images in the list.
GetSizeRetrieves the size of an image in the list.
RemoveRemoves the image at the given position.
RemoveAllRemoves all the images in the list.
ReplaceReplaces the existing image with the new bitmap.
ReplaceIconReplaces the existing image with the new icon.

API Class API

class PyImageList(object)[source]

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__(width, height, mask=True, initialCount=1, style=IL_VARIABLE_SIZE)[source]

Default class constructor.

Parameters:
  • 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;
  • maskTrue 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
    IL_FIXED_SIZE 0 All the images in PyImageList have the same size (width, height)
    IL_VARIABLE_SIZE 1 Each image can have any size (in terms of width and height)


Add(bitmap)[source]

Adds a new image or images using a bitmap.

Parameters:bitmap – a valid wx.Bitmap object.
Returns: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(icon)[source]

Adds a new image using an icon.

Parameters:icon – a valid wx.Icon object.
Returns: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(bitmap, maskColour)[source]

Adds a new image or images using a bitmap and a colour mask.

Parameters:
  • bitmap – a valid wx.Bitmap object;

  • colour – an instance of wx.Colour, a colour indicating which parts of the image are transparent.
Returns:

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(index, dc, x, y, flags, solidBackground=True)[source]

Draws a specified image onto a device context.

Parameters:
  • 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
    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 – currently unused.


GetBitmap(index)[source]

Returns the bitmap corresponding to the given index, or wx.NullBitmap if the index is invalid.

Parameters:index – the bitmap index.


GetIcon(index)[source]

Returns the icon corresponding to the given index, or wx.NullIcon if the index is invalid.

Parameters:index – the icon index.


GetImageCount()[source]

Returns the number of images in the list.



GetSize(index)[source]

Retrieves the size of an image in the list.

Parameters:index – the zero-based index of the image.
Returns:a tuple of (width, height) properties of the chosen bitmap.


Remove(index)[source]

Removes the image at the given position.

Parameters:index – the zero-based index of the image to be removed.


RemoveAll()[source]

Removes all the images in the list.



Replace(index, bitmap)[source]

Replaces the existing image with the new bitmap.

Parameters:
  • 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(index, icon)[source]

Replaces the existing image with the new icon.

Parameters:
  • index – the index at which the image should be replaced;
  • icon – the new icon to add to the image list, an instance of wx.Icon.
Tree

Table Of Contents

Previous topic

GeometryInfo

Next topic

SelectionStore