def test_button(self): # Run through various state change and drawing code for coverage b = buttons.SimpleButton() b.setIcon(b.style().standardIcon(QStyle.SP_ComputerIcon)) QApplication.sendEvent(b, QFocusEvent(QFocusEvent.FocusIn)) QApplication.sendEvent(b, QFocusEvent(QFocusEvent.FocusOut)) b.grab() b.setDown(True) b.grab() b.setCheckable(True) b.setChecked(True) b.grab()
def focusOutEvent(self, event: QFocusEvent) -> None: super().focusOutEvent(event) if self.__editing and event.reason() not in { Qt.ActiveWindowFocusReason, Qt.PopupFocusReason }: self.__endEdit()
def focusInEvent(self, event: QFocusEvent) -> None: super().focusInEvent(event) if self.textInteractionFlags() & Qt.TextEditable \ and not self.__editing \ and self.__editTriggers & EditTriggers.CurrentChanged: self.__startEdit(event.reason())