<commit_before># The functions in this module are used to connect callback properties to Qt
# widgets.

from __future__ import absolute_import, division, print_function

import math
from functools import partial

from .. import add_callback

__all__ = ['connect_checkable_button', 'connect_text', 'connect_combo_data',
           'connect_combo_text', 'connect_float_text', 'connect_value']


def connect_checkable_button(instance, prop, widget):
    """
    Connect a boolean callback property with a Qt button widget.

    Parameters
    ----------
    instance : object
        The class instance that the callback property is attached to
    prop : str
        The name of the callback property
    widget : QtWidget
        The Qt widget to connect. This should implement the ``setChecked``
        method and the ``toggled`` signal.
    """
    add_callback(instance, prop, widget.setChecked)
    widget.toggled.connect(partial(setattr, instance, prop))
    widget.setChecked(getattr(instance, prop))


def connect_text(instance, prop, widget):
    """
    Connect a string callback property with a Qt widget containing text.
<commit_msg>Small fix to checkbox connection code<commit_after># The functions in this module are used to connect callback properties to Qt
# widgets.

from __future__ import absolute_import, division, print_function

import math
from functools import partial

from .. import add_callback

__all__ = ['connect_checkable_button', 'connect_text', 'connect_combo_data',
           'connect_combo_text', 'connect_float_text', 'connect_value']


def connect_checkable_button(instance, prop, widget):
    """
    Connect a boolean callback property with a Qt button widget.

    Parameters
    ----------
    instance : object
        The class instance that the callback property is attached to
    prop : str
        The name of the callback property
    widget : QtWidget
        The Qt widget to connect. This should implement the ``setChecked``
        method and the ``toggled`` signal.
    """
    add_callback(instance, prop, widget.setChecked)
    widget.toggled.connect(partial(setattr, instance, prop))
    widget.setChecked(getattr(instance, prop) or False)


def connect_text(instance, prop, widget):
    """
    Connect a string callback property with a Qt widget containing text.

{'fraction_non_alphanumeric': 0.08013787160706592, 'fraction_numerical': 0.0, 'mean_word_length': 3.6254980079681274, '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': '7036503', 'n_tokens_mistral': 606, 'n_tokens_neox': 598, 'n_words': 231}