def __init__(self, *args): QtWidgets.QFrame.__init__(self, *args) layout = QtWidgets.QHBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) self._label = QtWidgets.QLabel("", self) self._label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self._label.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) layout.addWidget(self._label) self._progressBar = QtWidgets.QProgressBar(self) self._progressBar.setFormat("") self._progressBar.setRange(0, 100) self._progressBar.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) layout.addWidget(self._progressBar) self.setLayout(layout)
def __init__(self, parent=None, width=None, height=None, enableInputEdit=False, enableDontShowCheckBox=False): super(MessageBox, self).__init__(parent) self.setObjectName("messageBox") self._frame = None self._animation = None self._dontShowCheckbox = False self._clickedButton = None self._clickedStandardButton = None if width: self.setMinimumWidth(width) if height: self.setMinimumHeight(height) parent = self.parent() if parent: parent.installEventFilter(self) self._frame = QtWidgets.QFrame(parent) self._frame.setObjectName("messageBoxFrame") self._frame.show() self.setParent(self._frame) self._header = QtWidgets.QFrame(self) self._header.setObjectName("messageBoxHeaderFrame") self._header.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self._icon = QtWidgets.QLabel(self._header) self._icon.setObjectName("messageBoxIcon") self._icon.hide() self._icon.setScaledContents(True) self._icon.setAlignment(QtCore.Qt.AlignTop) self._icon.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) self._title = QtWidgets.QLabel(self._header) self._title.setObjectName("messageBoxHeaderLabel") self._title.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) hlayout = QtWidgets.QHBoxLayout(self._header) hlayout.setContentsMargins(15, 7, 15, 10) hlayout.setSpacing(10) hlayout.addWidget(self._icon) hlayout.addWidget(self._title) self._header.setLayout(hlayout) bodyLayout = QtWidgets.QVBoxLayout(self) self._body = QtWidgets.QFrame(self) self._body.setObjectName("messageBoxBody") self._body.setLayout(bodyLayout) self._message = QtWidgets.QLabel(self._body) self._message.setWordWrap(True) self._message.setMinimumHeight(15) self._message.setAlignment(QtCore.Qt.AlignLeft) self._message.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) self._message.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) bodyLayout.addWidget(self._message) bodyLayout.setContentsMargins(15, 15, 15, 15) if enableInputEdit: self._inputEdit = QtWidgets.QLineEdit(self._body) self._inputEdit.setObjectName("messageBoxInputEdit") self._inputEdit.setFocus() bodyLayout.addStretch(1) bodyLayout.addWidget(self._inputEdit) bodyLayout.addStretch(10) if enableDontShowCheckBox: msg = "Don't show this message again" self._dontShowCheckbox = QtWidgets.QCheckBox(msg, self._body) bodyLayout.addStretch(10) bodyLayout.addWidget(self._dontShowCheckbox) bodyLayout.addStretch(2) self._buttonBox = QtWidgets.QDialogButtonBox(None, QtCore.Qt.Horizontal, self) self._buttonBox.clicked.connect(self._clicked) self._buttonBox.accepted.connect(self._accept) self._buttonBox.rejected.connect(self._reject) vlayout1 = QtWidgets.QVBoxLayout(self) vlayout1.setContentsMargins(0, 0, 0, 0) vlayout1.addWidget(self._header) vlayout1.addWidget(self._body) bodyLayout.addWidget(self._buttonBox) self.setLayout(vlayout1) self.updateGeometry()