diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c9d283e..8e066acf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ CHANGELOG for FlatCAM Evo beta 18.04.2022 - in Geometry Editor, in Copy Tool added the 2D copy-as-array feature therefore finishing this editor plugin upgrade +- updated the FCLabel widget 17.04.2022 diff --git a/appGUI/GUIElements.py b/appGUI/GUIElements.py index 1ef72cc8..2a1ae714 100644 --- a/appGUI/GUIElements.py +++ b/appGUI/GUIElements.py @@ -2970,9 +2970,36 @@ class FCLabel(QtWidgets.QLabel): right_clicked = QtCore.pyqtSignal(bool) middle_clicked = QtCore.pyqtSignal(bool) - def __init__(self, parent=None): + def __init__(self, title, color=None, color_callback=None, bold=None, parent=None): + """ + + :param title: the label's text + :type title: str + :param color: text color + :type color: str + :param color_callback: function to alter the color + :type color_callback: function + :param bold: the text weight + :type bold: bool + :param parent: parent of this widget + :type parent: QtWidgets.QWidget | None + """ + super(FCLabel, self).__init__(parent) + if color and color_callback: + color = color_callback(color) + + if isinstance(title, str): + if color and not bold: + self.setText('%s' % (str(color), title)) + elif not color and bold: + self.setText('%s' % title) + elif color and bold: + self.setText('%s' % (str(color), title)) + else: + self.setText(title) + # for the usage of this label as a clickable label, to know that current state self.clicked_state = False self.middle_clicked_state = False @@ -5380,7 +5407,7 @@ class FlatCAMActivityView(QtWidgets.QWidget): self.movie_path = movie self.icon_path = icon - self.icon = FCLabel(self) + self.icon = FCLabel(parent=self) self.icon.setGeometry(0, 0, 16, 12) self.movie = QtGui.QMovie(self.movie_path)