wx.Icon

Inheritance diagram for wx.Icon:



Description

An icon is a small rectangular bitmap usually used for denoting a minimized application. It differs from a wx.Bitmap in always having a mask associated with it for transparent drawing. On some platforms, icons and bitmaps are implemented identically, since there is no real distinction between a wx.Bitmap with a mask and an icon; and there is no specific icon format on some platforms (X-based applications usually standardize on XPMs for small bitmaps and icons). However, some platforms (such as Windows) make the distinction, so a separate class is provided.

Remarks

It is usually desirable to associate a pertinent icon with a frame. Icons can also be used for other purposes, for example with wx.TreeCtrl and wx.ListCtrl.

Icons have different formats on different platforms. Therefore, separate icons will usually be created for the different environments. Platform-specific methods for creating a wx.Icon structure are catered for, and this is an occasion where conditional compilation will probably be required.

Note

Note that a new icon must be created for every time the icon is to be used for a new window. In Windows, the icon will not be reloaded if it has already been used. An icon allocated to a frame will be deleted when the frame is deleted.

Properties Summary

Class API

Methods

__init__(name, type, desiredWidth=-1, desiredHeight=-1)

Default constructor.

Parameters:

  • name (string): This can refer to a resource name under MS Windows, or a filename under MS Windows and X. Its meaning is determined by the type parameter.

  • type (int): One of the following values:

    Type Flag

    Description

    wx.BITMAP_TYPE_ICO

    Load a Windows icon file.

    wx.BITMAP_TYPE_ICO_RESOURCE

    Load a Windows icon from the resource database.

    wx.BITMAP_TYPE_GIF

    Load a GIF bitmap file.

    wx.BITMAP_TYPE_XBM

    Load an X bitmap file.

    wx.BITMAP_TYPE_XPM

    Load an XPM bitmap file.

    The validity of these flags depends on the platform and wxWidgets configuration

  • desiredWidth (int): Specifies the desired width of the icon. This parameter only has an effect in Windows (32-bit) where icon resources can contain several icons of different sizes.

  • desiredHeight (int): Specifies the desired height of the icon. This parameter only has an effect in Windows (32-bit) where icon resources can contain several icons of different sizes.


Returns:

wx.Icon


CopyFromBitmap(bmp)

Copies bmp bitmap to this icon. Under MS Windows the bitmap must have mask colour set.

Parameters:

See also

LoadFile


GetDepth()

Gets the colour depth of the icon. A value of 1 indicates a monochrome icon.


Returns:

int


GetHeight()

Gets the height of the icon in pixels.


Returns:

int

See also

GetWidth


GetWidth()

Gets the width of the icon in pixels.


Returns:

int

See also

GetHeight


IsOk()

Returns true if icon data is present.


Returns:

bool


LoadFile(name, type)

Loads an icon from a file or resource.

Parameters:

  • name (string): Either a filename or a Windows resource name. The meaning of name is determined by the type parameter.

  • type (int): One of the following values:

    Type Flag

    Description

    wx.BITMAP_TYPE_ICO

    Load a Windows icon file.

    wx.BITMAP_TYPE_ICO_RESOURCE

    Load a Windows icon from the resource database.

    wx.BITMAP_TYPE_GIF

    Load a GIF bitmap file.

    wx.BITMAP_TYPE_XBM

    Load an X bitmap file.

    wx.BITMAP_TYPE_XPM

    Load an XPM bitmap file.

    The validity of these flags depends on the platform and wxWidgets configuration


SetDepth(depth)

Sets the depth member (does not affect the icon data).

Parameters:

  • depth (int): the depth member

SetHeight(height)

Sets the height member (does not affect the icon data).

Parameters:

  • height (int): the height member

See also

SetWidth


SetWidth(width)

Sets the width member (does not affect the icon data).

Parameters:

  • width (int): the width member

See also

SetHeight


Properties

Depth
See GetDepth and SetDepth
Height
See GetHeight and SetHeight
Width
See GetWidth and SetWidth