<commit_before>'''
Behaviors
=========

.. versionadded:: 1.8.0

This module implements behaviors that can be mixed with existing base widgets.
For example, if you want to add a "button" capability to an `Image`, you could
do::


    class IconButton(ButtonBehavior, Image):
        pass

.. note::<commit_msg>doc: added examples to uix/behaviors.py<commit_after>'''
Behaviors
=========

.. versionadded:: 1.8.0

This module implements behaviors that can be mixed with existing base widgets.
For example, if you want to add a "button" capability to an `Image`, you could
do::


    class IconButton(ButtonBehavior, Image):
        pass

This would give you an `Image` with the events and properties inherited from
:class:`ButtonBehavior`. For example, the *on_press* and *on_release* events
would be fired when appropriate::

    class IconButton(ButtonBehavior, Image):
        def on_press(self):
            print("on_press")

Or in kv::

    IconButton:
        on_press: print('on_press')

Naturally, you could also bind to any property changes the behavior class
offers::

        def state_changed(*args):
            print('state changed')

        button = IconButton()
        button.bind(state=state_changed)


.. note::
{'fraction_non_alphanumeric': 0.10560519902518278, 'fraction_numerical': 0.00487408610885459, 'mean_word_length': 3.4963503649635035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6305020', 'n_tokens_mistral': 350, 'n_tokens_neox': 335, 'n_words': 135}