--- a/src/eric7/EricWidgets/EricLineEditButton.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/EricWidgets/EricLineEditButton.py Wed Jul 13 14:55:47 2022 +0200 @@ -16,44 +16,45 @@ """ Class implementing a button to be used with EricLineEdit. """ + def __init__(self, parent=None): """ Constructor - + @param parent reference to the parent widget (QWidget) """ super().__init__(parent) - + self.__menu = None self.__image = None - + self.setFocusPolicy(Qt.FocusPolicy.NoFocus) self.setCursor(Qt.CursorShape.ArrowCursor) self.setMinimumSize(16, 16) - + self.clicked.connect(self.__clicked) - + def setMenu(self, menu): """ Public method to set the button menu. - + @param menu reference to the menu (QMenu) """ self.__menu = menu self.update() - + def menu(self): """ Public method to get a reference to the menu. - + @return reference to the associated menu (QMenu) """ return self.__menu - + def setIcon(self, icon): """ Public method to set the button icon. - + @param icon icon to be set (QIcon) """ if icon.isNull(): @@ -61,7 +62,7 @@ else: self.__image = icon.pixmap(16, 16).toImage() super().setIcon(icon) - + def __clicked(self): """ Private slot to handle a button click. @@ -69,20 +70,20 @@ if self.__menu: pos = self.mapToGlobal(QPoint(0, self.height())) self.__menu.exec(pos) - + def paintEvent(self, evt): """ Protected method handling a paint event. - + @param evt reference to the paint event (QPaintEvent) """ painter = QPainter(self) - + if self.__image is not None and not self.__image.isNull(): x = (self.width() - self.__image.width()) // 2 - 1 y = (self.height() - self.__image.height()) // 2 - 1 painter.drawImage(x, y, self.__image) - + if self.__menu is not None: triagPath = QPainterPath() startPos = QPointF(self.width() - 5, self.height() - 3)