doc: revisions to uix/colorpicker.py

This commit is contained in:
Richard Larkin 2013-09-15 10:40:51 +02:00
parent 332d346f34
commit 4abdc6bacc
1 changed files with 28 additions and 28 deletions

View File

@ -6,18 +6,18 @@ Color Picker
.. warning::
This widget is experimental. Its use and API can change any time, until
This widget is experimental. Its use and API can change at any time until
this warning is removed.
The ColorPicker widget allows a user to pick a color utilizing from a chromatic
wheel where pinch/zoom can be used to change available colors or using a slider
or directly entering the colors in the text boxes.
The ColorPicker widget allows a user to select a color from a chromatic
wheel where pinch and zoom can be used to change the selected color. Sliders
and TextInputs are also provided for entering the RGBA/HSV/HEX values directly.
Usage::
clr_picker = ColorPicker()
parent.add_widget(ColorPicker)
parent.add_widget(clr_picker)
# print currently selected color in rgba format
print(clr_picker.color)
# print currently selected color in hsv format
@ -68,49 +68,49 @@ def rect_to_polar(origin, x, y):
class ColorWheel(Widget):
'''Chromatic wheel for the ColorPiker.
'''Chromatic wheel for the ColorPicker.
.. versionchanged:: 1.7.1
`font_size`, `font_name`, `foreground_color` have been removed. The
`font_size`, `font_name` and `foreground_color` have been removed. The
sizing is now the same as others widget, based on 'sp'. Orientation is
also automatically determined according to the ratio width/height.
also automatically determined according to the width/height ratio.
'''
r = BoundedNumericProperty(0, min=0, max=1)
'''The Red value of the color currently selected.
:data:`r` is an :class:`~kivy.properties.BoundedNumericProperty`
can be a value from 0 to 1 default to 0.
:data:`r` is a :class:`~kivy.properties.BoundedNumericProperty` and
can be a value from 0 to 1. It defaults to 0.
'''
g = BoundedNumericProperty(0, min=0, max=1)
'''The Green value of the color currently selected.
:data:`g` is an :class:`~kivy.properties.BoundedNumericProperty`
can be a value from 0 to 1
:data:`g` is a :class:`~kivy.properties.BoundedNumericProperty`
and can be a value from 0 to 1.
'''
b = BoundedNumericProperty(0, min=0, max=1)
'''The Blue value of the color currently selected.
:data:`b` is an :class:`~kivy.properties.BoundedNumericProperty`
:data:`b` is a :class:`~kivy.properties.BoundedNumericProperty` and
can be a value from 0 to 1.
'''
a = BoundedNumericProperty(0, min=0, max=1)
'''The Alpha value of the color currently selected.
:data:`r` is an :class:`~kivy.properties.BoundedNumericProperty`
:data:`a` is a :class:`~kivy.properties.BoundedNumericProperty` and
can be a value from 0 to 1.
'''
color = ReferenceListProperty(r, g, b, a)
'''The holds the color currently selected.
:data:`color` is an :class:`~kivy.properties.ReferenceListProperty`
a list of `r`, `g`, `b`, `a`.
:data:`color` is a :class:`~kivy.properties.ReferenceListProperty` and
contains a list of `r`, `g`, `b`, `a` values.
'''
_origin = ListProperty((100, 100))
@ -365,24 +365,24 @@ class ColorPicker(RelativeLayout):
'''
font_name = StringProperty('data/fonts/DroidSansMono.ttf')
'''Specifies the font used used on the Color Picker
'''Specifies the font used on the ColorPicker.
:data:`font_name` is an :class:`~kivy.properties.StringProperty`
defaults to 'data/fonts/DroidSansMono.ttf'
:data:`font_name` is a :class:`~kivy.properties.StringProperty` and
defaults to 'data/fonts/DroidSansMono.ttf'.
'''
color = ListProperty((1, 1, 1, 1))
'''The :data:`color` holds the color currently selected in rgba format.
:data:`color` is an :class:`~kivy.properties.ListProperty` defaults to
(1, 1, 1, 1)
:data:`color` is a :class:`~kivy.properties.ListProperty` and defaults to
(1, 1, 1, 1).
'''
hsv = ListProperty((1, 1, 1))
'''The :data:`hsv` holds the color currently selected in hsv format.
:data:`hsv` is an :class:`~kivy.properties.ListProperty` defaults to
(1, 1, 1)
:data:`hsv` is a :class:`~kivy.properties.ListProperty` and defaults to
(1, 1, 1).
'''
def _get_hex(self):
return get_hex_from_color(self.color)
@ -393,15 +393,15 @@ class ColorPicker(RelativeLayout):
hex_color = AliasProperty(_get_hex, _set_hex, bind=('color', ))
'''The :data:`hex_color` holds the currently selected color in hex.
:data:`hex_color` is a :class:`~kivy.properties.AliasProperty` default to
`#ffffffff`
:data:`hex_color` is an :class:`~kivy.properties.AliasProperty` and
defaults to `#ffffffff`.
'''
wheel = ObjectProperty(None)
'''The :data:`wheel` holds the color wheel.
:data:`wheel` is an :class:`~kivy.properties.ObjectProperty` defaults to
None
:data:`wheel` is an :class:`~kivy.properties.ObjectProperty` and defaults to
None.
'''
# now used only internally.
@ -433,7 +433,7 @@ class ColorPicker(RelativeLayout):
else:
self.hsv[clr_idx] = float(text) / 255.
except ValueError:
Logger.warning('Color Picker: invalid value : {}'.format(text))
Logger.warning('ColorPicker: invalid value : {}'.format(text))
def _update_hex(self, dt):
if len(self._upd_hex_list) != 9: