wx.ImageList

Inheritance diagram for wx.ImageList:



Description

A wx.ImageList contains a list of images, which are stored in an unspecified form. Images can have 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.

Derived From

Properties Summary

Class API

Methods

__init__(width, height, mask=True, initialCount=1)

Constructor specifying the image size, whether image masks should be created, and the initial size of the list.

Parameters:

  • width (int): Width of the images in the list.
  • height (int): Height of the images in the list.
  • mask (bool): True if masks should be created for all images.
  • initialCount (int): The initial size of the list.

Returns:

wx.ImageList


Add(bitmap, mask=wx.NullBitmap)

Adds a new image using a bitmap.

Parameters:

  • bitmap (wx.Bitmap): Bitmap representing the opaque areas of the image.
  • mask (wx.Bitmap): Monochrome mask bitmap, representing the transparent areas of the image

Returns:

int

Note

The original bitmap or icon is not affected by the Add operation, and can be deleted afterwards. If the bitmap is wider than the images in the list, then the bitmap will automatically be split into smaller images, each matching the dimensions of the image list. This does not apply when adding icons.


AddIcon(icon)

Adds a new image using an icon.

Parameters:


Returns:

int

Note

The original bitmap or icon is not affected by the Add operation, and can be deleted afterwards. If the bitmap is wider than the images in the list, then the bitmap will automatically be split into smaller images, each matching the dimensions of the image list. This does not apply when adding icons.


AddWithColourMask(bitmap, maskColour)

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

Parameters:

Returns:

int

Note

The original bitmap or icon is not affected by the Add operation, and can be deleted afterwards. If the bitmap is wider than the images in the list, then the bitmap will automatically be split into smaller images, each matching the dimensions of the image list. This does not apply when adding icons.


Draw(index, dc, x, y, flags=wx.IMAGELIST_DRAW_NORMAL, solidBackground=False)

Draws a specified image onto a device context.

Parameters:

  • 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 Flags

    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 (bool): For optimisation – drawing can be faster if the function is told that the background is solid.


Returns:

bool


GetBitmap(index)

Returns the bitmap corresponding to the given index.

Parameters:

  • index (int)

Returns:

wx.Bitmap


GetIcon(index)

Returns the icon corresponding to the given index.

Parameters:

  • index (int)

Returns:

wx.Icon


GetImageCount()

Returns the number of images in the list.


Returns:

int


GetSize(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.

Parameters:

  • index (int): currently unused, should be 0

Returns:

bool


Remove(index)

Removes the image at the given position.

Parameters:

  • index (int): the given position

Returns:

bool


RemoveAll()

Removes all the images in the list.


Returns:

bool


Replace(index, bitmap, mask)

Replaces the existing image with the new image.

Parameters:

  • index (int): the given position.
  • bitmap (wx.Bitmap): Bitmap representing the opaque areas of the image.
  • mask (wx.Bitmap): Monochrome mask bitmap, representing the transparent areas of the image.

Returns:

bool

Note

The original bitmap or icon is not affected by the Replace operation, and can be deleted afterwards.


Properties

ImageCount
See GetImageCount
Size
See GetSize