效果预览
实现代码
from PyQt5.QtWidgets import QCheckBox, QApplication, QWidget, QVBoxLayout
from PyQt5.QtCore import Qt, QRect, QPropertyAnimation, QEasingCurve, pyqtProperty
from PyQt5.QtGui import QPainter, QColor, QPen, QFontclass CompactSwitchCheckbox(QCheckBox):def __init__(self, parent=None):super().__init__(parent)# 调整控件的整体尺寸为 60x30self.setFixedSize(60, 30)