(buttonbox, enabled)
Disable/enable buttons in a QDialogButtonBox based on their role.

    All buttons except the ones with RejectRole or HelpRole are disabled.
Disable/enable buttons in a QDialogButtonBox based on their role.
Disable / enable buttons in a QDialogButtonBox based on their role .
def dialog_button_box_set_enabled(buttonbox, enabled):
    # type: (QDialogButtonBox, bool) -> None
    """
    Disable/enable buttons in a QDialogButtonBox based on their role.

    All buttons except the ones with RejectRole or HelpRole are disabled.
    """
    stashname = "__p_dialog_button_box_set_enabled"
    for b in buttonbox.buttons():
        role = buttonbox.buttonRole(b)
        if not enabled:
            if b.property(stashname) is None:
                b.setProperty(stashname, b.isEnabledTo(buttonbox))
            b.setEnabled(
                role == QDialogButtonBox.RejectRole or
                role == QDialogButtonBox.HelpRole
            )
        else:
            stashed_state = b.property(stashname)
            if isinstance(stashed_state, bool):
                state = stashed_state
                b.setProperty(stashname, None)
            else:
                state = True
            b.setEnabled(state)
def dialog_button_box_set_enabled ( buttonbox , enabled ) : # type: (QDialogButtonBox, bool) -> None stashname = "__p_dialog_button_box_set_enabled" for b in buttonbox . buttons ( ) : role = buttonbox . buttonRole ( b ) if not enabled : if b . property ( stashname ) is None : b . setProperty ( stashname , b . isEnabledTo ( buttonbox ) ) b . setEnabled ( role == QDialogButtonBox . RejectRole or role == QDialogButtonBox . HelpRole ) else : stashed_state = b . property ( stashname ) if isinstance ( stashed_state , bool ) : state = stashed_state b . setProperty ( stashname , None ) else : state = True b . setEnabled ( state )