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, 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 __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(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, parent, name = 'capturedModelPanel', **kwargs): super(ModelPanelWidget, self).__init__(parent, **kwargs) name = self.findUniqueName(name) self.setObjectName(name + 'Widget') layout = QtWidgets.QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setObjectName(name + 'Layout') self.setLayout(layout) maya.cmds.setParent(layout.objectName()) self._modelPanel = maya.cmds.modelPanel(name, label='ModelPanel') self.setModelPanelOptions()
def __init__(self, path="", parent=None, startFrame=None, endFrame=None, step=1): """ :type path: str :type parent: QtWidgets.QWidget :type startFrame: int :type endFrame: int :type step: int """ parent = parent or mutils.gui.mayaWindow() QtWidgets.QDialog.__init__(self, parent) self._path = path self._step = step self._endFrame = None self._startFrame = None self._capturedPath = None if endFrame is None: endFrame = int(maya.cmds.currentTime(query=True)) if startFrame is None: startFrame = int(maya.cmds.currentTime(query=True)) self.setEndFrame(endFrame) self.setStartFrame(startFrame) self.setObjectName("CaptureWindow") self.setWindowTitle("Capture Window") self._captureButton = QtWidgets.QPushButton("Capture") self._captureButton.clicked.connect(self.capture) self._modelPanelWidget = mutils.gui.modelpanelwidget.ModelPanelWidget( self) vbox = QtWidgets.QVBoxLayout(self) vbox.setObjectName(self.objectName() + "Layout") vbox.addWidget(self._modelPanelWidget) vbox.addWidget(self._captureButton) self.setLayout(vbox) width = (self.DEFAULT_WIDTH * 1.5) height = (self.DEFAULT_HEIGHT * 1.5) + 50 self.setWidthHeight(width, height) self.centerWindow()
def __init__(self, parent=None, data=None, formWidget=None): super(FieldWidget, self).__init__(parent) self._data = data or {} self._error = False self._widget = None self._default = None self._required = None self._collapsed = False self._errorLabel = None self._menuButton = None self._actionResult = None self._formWidget = None if formWidget: self.setFormWidget(formWidget) self.setObjectName("fieldWidget") direction = self._data.get("layout", self.DefaultLayout) if direction == "vertical": layout = QtWidgets.QVBoxLayout(self) else: layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.setContentsMargins(0, 0, 0, 0) self._label = QtWidgets.QLabel(self) self._label.setObjectName('label') self._label.setSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred, ) layout.addWidget(self._label) self._layout2 = QtWidgets.QHBoxLayout(self) layout.addLayout(self._layout2) if direction == "vertical": self._label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) else: self._label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) widget = self.createWidget() if widget: self.setWidget(widget)
def __init__(self, parent=None, form=None): super(FormDialog, self).__init__(parent) layout = QtWidgets.QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.setLayout(layout) self._widgets = [] self._validator = None self._title = QtWidgets.QLabel(self) self._title.setObjectName('title') self._title.setText('FORM') self.layout().addWidget(self._title) self._description = QtWidgets.QLabel(self) self._description.setObjectName('description') self.layout().addWidget(self._description) self._formWidget = FormWidget(self) self._formWidget.setObjectName("formWidget") self._formWidget.validated.connect(self._validated) self.layout().addWidget(self._formWidget) self.layout().addStretch(1) buttonLayout = QtWidgets.QHBoxLayout(self) buttonLayout.setContentsMargins(0, 0, 0, 0) buttonLayout.setSpacing(0) self.layout().addLayout(buttonLayout) buttonLayout.addStretch(1) self._acceptButton = QtWidgets.QPushButton(self) self._acceptButton.setObjectName('acceptButton') self._acceptButton.setText('Submit') self._acceptButton.clicked.connect(self.accept) self._rejectButton = QtWidgets.QPushButton(self) self._rejectButton.setObjectName('rejectButton') self._rejectButton.setText('Cancel') self._rejectButton.clicked.connect(self.reject) buttonLayout.addWidget(self._acceptButton) buttonLayout.addWidget(self._rejectButton) if form: self.setSettings(form)
def __init__(self, parent, name="capturedModelPanel", **kwargs): super(ModelPanelWidget, self).__init__(parent, **kwargs) uniqueName = name + str(id(self)) self.setObjectName(uniqueName + 'Widget') layout = QtWidgets.QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setObjectName(uniqueName + "Layout") self.setLayout(layout) maya.cmds.setParent(layout.objectName()) self._modelPanel = maya.cmds.modelPanel(uniqueName, label="ModelPanel") self.setModelPanelOptions()
def setWidget(self, widget): """ Set the widget used to set and get the field value. :type widget: QtWidgets.QWidget """ widgetLayout = QtWidgets.QHBoxLayout() widgetLayout.setContentsMargins(0, 0, 0, 0) widgetLayout.setSpacing(0) self._widget = widget self._widget.setParent(self) self._widget.setObjectName('widget') self._widget.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred, ) self._menuButton = QtWidgets.QPushButton("...") self._menuButton.setHidden(True) self._menuButton.setObjectName("menuButton") self._menuButton.clicked.connect(self._menuCallback) self._menuButton.setSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding, ) widgetLayout.addWidget(self._widget) widgetLayout.addWidget(self._menuButton) layout = QtWidgets.QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self._errorLabel = QtWidgets.QLabel(self) self._errorLabel.setHidden(True) self._errorLabel.setObjectName("errorLabel") self._errorLabel.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred, ) layout.addLayout(widgetLayout) layout.addWidget(self._errorLabel) self._layout2.addLayout(layout)
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 loadUiPySide(widget, path=None): """ :type widget: QtWidgets.QWidget :type path: str :rtype: None """ loader = QtUiTools.QUiLoader() loader.setWorkingDirectory(os.path.dirname(path)) f = QtCore.QFile(path) f.open(QtCore.QFile.ReadOnly) widget.ui = loader.load(path, widget) f.close() layout = QtWidgets.QVBoxLayout() layout.setObjectName('uiLayout') layout.addWidget(widget.ui) widget.setLayout(layout) layout.setContentsMargins(0, 0, 0, 0) widget.setMinimumWidth(widget.ui.minimumWidth()) widget.setMinimumHeight(widget.ui.minimumHeight()) widget.setMaximumWidth(widget.ui.maximumWidth()) widget.setMaximumHeight(widget.ui.maximumHeight())
def __init__(self, parent=None, options=None): super(OptionWidget, self).__init__(parent) self._option = options or {} self._widget = None self._default = None self._required = None direction = self._option.get("layout", "horizontal") self.setProperty("layout", direction) if direction == "vertical": layout = QtWidgets.QVBoxLayout(self) else: layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.setLayout(layout) self.setContentsMargins(0, 0, 0, 0) self._label = QtWidgets.QLabel(self) self._label.setObjectName('label') self._label.setSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred, ) layout.addWidget(self._label) if direction == "vertical": self._label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) else: layout.setStretchFactor(self._label, 2) self._label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
def __init__(self, *args): QtWidgets.QFrame.__init__(self, *args) layout = QtWidgets.QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) self._label = QtWidgets.QLabel("", self) 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, item, *args): """ :type item: ImageItem :type args: list """ QtWidgets.QWidget.__init__(self, *args) self._item = item self._pixmap = QtGui.QPixmap(item.thumbnailPath()) self._image = QtWidgets.QLabel(self) self._image.setAlignment(QtCore.Qt.AlignHCenter) self._loadButton = QtWidgets.QPushButton("Load") self._loadButton.setFixedHeight(40) self._loadButton.clicked.connect(self.load) layout = QtWidgets.QVBoxLayout() layout.addWidget(self._image) layout.addStretch(1) layout.addWidget(self._loadButton) self.setLayout(layout)
def __init__(self, *args): QtWidgets.QWidget.__init__(self, *args) layout = QtWidgets.QVBoxLayout(self) self.setLayout(layout) self._lineEdit = QtWidgets.QLineEdit() self._lineEdit.textChanged.connect(self.searchChanged) self._treeWidget = SidebarWidget(self) self._slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) self._slider.valueChanged.connect(self._valueChanged) self._slider.setRange(50, 200) self._slider.setValue(100) self._slider.setFixedHeight(18) layout.addWidget(self._slider) layout.addWidget(self._lineEdit) layout.addWidget(self._treeWidget) self._treeWidget.itemClicked.connect(self.itemClicked) self._treeWidget.itemSelectionChanged.connect(self.selectionChanged) self.update()
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()