U
    Pe                  	   @   s   d Z dZddlmZmZmZ ddlmZ ddlm	Z	 G dd dee	Z
edkrdd	lmZ dd
lmZ ddlmZ eddZedD ]BZdd edD \ZZZee
ed rdndeeedgd qee dS )a  
CheckBox
========

.. versionadded:: 1.4.0

.. image:: images/checkbox.png
    :align: right

:class:`CheckBox` is a specific two-state button that can be either checked or
unchecked. If the CheckBox is in a Group, it becomes a Radio button.
As with the :class:`~kivy.uix.togglebutton.ToggleButton`, only one Radio button
at a time can be selected when the :attr:`CheckBox.group` is set.

An example usage::

    from kivy.uix.checkbox import CheckBox

    # ...

    def on_checkbox_active(checkbox, value):
        if value:
            print('The checkbox', checkbox, 'is active')
        else:
            print('The checkbox', checkbox, 'is inactive')

    checkbox = CheckBox()
    checkbox.bind(active=on_checkbox_active)
)CheckBox    )AliasPropertyStringPropertyColorProperty)ToggleButtonBehavior)Widgetc                       s   e Zd ZdZdd Zdd ZeeedddZed	Z	ed
Z
edZedZedZedZedZedZeddddgZ fddZdd Z fddZ  ZS )r   zCCheckBox class, see module documentation for more information.
    c                 C   s
   | j dkS Ndownstate)self r   5/tmp/pip-unpacked-wheel-xzebddm3/kivy/uix/checkbox.py_get_active*   s    zCheckBox._get_activec                 C   s   |rdnd| _ d S )Nr	   normalr
   )r   valuer   r   r   _set_active-   s    zCheckBox._set_activer
   T)bindcachez-atlas://data/images/defaulttheme/checkbox_offz,atlas://data/images/defaulttheme/checkbox_onz6atlas://data/images/defaulttheme/checkbox_disabled_offz5atlas://data/images/defaulttheme/checkbox_disabled_onz3atlas://data/images/defaulttheme/checkbox_radio_offz2atlas://data/images/defaulttheme/checkbox_radio_onz<atlas://data/images/defaulttheme/checkbox_radio_disabled_offz;atlas://data/images/defaulttheme/checkbox_radio_disabled_on   c                    s$   |  d| j tt| jf | d S )Nr   )Zfbind	_on_statesuperr   __init__)r   kwargs	__class__r   r   r      s    zCheckBox.__init__c                 C   s   | j r| jdkr| |  d S r   )groupr   _release_group)r   instancer   r   r   r   r      s    zCheckBox._on_statec                    s$   t t| j|  | jr | |  d S )N)r   r   on_groupactiver   )r   largsr   r   r   r      s    zCheckBox.on_group)__name__
__module____qualname____doc__r   r   r   r    r   Zbackground_checkbox_normalZbackground_checkbox_downZ#background_checkbox_disabled_normalZ!background_checkbox_disabled_downZbackground_radio_normalZbackground_radio_downZ background_radio_disabled_normalZbackground_radio_disabled_downr   colorr   r   r   __classcell__r   r   r   r   r   &   sJ      r   __main__uniform)runTouchApp)
GridLayout   )cols$   c                 C   s   g | ]}t d dqS )g?g      ?r)   ).0jr   r   r   
<listcomp>   s     r2         1 )r   r&   N)r%   __all__Zkivy.propertiesr   r   r   Zkivy.uix.behaviorsr   Zkivy.uix.widgetr   r   r"   randomr*   Z	kivy.baser+   Zkivy.uix.gridlayoutr,   xrangeirgbZ
add_widgetr   r   r   r   <module>   s    
(