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 303
|
.. 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
.. module:: wx.lib.agw.cubecolourdialog
.. currentmodule:: wx.lib.agw.cubecolourdialog
.. highlight:: python
.. _wx.lib.agw.cubecolourdialog:
==========================================================================================================================================
|phoenix_title| **wx.lib.agw.cubecolourdialog**
==========================================================================================================================================
:class:`~wx.lib.agw.cubecolourdialog.CubeColourDialog` is an alternative implementation of :class:`wx.ColourDialog`.
Description
===========
The :class:`CubeColourDialog` is an alternative implementation of :class:`wx.ColourDialog`, and it
offers different functionalities with respect to the default wxPython one. It
can be used as a replacement of :class:`wx.ColourDialog` with exactly the same syntax and
methods.
Some features:
- RGB components may be controlled using spin controls or with mouse gestures
on a 3D RGB cube, with the 3 components laying on the X, Y, Z axes;
- HSB components may be controlled using spin controls or with mouse gestures
on a 2D colour wheel;
- Brightness has its own vertical slider to play with;
- The colour alpha channel can be controlled using another vertical slider, or
via spin control;
- The colour alpha channel controls can be completely hidden at startup or the
choice to use the alpha channel can be left to the user while playing with the
dialog, via a simple :class:`CheckBox`;
- The "old colour" and "new colour" are displayed in two small custom panel,
which support alpha transparency and texture;
- :class:`CubeColourDialog` displays also the HTML colour code in hexadecimal format;
- When available, a corresponding "Web Safe" colour is generated using a 500
web colours "database" (a dictionary inside the widget source code). Web Safe
colours are recognized by all the browsers;
- When available, a corresponding "HTML name" for the selected colour is displayed,
by using the same 500 web colours "database";
- When available, a corresponding "Microsoft Access Code" for the selected colour
is displayed, by using the same 500 web colours "database".
And much more.
Usage
=====
Usage example::
import wx
import wx.lib.agw.cubecolourdialog as CCD
# Our normal wxApp-derived class, as usual
app = wx.App(0)
colourData = wx.ColourData()
dlg = CCD.CubeColourDialog(None, colourData)
if dlg.ShowModal() == wx.ID_OK:
# If the user selected OK, then the dialog's wx.ColourData will
# contain valid information. Fetch the data ...
colourData = dlg.GetColourData()
h, s, v, a = dlg.GetHSVAColour()
# ... then do something with it. The actual colour data will be
# returned as a three-tuple (r, g, b) in this particular case.
colour = colourData.GetColour()
r, g, b, alpha = colour.Red(), colour.Green(), colour.Blue(), colour.Alpha()
print("You selected (RGBA): %d, %d, %d, %d"%(r, g, b, alpha))
print("You selected (HSVA): %d, %d, %d, %d"%(h, s, v, a))
# Once the dialog is destroyed, Mr. wx.ColourData is no longer your
# friend. Don't use it again!
dlg.Destroy()
app.MainLoop()
Window Styles
=============
This class supports the following window styles:
================== =========== ==================================================
Window Styles Hex Value Description
================== =========== ==================================================
``CCD_SHOW_ALPHA`` 0x1 Show the widget used to control colour alpha channels in :class:`CubeColourDialog`.
================== =========== ==================================================
Events Processing
=================
`No custom events are available for this class.`
License And Version
===================
:class:`CubeColourDialog` is distributed under the wxPython license.
Latest Revision: Andrea Gavana @ 19 Dec 2012, 21.00 GMT
Version 0.5.
|function_summary| Functions Summary
====================================
================================================================================ ================================================================================
:func:`~wx.lib.agw.cubecolourdialog.AngleFromPoint` Returns the angle between the x-axis and the line connecting the center and
:func:`~wx.lib.agw.cubecolourdialog.deg2rad` Transforms degrees into radians.
:func:`~wx.lib.agw.cubecolourdialog.Distance` Returns the distance between 2 points.
:func:`~wx.lib.agw.cubecolourdialog.DrawCheckerBoard` Draws a checkerboard on a :class:`wx.DC`.
:func:`~wx.lib.agw.cubecolourdialog.FindC` Internal function.
:func:`~wx.lib.agw.cubecolourdialog.Intersection` Calculates the intersection point between 2 lines.
:func:`~wx.lib.agw.cubecolourdialog.PointOnLine` Internal function.
:func:`~wx.lib.agw.cubecolourdialog.PtFromAngle` Given the angle with respect to the x-axis, returns the point based on
:func:`~wx.lib.agw.cubecolourdialog.rad2deg` Transforms radians into degrees.
:func:`~wx.lib.agw.cubecolourdialog.RestoreOldDC` Restores the old settings for a :class:`wx.DC`.
:func:`~wx.lib.agw.cubecolourdialog.rgb2html` Transforms a RGB triplet into an html hex string.
:func:`~wx.lib.agw.cubecolourdialog.scaletomax` Normalize a value as a function of the radius.
:func:`~wx.lib.agw.cubecolourdialog.Slope` Calculates the slope of the line connecting 2 points.
:func:`~wx.lib.agw.cubecolourdialog.toscale` Normalize a value as a function of the radius.
================================================================================ ================================================================================
|
|class_summary| Classes Summary
===============================
================================================================================ ================================================================================
:ref:`~wx.lib.agw.cubecolourdialog.AlphaCtrl` Implements the drawing, mouse handling and sizing routines for the alpha
:ref:`~wx.lib.agw.cubecolourdialog.BaseLineCtrl` Base class used to hold common code for the Alpha channel control and the
:ref:`~wx.lib.agw.cubecolourdialog.BasePyControl` Base class used to hold common code for the HSB colour wheel and the RGB
:ref:`~wx.lib.agw.cubecolourdialog.BrightCtrl` Implements the drawing, mouse handling and sizing routines for the brightness
:ref:`~wx.lib.agw.cubecolourdialog.Colour` This is a subclass of :class:`wx.Colour`, which adds Hue, Saturation and Brightness
:ref:`~wx.lib.agw.cubecolourdialog.ColourPanel` Simple custom class used to display "old" and "new" colour panels, with alpha
:ref:`~wx.lib.agw.cubecolourdialog.CubeColourDialog` This is the CubeColourDialog main class implementation.
:ref:`~wx.lib.agw.cubecolourdialog.CustomPanel` This panel displays a series of custom colours (chosen by the user) just like
:ref:`~wx.lib.agw.cubecolourdialog.HSVWheel` Implements the drawing, mouse handling and sizing routines for the HSV
:ref:`~wx.lib.agw.cubecolourdialog.LineDescription` Simple class to store description and constants for a line in 2D space.
:ref:`~wx.lib.agw.cubecolourdialog.RGBCube` Implements the drawing, mouse handling and sizing routines for the RGB
================================================================================ ================================================================================
|
.. toctree::
:maxdepth: 1
:hidden:
wx.lib.agw.cubecolourdialog.AlphaCtrl
wx.lib.agw.cubecolourdialog.BaseLineCtrl
wx.lib.agw.cubecolourdialog.BasePyControl
wx.lib.agw.cubecolourdialog.BrightCtrl
wx.lib.agw.cubecolourdialog.Colour
wx.lib.agw.cubecolourdialog.ColourPanel
wx.lib.agw.cubecolourdialog.CubeColourDialog
wx.lib.agw.cubecolourdialog.CustomPanel
wx.lib.agw.cubecolourdialog.HSVWheel
wx.lib.agw.cubecolourdialog.LineDescription
wx.lib.agw.cubecolourdialog.RGBCube
Functions
------------
.. function:: AngleFromPoint(pt, center)
Returns the angle between the x-axis and the line connecting the center and
the point `pt`.
:param `pt`: an instance of :class:`wx.Point`;
:param `center`: a float value representing the center.
.. function:: deg2rad(x)
Transforms degrees into radians.
:param `x`: a float representing an angle in degrees.
.. function:: Distance(pt1, pt2)
Returns the distance between 2 points.
:param `pt1`: an instance of :class:`wx.Point`;
:param `pt2`: another instance of :class:`wx.Point`.
.. function:: DrawCheckerBoard(dc, rect, checkColour, box=5)
Draws a checkerboard on a :class:`wx.DC`.
:param `dc`: an instance of :class:`wx.DC`;
:param `rect`: the client rectangle on which to draw the checkerboard;
:param `checkColour`: the colour used for the dark checkerboards;
:param `box`: the checkerboards box sizes.
:note: Used for the Alpha channel control and the colour panels.
.. function:: FindC(line)
Internal function.
.. function:: Intersection(line1, line2)
Calculates the intersection point between 2 lines.
:param `line1`: an instance of :class:`LineDescription`;
:param `line2`: another instance of :class:`LineDescription`.
.. function:: PointOnLine(pt1, pt2, length, maxLen)
Internal function.
.. function:: PtFromAngle(angle, sat, center)
Given the angle with respect to the x-axis, returns the point based on
the saturation value.
:param `angle`: a float representing an angle;
:param `sat`: a float representing the colour saturation value;
:param `center`: a float value representing the center.
.. function:: rad2deg(x)
Transforms radians into degrees.
:param `x`: a float representing an angle in radians.
.. function:: RestoreOldDC(dc, oldPen, oldBrush, oldMode)
Restores the old settings for a :class:`wx.DC`.
:param `dc`: an instance of :class:`wx.DC`;
:param `oldPen`: an instance of :class:`wx.Pen`;
:param `oldBrush`: an instance of :class:`wx.Brush`;
:param `oldMode`: the :class:`wx.DC` drawing mode bit.
.. function:: rgb2html(colour)
Transforms a RGB triplet into an html hex string.
:param `colour`: a tuple of red, green, blue integers.
.. function:: scaletomax(x)
Normalize a value as a function of the radius.
:param `x`: a float value to normalize
.. function:: Slope(pt1, pt2)
Calculates the slope of the line connecting 2 points.
:param `pt1`: an instance of :class:`wx.Point`;
:param `pt2`: another instance of :class:`wx.Point`.
.. function:: toscale(x)
Normalize a value as a function of the radius.
:param `x`: a float value to normalize
|