def _set_from(slot, val):
    """Connect a :class:`~madgui.util.collections.Bool` to the given slot.
    This is used to keep the state of ``QAction.checked`` and ``.enabled``
    properties synchronized."""
    if val is not None:
        try:
            cur = val()
            val.changed.connect(slot)
        except TypeError:
            cur = val
        slot(cur)
