def __init__(self, color, parent=None): QToolButton.__init__(self, parent) self.setIconSize(QSize(50, 25)) self.pix = QPixmap(self.iconSize()) self._color = QColor('#' + color) self.pix.fill(self._color) self.setIcon(QIcon(self.pix)) self.clicked.connect(self.choose_color)
def __init__(self, icon, text, splitter=None, parent=None, shortcut=None): QToolButton.__init__(self, parent) self.label = text self.setIcon(QIcon(icon)) self.setCheckable(True) self.icname = os.path.basename(icon).rpartition('.')[0] self.splitter = splitter if splitter is not None: splitter.state_changed.connect(self.update_state) self.setCursor(Qt.CursorShape.PointingHandCursor) self.shortcut = shortcut or ''
def __init__(self, *args): QToolButton.__init__(self, *args) # vertically size policy must be expanding for it to align inside a # toolbar self.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Expanding) self._icon_size = -1 QToolButton.setIcon(self, QIcon(I('donate.png'))) self.setText('\xa0') self.animation = QPropertyAnimation(self, b'icon_size', self) self.animation.setDuration(int(60/72.*1000)) self.animation.setLoopCount(4) self.animation.valueChanged.connect(self.value_changed) self.setCursor(Qt.CursorShape.PointingHandCursor) self.animation.finished.connect(self.animation_finished)