.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. _wx.Palette: ========================================================================================================================================== |phoenix_title| **wx.Palette** ========================================================================================================================================== A palette is a table that maps pixel values to ``RGB`` colours. It allows the colours of a low-depth bitmap, for example, to be mapped to the available colours in a display. The notion of palettes is becoming more and more obsolete nowadays and only the MSW port is still using a native palette. All other ports use generic code which is basically just an array of colours. It is likely that in the future the only use for palettes within wxWidgets will be for representing colour indices from images (such as ``GIF`` or ``PNG``). The image handlers for these formats have been modified to create a palette if there is such information in the original image file (usually 256 or less colour images). See :ref:`wx.Image` for more information. .. seealso:: :meth:`wx.DC.SetPalette` , :ref:`wx.Bitmap` | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class Palette:
| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.Palette.__init__` Default constructor. :meth:`~wx.Palette.Create` Creates a palette from 3 sequences of integers, one for each red, blue or green component. :meth:`~wx.Palette.GetColoursCount` Returns number of entries in palette. :meth:`~wx.Palette.GetPixel` Returns a pixel value (index into the palette) for the given ``RGB`` values. :meth:`~wx.Palette.GetRGB` Returns ``RGB`` values for a given palette index. :meth:`~wx.Palette.IsOk` Returns ``True`` if palette data is present. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~wx.Palette.ColoursCount` See :meth:`~wx.Palette.GetColoursCount` :attr:`~wx.Palette.RGB` See :meth:`~wx.Palette.GetRGB` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.Palette(GDIObject) **Possible constructors**:: Palette() Palette(palette) Palette(red, green, blue) A palette is a table that maps pixel values to ``RGB`` colours. .. method:: __init__(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **__init__** `(self)` Default constructor. :html:`

` **__init__** `(self, palette)` Copy constructor, uses :ref:`Reference Counting `. :param `palette`: A reference to the palette to copy. :type `palette`: wx.Palette :html:`

` **__init__** `(self, red, green, blue)` Creates a palette from a set of sequences of integers, one for each red, green and blue color components. :param red: A sequence of integer values in the range 0..255 inclusive. :param green: A sequence of integer values in the range 0..255 inclusive. :param blue: A sequence of integer values in the range 0..255 inclusive. .. note:: All sequences must be the same length. :html:`

` .. method:: Create(self, red, green, blue) Creates a palette from 3 sequences of integers, one for each red, blue or green component. :param red: A sequence of integer values in the range 0..255 inclusive. :param green: A sequence of integer values in the range 0..255 inclusive. :param blue: A sequence of integer values in the range 0..255 inclusive. .. note:: All sequences must be the same length. :rtype: `bool` .. method:: GetColoursCount(self) Returns number of entries in palette. :rtype: `int` .. method:: GetPixel(self, red, green, blue) Returns a pixel value (index into the palette) for the given ``RGB`` values. :param `red`: Red value. :type `red`: int :param `green`: Green value. :type `green`: int :param `blue`: Blue value. :type `blue`: int :rtype: `int` :returns: The nearest palette index or ``NOT_FOUND`` for unexpected errors. .. seealso:: :meth:`GetRGB` .. method:: GetRGB(self, pixel) Returns ``RGB`` values for a given palette index. :rtype: `tuple` :returns: ( `red`, `green`, `blue` ) .. method:: IsOk(self) Returns ``True`` if palette data is present. :rtype: `bool` .. attribute:: ColoursCount See :meth:`~wx.Palette.GetColoursCount` .. attribute:: RGB See :meth:`~wx.Palette.GetRGB`