def __init__(self, parent=None): super(MessageBox, self).__init__(parent) self.setMinimumWidth(300) self.setMaximumWidth(400) self._standardButtonClicked = None self._header = QtWidgets.QFrame(self) self._header.setStyleSheet("background-color: rgb(50,150,200,0);") self._header.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self._header.setFixedHeight(46) self._icon = QtWidgets.QLabel(self._header) self._icon.setAlignment(QtCore.Qt.AlignTop) self._icon.setScaledContents(True) self._icon.setFixedWidth(28) self._icon.setFixedHeight(28) self._icon.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) self._title = QtWidgets.QLabel(self._header) self._title.setStyleSheet("font: 14pt bold; color:rgb(255,255,255);") self._title.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) hlayout = QtWidgets.QHBoxLayout(self._header) hlayout.setSpacing(10) hlayout.addWidget(self._icon) hlayout.addWidget(self._title) self._header.setLayout(hlayout) self._message = QtWidgets.QLabel() self._message.setMinimumHeight(50) self._message.setWordWrap(True) self._message.setAlignment(QtCore.Qt.AlignLeft) self._message.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) self._message.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) options = QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel 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) vlayout2 = QtWidgets.QVBoxLayout(self) vlayout2.setSpacing(25) vlayout2.setContentsMargins(15, 5, 15, 5) vlayout2.addWidget(self._message) vlayout2.addWidget(self._buttonBox) vlayout1.addLayout(vlayout2) self.setLayout(vlayout1)
def __init__(self, *args, **kwargs): super(FormWidget, self).__init__(*args, **kwargs) self._schema = [] self._widgets = [] self._validator = None layout = QtWidgets.QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.setLayout(layout) self._optionsFrame = QtWidgets.QFrame(self) self._optionsFrame.setObjectName("optionsFrame") layout = QtWidgets.QVBoxLayout(self._optionsFrame) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self._optionsFrame.setLayout(layout) self._titleWidget = QtWidgets.QPushButton(self) self._titleWidget.setCheckable(True) self._titleWidget.setObjectName("titleWidget") self._titleWidget.toggled.connect(self._titleClicked) self._titleWidget.hide() self.layout().addWidget(self._titleWidget) self.layout().addWidget(self._optionsFrame)
def __init__(self, *args, **kwargs): super(ButtonGroupFieldWidget, self).__init__(*args, **kwargs) self._value = "" self._buttons = {} items = self.data().get('items') widget = QtWidgets.QFrame() layout = QtWidgets.QHBoxLayout(widget) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) widget.setLayout(layout) i = 0 for item in items: i += 1 button = QtWidgets.QPushButton(toTitle(item), self) button.setCheckable(True) callback = functools.partial(self.setValue, item) button.clicked.connect(callback) self._buttons[item] = button if i == 1: button.setProperty('first', True) if i == len(items): button.setProperty('last', True) widget.layout().addWidget(button) self.setWidget(widget)
def createWidget(self, menu): """ This method is called by the QWidgetAction base class. :type menu: QtWidgets.QMenu """ widget = QtWidgets.QFrame(self.parent()) widget.setObjectName("filterByAction") facet = self._facet name = facet.get("name") or "" count = str(facet.get("count", 0)) title = name.replace(".", "").title() label = QtWidgets.QCheckBox(widget) label.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents) label.setText(title) label.installEventFilter(self) label.toggled.connect(self._triggered) label.setChecked(self._checked) label2 = QtWidgets.QLabel(widget) label2.setObjectName("actionCounter") label2.setText(count) layout = QtWidgets.QHBoxLayout(widget) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(label, stretch=1) layout.addWidget(label2) widget.setLayout(layout) return widget
def __init__(self, title, widget, *args, **kwargs): super(GroupBoxWidget, self).__init__(*args, **kwargs) self._widget = None layout = QtWidgets.QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.setLayout(layout) self._titleWidget = QtWidgets.QPushButton(self) self._titleWidget.setCheckable(True) self._titleWidget.setText(title) self._titleWidget.setObjectName("title") self._titleWidget.toggled.connect(self._toggle) self.layout().addWidget(self._titleWidget) self._widgetFrame = QtWidgets.QFrame(self) self._widgetFrame.setObjectName("frame") layout = QtWidgets.QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self._widgetFrame.setLayout(layout) self.layout().addWidget(self._widgetFrame) if widget: self.setWidget(widget)
def createWidget(self, menu): """ This method is called by the QWidgetAction base class. :type menu: QtWidgets.QMenu """ widget = QtWidgets.QFrame(self.parent()) widget.setObjectName("filterByAction") title = self._name # Using a checkbox so that the text aligns with the other actions label = QtWidgets.QCheckBox(widget) label.setText(title) label.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents) label.toggled.connect(self._triggered) label.setStyleSheet(""" #QCheckBox::indicator:checked { image: url(none.png) } QCheckBox::indicator:unchecked { image: url(none.png) } """) actionLayout = QtWidgets.QHBoxLayout(widget) actionLayout.setContentsMargins(0, 0, 0, 0) actionLayout.addWidget(label, stretch=1) widget.setLayout(actionLayout) return widget
def createWidget(self, parent): """ :type parent: QtWidgets.QMenu """ height = 25 spacing = 1 options = self.library().theme().options() styleSheet = studioqt.StyleSheet.fromText(LibraryAction.STYLE_SHEET, options=options) actionWidget = QtWidgets.QFrame(parent) actionWidget.setObjectName('actionWidget') actionWidget.setStyleSheet(styleSheet.data()) actionLabel = QtWidgets.QLabel(self.library().name(), actionWidget) actionLabel.setObjectName('actionLabel') actionLabel.setFixedHeight(height) iconColor = QtGui.QColor(255, 255, 255, 220) icon = studiolibrary.resource().icon('delete', color=iconColor) actionOption = QtWidgets.QPushButton('', actionWidget) actionOption.setObjectName('actionOption') actionOption.setIcon(icon) actionOption.setFixedHeight(height + spacing) actionOption.setFixedWidth(height) actionOption.clicked.connect(self.deleteLibrary) actionIcon = QtWidgets.QLabel('', actionWidget) actionIcon.setObjectName('actionIcon') actionIcon.setFixedWidth(10) actionIcon.setFixedHeight(height) actionLayout = QtWidgets.QHBoxLayout(actionWidget) actionLayout.setSpacing(0) actionLayout.setContentsMargins(0, 0, 0, 0) actionLayout.addWidget(actionIcon, stretch=1) actionLayout.addWidget(actionLabel, stretch=1) actionLayout.addWidget(actionOption, stretch=1) return actionWidget
def example(): widget = QtWidgets.QFrame() widget.setStyleSheet("border-radius:3px;background-color:white;") widget.setMinimumWidth(300) widget.setMinimumHeight(300) widget.setMaximumWidth(500) lightbox = Lightbox() lightbox.setWidget(widget) lightbox.show()
def __init__(self, label='', parent=None, dpi=1): """ :type parent: QtWidgets.QMenu """ QtWidgets.QWidgetAction.__init__(self, parent) self.setObjectName('customAction') self._frame = QtWidgets.QFrame(parent) self._label = QtWidgets.QLabel(label, self._frame) self._label.setObjectName('sliderActionLabel') self._label.setMinimumWidth(85) self._slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self._frame) self.valueChanged = self._slider.valueChanged
def createWidget(self, menu): """ This method is called by the QWidgetAction base class. :type menu: QtWidgets.QMenu """ widget = QtWidgets.QFrame(self.parent()) widget.setObjectName("colorPickerAction") actionLayout = QtWidgets.QHBoxLayout(widget) actionLayout.setContentsMargins(0, 0, 0, 0) actionLayout.addWidget(self.picker(), stretch=1) widget.setLayout(actionLayout) return widget
def __init__(self, *args, **kwargs): super(RadioFieldWidget, self).__init__(*args, **kwargs) self._radioButtons = [] layout = QtWidgets.QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self._radioFrame = QtWidgets.QFrame(self) self._radioFrame.setLayout(layout) self.setWidget(self._radioFrame) self.label().setStyleSheet("margin-top:2px;") self.widget().setStyleSheet("margin-top:2px;") self.label().setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)
def __init__(self, *args, **kwargs): super(StringDoubleFieldWidget, self).__init__(*args, **kwargs) widget = QtWidgets.QFrame(self) layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(3) widget.setLayout(layout) self._widget1 = QtWidgets.QLineEdit(self) self._widget1.textChanged.connect(self.emitValueChanged) widget.layout().addWidget(self._widget1) self._widget2 = QtWidgets.QLineEdit(self) self._widget2.textChanged.connect(self.emitValueChanged) widget.layout().addWidget(self._widget2) self.setWidget(widget)
def __init__(self, *args, **kwargs): super(RangeOptionWidget, self).__init__(*args, **kwargs) widget = QtWidgets.QFrame(self) layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(3) widget.setLayout(layout) self._minwidget = QtWidgets.QSpinBox(self) self._minwidget.valueChanged.connect(self.emitValueChanged) widget.layout().addWidget(self._minwidget) self._maxwidget = QtWidgets.QSpinBox(self) self._maxwidget.valueChanged.connect(self.emitValueChanged) widget.layout().addWidget(self._maxwidget) self.setWidget(widget)
def __init__(self, *args, **kwargs): super(OptionsWidget, self).__init__(*args, **kwargs) layout = QtWidgets.QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) self.setStyleSheet(STYLE) self.setLayout(layout) self._widgets = [] self._validator = None self._optionsFrame = QtWidgets.QFrame(self) self._optionsFrame.setObjectName('optionsFrame') layout = QtWidgets.QVBoxLayout(self._optionsFrame) self._optionsFrame.setLayout(layout) self.layout().addWidget(self._optionsFrame)
def __init__(self, *args, **kwargs): super(RangeFieldWidget, self).__init__(*args, **kwargs) widget = QtWidgets.QFrame(self) layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(3) widget.setLayout(layout) validator = QtGui.QIntValidator(-50000000, 50000000, self) self._minwidget = QtWidgets.QLineEdit(self) self._minwidget.setValidator(validator) self._minwidget.textChanged.connect(self.emitValueChanged) widget.layout().addWidget(self._minwidget) self._maxwidget = QtWidgets.QLineEdit(self) self._maxwidget.setValidator(validator) self._maxwidget.textChanged.connect(self.emitValueChanged) widget.layout().addWidget(self._maxwidget) self.setWidget(widget)
def __init__(self, parent=None, width=None, height=None, enableInputEdit=False, enableDontShowCheckBox=False, customInputWidget=None): super(MessageBox, self).__init__(parent) self.setObjectName("messageBox") self._frame = None self._animation = None self._dontShowCheckbox = False self._clickedButton = None self._clickedStandardButton = None self.setMinimumWidth(width or 320) self.setMinimumHeight(height or 220) 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.setFixedHeight(46) self._header.setObjectName("messageBoxHeaderFrame") self._header.setStyleSheet("background-color: rgb(0,0,0,0);") self._header.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self._icon = QtWidgets.QLabel(self._header) self._icon.hide() self._icon.setFixedWidth(32) self._icon.setFixedHeight(32) 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 customInputWidget: self._customInputWidget = customInputWidget bodyLayout.addStretch(1) bodyLayout.addWidget(self._customInputWidget) bodyLayout.addStretch(10) if enableInputEdit: self._inputEdit = QtWidgets.QLineEdit(self._body) self._inputEdit.setObjectName("messageBoxInputEdit") self._inputEdit.setMinimumHeight(32) 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()