******* wx.Icon ******* Inheritance diagram for `wx.Icon`: | .. inheritance-diagram:: 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. .. seealso:: `wx.DC.DrawIcon `_, `wx.Cursor `_ Derived From ^^^^^^^^^^^^^ * `wx.Bitmap `_ * `wx.GDIObject `_ * `wx.Object `_ 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. Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `CopyFromBitmap <#CopyFromBitmap>`_ * `GetDepth <#GetDepth>`_ * `GetHeight <#GetHeight>`_ * `GetWidth <#GetWidth>`_ * `IsOk <#IsOk>`_ * `LoadFile <#LoadFile>`_ * `SetDepth <#SetDepth>`_ * `SetHeight <#SetHeight>`_ * `SetWidth <#SetWidth>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `Depth <#Depth>`_ * `Height <#Height>`_ * `Width <#Width>`_ Class API ========= Methods ^^^^^^^ .. method:: __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 `_ -------- .. method:: CopyFromBitmap(bmp) Copies `bmp` bitmap to this icon. Under MS Windows the bitmap must have mask colour set. **Parameters:** * `bmp` (`wx.Bitmap `_) .. seealso:: `LoadFile <#LoadFile>`_ -------- .. method:: GetDepth() Gets the colour depth of the icon. A value of 1 indicates a monochrome icon. | **Returns:** `int` -------- .. method:: GetHeight() Gets the height of the icon in pixels. | **Returns:** `int` .. seealso:: `GetWidth <#GetWidth>`_ -------- .. method:: GetWidth() Gets the width of the icon in pixels. | **Returns:** `int` .. seealso:: `GetHeight <#GetHeight>`_ -------- .. method:: IsOk() Returns true if icon data is present. | **Returns:** `bool` -------- .. method:: 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 -------- .. method:: SetDepth(depth) Sets the depth member (does not affect the icon data). **Parameters:** * `depth` (int): the depth member -------- .. method:: SetHeight(height) Sets the height member (does not affect the icon data). **Parameters:** * `height` (int): the height member .. seealso:: `SetWidth <#SetWidth>`_ -------- .. method:: SetWidth(width) Sets the width member (does not affect the icon data). **Parameters:** * `width` (int): the width member .. seealso:: `SetHeight <#SetHeight>`_ -------- Properties ^^^^^^^^^^ .. attribute:: Depth See `GetDepth <#GetDepth>`_ and `SetDepth <#SetDepth>`_ .. attribute:: Height See `GetHeight <#GetHeight>`_ and `SetHeight <#SetHeight>`_ .. attribute:: Width See `GetWidth <#GetWidth>`_ and `SetWidth <#SetWidth>`_