1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 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
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>Palette</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.Palette_inheritance.png" alt="Inheritance diagram of Palette" usemap="#dummy" class="inheritance"/></center>
</div>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Palette.html" title="wx.Palette" alt="" coords="15,160,101,189"/> <area shape="rect" id="node2" href="wx.GDIObject.html" title="wx.GDIObject" alt="" coords="5,83,112,112"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="17,5,99,35"/> </map>
</p>
|
|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:
**~~~**
**__init__** `(self)`
Default constructor.
**~~~**
**__init__** `(self, palette)`
Copy constructor, uses :ref:`Reference Counting <reference counting>`.
:param `palette`: A reference to the palette to copy.
:type `palette`: wx.Palette
**~~~**
**__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.
**~~~**
.. 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`
|