def __init__(self, showColumnVisBox=True, showHeaderBox=True, parent=None): super(ViewSearchWidget, self).__init__(parent=parent) # TODO: these button colors need stylesheeting once Stylesheeting is moved to zoocore searchIcon = iconlib.iconColorized("magnifier", size=14, color=(255, 255, 255)) closeIcon = iconlib.iconColorized("close", size=14, color=(255, 255, 255)) self.searchFrame = QtWidgets.QFrame(parent=self) self.searchFrame.setFrameShape(QtWidgets.QFrame.NoFrame) self.searchFrame.setFrameShadow(QtWidgets.QFrame.Plain) self.searchLayout = QtWidgets.QHBoxLayout(self) self.searchLayout.setContentsMargins(0, 0, 0, 0) self.searchWidget = searchwidget.SearchLineEdit(searchIcon, closeIcon, parent=self) self.searchWidget.textCleared.connect(self.searchTextedCleared.emit) self.searchWidget.textChanged.connect(self.searchTextedChanged.emit) self.searchFrame.setLayout(self.searchLayout) self.columnVisibilityBox = combobox.ExtendedComboBox(parent=self) self.columnVisibilityBox.setMinimumWidth(100) self.columnVisibilityBox.checkStateChanged.connect(self.onVisibilityChanged) self.searchLayout.addWidget(self.columnVisibilityBox) self.searchHeaderBox = combobox.ExtendedComboBox(parent=self) self.searchHeaderBox.setMinimumWidth(100) self.searchHeaderBox.currentIndexChanged.connect(self.onFilterChanged) self.searchLayout.addWidget(self.searchHeaderBox) self.searchLayout.addWidget(self.searchWidget) if not showColumnVisBox: self.columnVisibilityBox.hide() if not showHeaderBox: self.searchHeaderBox.hide()
def __init__(self, parent=None): super(ArrayAttributeView, self).__init__(parent) layout = QtWidgets.QVBoxLayout() self.setLayout(layout) sliceLayout = QtWidgets.QHBoxLayout() layout.addLayout(sliceLayout) sliceLayout.addWidget(QtWidgets.QLabel("Slice:")) self._lineEdit = _SliceLineEdit() self._lineEdit.setPlaceholderText('e.g.: "0:5000", "::-1"') sliceLayout.addWidget(self._lineEdit) self._arrayAttrModel = _ArrayAttributeModel() self._listView = QtWidgets.QListView() self._listView.setUniformItemSizes(True) self._listView.setViewMode(QtWidgets.QListView.ListMode) self._listView.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) self._listView.setModel(self._arrayAttrModel) layout.addWidget(self._listView) self._lineEdit.SliceChanged.connect(self._arrayAttrModel.SetSlice) self._SetupContextMenu()
def buildTitleFrame(self): """Builds the title part of the layout with a QFrame widget """ # main dark grey qframe self.titleFrame = frame.QFrame(parent=self) self.setFrameColor(self.color) self.titleFrame.setContentsMargins(4, 0, 4, 0) # the horizontal layout self.horizontalLayout = QtWidgets.QHBoxLayout(self.titleFrame) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) # the icon and title and spacer self.iconButton = QtWidgets.QToolButton(parent=self) if self.collapsed: self.iconButton.setIcon(self._collapsedIcon) else: self.iconButton.setIcon(self._expandIcon) self.titleLabel = QtWidgets.QLabel(self.title, parent=self) self.titleLabel.setStyleSheet("font: bold;") self.titleLabel.setContentsMargins(0, 0, 0, 0) spacerItem = QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) # add to horizontal layout self.horizontalLayout.addWidget(self.iconButton) self.horizontalLayout.addWidget(self.titleLabel) self.horizontalLayout.addItem(spacerItem) self.titleFrame.setFixedHeight(self.titleFrame.sizeHint().height()) self.setMinimumSize(self.titleFrame.sizeHint().width(), self.titleFrame.sizeHint().height())
def _initUi(self): self.mainLayout = QtWidgets.QVBoxLayout() self.setLayout(self.mainLayout) topSpacer = QtWidgets.QSpacerItem(20, 52, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) bottomSpacer = QtWidgets.QSpacerItem(20, 52, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) leftSpacer = QtWidgets.QSpacerItem(20, 52, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) rightSpacer = QtWidgets.QSpacerItem(20, 52, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) # label to hold the thumbnail image self.imageLabel = QtWidgets.QLabel(parent=self) self.imageLabel.hide() # camera icon self.iconLayout = QtWidgets.QHBoxLayout() self.cameraBtn = _CameraButton(parent=self) self.iconLayout.addItem(leftSpacer) self.iconLayout.addWidget(self.cameraBtn) self.iconLayout.addItem(rightSpacer) # add the items self.mainLayout.addItem(topSpacer) self.mainLayout.addLayout(self.iconLayout) self.mainLayout.addItem(bottomSpacer) self.cameraBtn.clicked.connect(self.onCameraButtonClicked)
def __init__(self, showColumnVisBox=True, showHeaderBox=True, parent=None): super(ViewSearchWidget, self).__init__(parent=parent) searchIcon = iconlib.icon("magnifier", 16) closeIcon = iconlib.icon("close", 16) self.searchFrame = QtWidgets.QFrame(parent=self) self.searchFrame.setFrameShape(QtWidgets.QFrame.NoFrame) self.searchFrame.setFrameShadow(QtWidgets.QFrame.Plain) self.searchLayout = QtWidgets.QHBoxLayout(self) self.searchLayout.setContentsMargins(2, 2, 2, 2) self.searchWidget = searchwidget.SearchLineEdit(searchIcon, closeIcon, parent=self) self.searchWidget.textCleared.connect(self.searchTextedCleared.emit) self.searchWidget.textChanged.connect(self.searchTextedChanged.emit) self.searchFrame.setLayout(self.searchLayout) self.columnVisibilityBox = None self.columnVisibilityBox = combobox.ExtendedComboBox(parent=self) self.columnVisibilityBox.setMinimumWidth(100) self.columnVisibilityBox.checkStateChanged.connect(self.onVisibilityChanged) self.searchLayout.addWidget(self.columnVisibilityBox) self.searchHeaderBox = combobox.ExtendedComboBox(parent=self) self.searchHeaderBox.setMinimumWidth(100) self.searchHeaderBox.currentIndexChanged.connect(self.onFilterChanged) self.searchLayout.addWidget(self.searchHeaderBox) self.searchLayout.addWidget(self.searchWidget) if not showColumnVisBox: self.columnVisibilityBox.hide() if not showHeaderBox: self.searchHeaderBox.hide()
def __init__(self, parent=None): super(DebugFlagsWidget, self).__init__(parent) self.setObjectName("Debug Flags") self.setMinimumSize(640, 300) self._listView = QtWidgets.QListView() self._tableWidget = QtWidgets.QTableWidget(0, 2) # Configure and populate the left list view self._listView.setEditTriggers( QtWidgets.QAbstractItemView.NoEditTriggers) self._populateDebugFlagsListView(self._listView) # For some reason, the last two lines work, while combining them into one command throws an error. self._listModel = self._listView.selectionModel() self._listModel.selectionChanged.connect(self._onFlagSelectionChanged) # Configure the table widget self._tableWidget.horizontalHeader().setStretchLastSection(True) self._tableWidget.horizontalHeader().setDefaultSectionSize(200) self._tableWidget.setHorizontalHeaderLabels( ['Debug Symbol', 'Description']) self._tableWidget.verticalHeader().hide() self._tableWidget.itemClicked.connect(self._onDebugFlagChecked) # Set the layout lay = QtWidgets.QHBoxLayout() lay.addWidget(self._listView, 0) lay.addWidget(self._tableWidget, 1) self.setLayout(lay)
def DragSpinBoxExample(): wid = QtWidgets.QWidget() horizontalLayout = QtWidgets.QHBoxLayout(wid) spinBox = spinbox.DragSpinBox(wid) horizontalLayout.addWidget(spinBox) doubleSpinBox = spinbox.DragDoubleSpinBox(wid) horizontalLayout.addWidget(doubleSpinBox) wid.show() return wid
def createWidget(self, parent): layout = QtWidgets.QHBoxLayout() layout.setSpacing(2) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.iconWidget) layout.addWidget(self.label) layout.addWidget(self.optionBox) self.optionBox.setVisible(self.hasOptionBox) self.frame.setLayout(layout) return self.frame
def _setupFilter(self): self.reloadBtn = QtWidgets.QToolButton(parent=self) self.reloadBtn.setIcon(iconlib.icon("reload")) self.searchLayout = QtWidgets.QHBoxLayout(self) self.searchLayout.setContentsMargins(2, 2, 2, 2) self.searchLayout.addWidget(self.reloadBtn) # setup the column search widget self.searchWidget = viewfilterwidget.ViewSearchWidget(parent=self) self.searchLayout.addWidget(self.searchWidget) self.mainLayout.addLayout(self.searchLayout)
def _setupFilter(self): self.reloadBtn = QtWidgets.QToolButton(parent=self) self.reloadBtn.setIcon(iconlib.icon("reload")) self.searchLayout = QtWidgets.QHBoxLayout(self) self.searchLayout.setContentsMargins(2, 2, 2, 2) self.searchLayout.addWidget(self.reloadBtn) self.searchWidget = viewfilterwidget.ViewSearchWidget(showColumnVisBox=False, showHeaderBox=False, parent=self) self.searchLayout.addWidget(self.searchWidget) self.mainLayout.addLayout(self.searchLayout)
def hlineEdit(labelName, parent, enabled=True): layout = QtWidgets.QHBoxLayout() label = QtWidgets.QLabel(labelName, parent=parent) edit = QtWidgets.QLineEdit(parent=parent) edit.setEnabled(enabled) layout.addWidget(label) layout.addWidget(edit) layout.setContentsMargins(2, 2, 2, 2) layout.setSpacing(1) return label, edit, layout
def _setupFilter(self): self.reloadBtn = QtWidgets.QToolButton(parent=self) # TODO: this button color needs stylesheeting once Stylesheeting is moved to zoocore self.reloadBtn.setIcon(iconlib.iconColorized("reload", color=(255, 255, 255))) self.searchLayout = QtWidgets.QHBoxLayout(self) self.searchLayout.setContentsMargins(0, 0, 0, 0) self.searchLayout.addWidget(self.reloadBtn) self.searchWidget = viewfilterwidget.ViewSearchWidget(showColumnVisBox=False, showHeaderBox=False, parent=self) self.searchWidget.setFixedHeight(utils.dpiScale(23)) self.searchLayout.addWidget(self.searchWidget) self.mainLayout.addLayout(self.searchLayout)
def createWidget(self, menu): """ This method is called by the QWidgetAction base class. :type menu: QtWidgets.QMenu """ actionWidget = self.widget actionLayout = QtWidgets.QHBoxLayout(actionWidget) actionLayout.setContentsMargins(0, 0, 0, 0) actionLayout.addWidget(self.label) actionLayout.addWidget(self.slider) actionWidget.setLayout(actionLayout) return actionWidget
def __init__(self, model, parent=None): super(PathWidget, self).__init__(parent=parent) self.directory = False self.model = model self.edit = QtWidgets.QLineEdit(parent=self) self.layout = QtWidgets.QHBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.layout) self.layout.addWidget(self.edit) self.browserBtn = QtWidgets.QPushButton("...", parent=self) self.layout.addWidget(self.browserBtn) self.browserBtn.clicked.connect(self.onBrowserClicked) self.edit.editingFinished.connect(self.onEditChanged)
def HBoxLayout(parent=None, margins=(0, 0, 0, 0), spacing=uiconstants.SREG): """One liner for QtWidgets.QHBoxLayout() to make it easier to create an easy Horizontal Box layout DPI (4k) is handled here Defaults use regular spacing and no margins :param margins: override the margins with this value :type margins: tuple :param spacing: override the spacing with this pixel value :type spacing: int """ zooQHBoxLayout = QtWidgets.QHBoxLayout(parent) zooQHBoxLayout.setContentsMargins(*utils.marginsDpiScale(*margins)) zooQHBoxLayout.setSpacing(utils.dpiScale(spacing)) return zooQHBoxLayout
def __init__(self, radioList=None, toolTipList=None, default=0, parent=None, vertical=False): """Horizontal group of radio buttons :param radioList: a list of radio button names (strings) :type radioList: list :param default: the default button to be checked as on, starts at 0 matching the list :type default: int :param parent: the parent widget :type parent: obj """ super(RadioButtonGroup, self).__init__(parent=parent) # todo: STYLESHEET needs to be in the stylesheet and not hardcoded # rgb(27, 27, 27) is the main color of the unchecked button # rgb(45, 45, 45) is the background color of the window, unchecked has no icon indicatorWH = utils.dpiScale(14) uncheckedWH = utils.dpiScale(10) borderRadius = utils.dpiScale(7) borderPx = utils.dpiScale(2) styleSheetF = "QRadioButton::indicator {0}" \ "width: {2}px; " \ "height: {2}px;{1}" \ "QRadioButton::indicator:unchecked " \ "{0}background: rgb(27, 27, 27); " \ "width: {3}px; " \ "height: {3}px;" \ "border-radius: {4}px; " \ "border: {5}px solid rgb(45, 45, 45){1}".format("{", "}", indicatorWH, uncheckedWH, borderRadius, borderPx) if radioList is None: radioList = [] self.radioButtons = [] self.group = QtWidgets.QButtonGroup(parent=self) if not vertical: radioLayout = QtWidgets.QHBoxLayout() else: radioLayout = QtWidgets.QVBoxLayout() for i, radioName in enumerate(radioList): newRadio = QtWidgets.QRadioButton(radioName, self) newRadio.setStyleSheet(styleSheetF) if toolTipList: newRadio.setToolTip(toolTipList[i]) self.group.addButton(newRadio) radioLayout.addWidget(newRadio) self.radioButtons.append(newRadio) if default is not None and default < len(self.radioButtons): self.radioButtons[default].setChecked(True) self.group.buttonClicked.connect(self.toggled.emit) self.setLayout(radioLayout)
def __init__(self, min_=0, max_=100, parent=None): super(SpinboxSlider, self).__init__(parent=parent) self.range = (min_, max_) hbox = QtWidgets.QHBoxLayout(self) self.slider = QtWidgets.QSlider(parent=self) hbox.addWidget(self.slider) self.slider.setOrientation(QtCore.Qt.Horizontal) self.slider.setRange(*self.range) self.spinbox = QtWidgets.QSpinBox(parent=self) hbox.addWidget(self.spinbox) self.spinbox.setRange(*self.range) self.slider.valueChanged.connect(partial(self.onUpdate, self.spinbox)) self.spinbox.valueChanged.connect(partial(self.onUpdate, self.slider))
def __init__(self, okText="OK", cancelTxt="Cancel", parent=None): """Creates OK Cancel Buttons bottom of window, can change the names :param okText: the text on the ok (first) button :type okText: str :param cancelTxt: the text on the cancel (second) button :type cancelTxt: str :param parent: the widget parent :type parent: class """ super(OkCancelButtons, self).__init__(parent=parent) self.layout = QtWidgets.QHBoxLayout() self.okBtn = QtWidgets.QPushButton(okText, parent=self) self.cancelBtn = QtWidgets.QPushButton(cancelTxt, parent=self) self.layout.addWidget(self.okBtn) self.layout.addWidget(self.cancelBtn) self.setLayout(self.layout) self.connections()
def __init__(self, title="", parent=None, treeItem=None): super(GroupWidget, self).__init__(parent=parent) self.color = uiconstants.DARKBGCOLOR self.horizontalLayout = utils.hBoxLayout(self) self.mainLayout = utils.hBoxLayout(self) self.expandToggleButton = QtWidgets.QToolButton(parent=self) self.folderIcon = QtWidgets.QToolButton(parent=self) self.titleFrame = frame.QFrame(parent=self) self.collapsed = False self.groupTextEdit = LineClickEdit(title, single=False) self.titleExtrasLayout = QtWidgets.QHBoxLayout() self.deleteBtn = QtWidgets.QToolButton(parent=self) self.treeItem = treeItem self.initUi() self.connections()
def initUi(self): compStackToolbarLayout = QtWidgets.QHBoxLayout() compStackToolbarLayout.addWidget(self.stackSearchEdit) # Toolbar buttons self.expandBtn.setIcon(self._expandIcon) self.expandBtn.setIconSize(QtCore.QSize(12, 12)) self.collapseBtn.setIcon(self._collapseIcon) self.collapseBtn.setIconSize(QtCore.QSize(10, 10)) size = QtCore.QSize(self.collapseBtn.sizeHint().width(), 20) # Temporary size till we get icons here self.collapseBtn.setFixedSize(size) self.expandBtn.setFixedSize(size) # Add buttons and search to toolbar compStackToolbarLayout.addSpacing(1) compStackToolbarLayout.addWidget(self.collapseBtn) compStackToolbarLayout.addWidget(self.expandBtn) compStackToolbarLayout.setStretchFactor(self.stackSearchEdit, 1) compStackToolbarLayout.setContentsMargins(0, 0, 0, 0) compStackToolbarLayout.setSpacing(1) compStackToolbar = QtWidgets.QWidget(parent=self) compStackToolbar.setLayout(compStackToolbarLayout) mainLayout = QtWidgets.QVBoxLayout() if self.text != "": mainLayout.addWidget(QtWidgets.QLabel(self.text)) if not self.showToolbar: compStackToolbar.hide() mainLayout.addWidget(compStackToolbar) mainLayout.addWidget(self.stackTableWgt) self.setLayout(mainLayout)
def __init__(self, widget, width=450, height=50, iconSize=40, parent=None, showOnInitialize=False, stylesheet="", popupRelease=QtCore.Qt.Key_Control, showAtCursor=True): super(ExpandedTooltipPopup, self).__init__(None, width, height, "", parent, showOnInitialize) self.layout = QtWidgets.QVBoxLayout(self) self.font = QtGui.QFont("sans") self.titleFont = QtGui.QFont("sans") # Maybe should link this with the stylesheets self.iconColour = self.ETT_ICONCOLOUR self.themeColour = self.ETT_THEMECOLOUR self.linkColour = self.ETT_LINKCOLOUR self.popupKey = popupRelease self.iconSize = iconSize self.frameLayout = QtWidgets.QVBoxLayout() self.titleLayout = QtWidgets.QHBoxLayout() self.frame = QtWidgets.QFrame(self) self.titleLabel = QtWidgets.QLabel(self) self.tooltipIcon = None # type: QtCore.QIcon self.widget = widget if stylesheet != "": self.setStyleSheet(stylesheet) self.initUi() self.show() if showAtCursor: self.move(QtGui.QCursor.pos()) self.setStyle(self.style())
def __init__(self, primViewItem, refreshFunc, printTiming=False, parent=None): QtWidgets.QWidget.__init__(self, parent) self._primViewItem = primViewItem self._layout = QtWidgets.QHBoxLayout() self._layout.setSpacing(0) self._layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self._layout) self._comboBox = DrawModeComboBox(self) self._modelAPI = UsdGeom.ModelAPI(self._primViewItem.prim) # Reducing the width further causes the pop-up dialog to be trimmed # and option text to be pruned. self._comboBox.setFixedWidth(100) self._comboBox.addItem(DrawModes.DEFAULT) self._comboBox.addItem(DrawModes.CARDS) self._comboBox.addItem(DrawModes.BOUNDS) self._comboBox.addItem(DrawModes.ORIGIN) self._layout.addWidget(self._comboBox) self._clearButton = QtWidgets.QToolButton(self) self._clearButton.setText('X') self._clearButton.setFixedSize(16, 16) retainSizePolicy = self._clearButton.sizePolicy() retainSizePolicy.setRetainSizeWhenHidden(True) self._clearButton.setSizePolicy(retainSizePolicy) self._layout.addWidget(self._clearButton) self._currentDrawMode = None self.RefreshDrawMode() self._firstPaint = True self._refreshFunc = refreshFunc self._printTiming = printTiming self._comboBox.signalPopupHidden.connect(self._PopupHidden) self._comboBox.activated.connect(self._UpdateDrawMode) self._clearButton.clicked.connect(self._ClearDrawMode)
def __init__(self, model, parent=None): super(NumericAttributeWidget, self).__init__(parent=parent) self.model = weakref.ref(model) layout = QtWidgets.QHBoxLayout() layout.setSpacing(1) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, parent=self) self.valueSpinBox = QtWidgets.QSpinBox(parent=self) self.valueSpinBox.setFocusPolicy(QtCore.Qt.StrongFocus) self.valueSpinBox.setRange(-100, 100) self.valueSpinBox.setSingleStep(1) self.valueSpinBox.valueChanged.connect(self.setValue) self.slider.valueChanged.connect(self.setValue) # self.valueSpinBox.valueChanged.connect(self.valueChanged.emit) layout.addWidget(self.slider) layout.addWidget(self.valueSpinBox) self.setStyleSheet(""" QSlider::groove:horizontal { border:none; } QSlider::sub-page { background: rgb(164, 192, 2); } QSlider::add-page { background: rgb(70, 70, 70); } QSlider::handle { background: rgb(164, 192, 2); width: 30px; margin: -30px 0; } """)
def _setupFilter(self): self.searchBoxLabel = QtWidgets.QLabel("Search By: ", parent=self) self.searchHeaderBox = QtWidgets.QComboBox(parent=self) self.refreshBtn = QtWidgets.QToolButton(parent=self) self.refreshBtn.setIcon(iconlib.icon("reload")) self.searchFrame = QtWidgets.QFrame(parent=self) self.searchFrame.setFrameShape(QtWidgets.QFrame.NoFrame) self.searchFrame.setFrameShadow(QtWidgets.QFrame.Plain) self.searchLayout = QtWidgets.QHBoxLayout(self) self.searchLayout.setContentsMargins(2, 2, 2, 2) self.searchClearBtn = QtWidgets.QPushButton("Clear", parent=self) self.searchLabel = QtWidgets.QLabel("Search", parent=self) self.searchEdit = QtWidgets.QLineEdit(self) self.searchFrame.setLayout(self.searchLayout) self.searchLayout.addWidget(self.refreshBtn) self.searchLayout.addWidget(self.searchBoxLabel) self.searchLayout.addWidget(self.searchHeaderBox) self.searchLayout.addWidget(self.searchLabel) self.searchLayout.addWidget(self.searchEdit) self.searchLayout.addWidget(self.searchClearBtn) self.mainLayout.addWidget(self.searchFrame)
def buildTitleFrame(self): """Builds the title part of the layout with a QFrame widget """ self.layout().addWidget(self.titleFrame) self.titleFrame.setContentsMargins(1, 1, 4, 0) self.titleFrame.mousePressEvent = self.mousePressEvent # the horizontal layout self.horizontalLayout = QtWidgets.QHBoxLayout(self.titleFrame) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) # the icon and title and spacer self.expandToggleButton.setParent(self.titleFrame) if self.collapsed: self.expandToggleButton.setIcon(self._collapsedIcon) else: self.expandToggleButton.setIcon(self._expandIcon) self.folderIcon.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents) spacerItem = QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) # add to horizontal layout self.horizontalLayout.addWidget(self.expandToggleButton) self.horizontalLayout.addWidget(self.folderIcon) self.horizontalLayout.addItem(spacerItem) self.titleFrame.setFixedHeight(self.titleFrame.sizeHint().height()) self.setMinimumSize(self.titleFrame.sizeHint().width(), self.titleFrame.sizeHint().height() + 3) self.horizontalLayout.addWidget(self.groupTextEdit) self.horizontalLayout.addLayout(self.titleExtrasLayout) self.horizontalLayout.addWidget(self.deleteBtn) self.horizontalLayout.setStretchFactor(self.groupTextEdit, 4)
def __init__(self, actionData, parent): super(ColorAction, self).__init__(parent) widget = QtWidgets.QWidget(parent) layout = QtWidgets.QHBoxLayout(widget) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) button = QtWidgets.QPushButton(actionData.get("label", ""), parent=widget) button.setStyleSheet("QLabel {" + " background-color: {}; color: {};".format( actionData.get("backgroundColor", ""), actionData.get("color", "")) + "}") icon = actionData.get("icon") if icon: if isinstance(icon, QtGui.QIcon): button.setIcon(icon) else: icon = iconlib.icon(icon) if not icon.isNull(): button.setIcon(icon) button.setToolTip(actionData.get("tooltip", "")) button.clicked.connect(self.triggered.emit) layout.addWidget(button) self.setDefaultWidget(widget)
def hBoxLayout(parent=None): layout = QtWidgets.QHBoxLayout(parent) layout.setContentsMargins(2, 2, 2, 2) layout.setSpacing(2) return layout