class Box(QWidget): """docstring for BoxLayout.""" def __init__(self, direction, parent=None): super(Box, self).__init__(parent) self.box = QBoxLayout(direction) self.setLayout(self.box) def addWidget(self, widget, stretch=0): self.box.addWidget(widget, stretch)
def __init__(self, parent, direction): QLayout.__init__(self, parent) self._inner = QBoxLayout(direction) self._direction = direction self._separator = VLine if not self.isVertical() else HLine self._item_count = 0 self._grid_layouts = [] self._minimum_row_height = 0 self._spacing = 0 self._label_alignment = Qt.AlignCenter self._panel_direction = QBoxLayout.TopToBottom self._group_alignment = None
def __init__(self, parent=None): super(SpinWidget, self).__init__(parent) base = QBoxLayout(QBoxLayout.TopToBottom, self) base.setContentsMargins(0, 0, 0, 0) base.setSpacing(0) self._dec = SpinWidget.Button(self) self._dec.clicked.connect(self._onDecreaseClicked) self._dec.setObjectName("Decrease") self._inc = SpinWidget.Button(self) self._inc.clicked.connect(self._onIncreaseClicked) self._inc.setObjectName("Increase") base.addWidget(self._dec) base.addWidget(self._inc) self._updateButtons()
def __init__(self, direction, parent=None): super(Box, self).__init__(parent) self.box = QBoxLayout(direction) self.setLayout(self.box)
class GroupPanelLayout(QLayout): def __init__(self, parent, direction): QLayout.__init__(self, parent) self._inner = QBoxLayout(direction) self._direction = direction self._separator = VLine if not self.isVertical() else HLine self._item_count = 0 self._grid_layouts = [] self._minimum_row_height = 0 self._spacing = 0 self._label_alignment = Qt.AlignCenter self._panel_direction = QBoxLayout.TopToBottom self._group_alignment = None def addWidget(self, widget, group_name): if self._item_count > 0: self.addSeparator() container = LinkWidget(self.parent(), widget) layout = QVBoxLayout(container) layout.setDirection(self._panel_direction) layout.setContentsMargins(self._spacing, self._spacing, self._spacing, self._spacing) self.addLabel(layout, group_name) layout.addWidget(widget) container.setLayout(layout) group_alignment = self._group_alignment if self._group_alignment is not None else Qt.Alignment( 0) self._inner.addWidget(container, alignment=group_alignment) self._item_count += 1 def setLabelAlignment(self, alignment): self._label_alignment = alignment def setPanelDirection(self, direction): self._panel_direction = direction def setGroupAlignment(self, alignment): self._group_alignment = alignment def isVertical(self): return self._direction in (QBoxLayout.TopToBottom, QBoxLayout.BottomToTop) def addSeparator(self): self._inner.addWidget(self._separator(self.parent())) def addLabel(self, layout, name): label = QLabel(name) label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) layout.addWidget(label, alignment=self._label_alignment) def addStretch(self, stretch): self._inner.addStretch(stretch) def setContentsMargins(self, left, top, right, bottom): self._inner.setContentsMargins(left, top, right, bottom) def setSpacing(self, spacing): self._spacing = spacing def count(self): return self._inner.count() def sizeHint(self): return self._inner.sizeHint() def setGeometry(self, rect): self._inner.setGeometry(rect) def itemAt(self, index): return self._inner.itemAt(index) def takeAt(self, index): return self._inner.takeAt(index) def minimumSize(self): return self._inner.minimumSize() def hasHeightForWidth(self): return self._inner.hasHeightForWidth() def heightForWidth(self, width): return self._inner.heightForWidth(width) def update(self): return self._inner.update()
def addWidget(self, widget, group_name, expanded=True): QBoxLayout.addWidget(self, self._create_header(group_name, expanded)) QBoxLayout.addWidget(self, widget) self._widgets.append(widget) widget.setVisible(expanded) self._index += 1
def __init__(self, parent, direction): QBoxLayout.__init__(self, direction, parent) self._index = 0 self._widgets = []
def __init__(self): QBoxLayout.__init__(self, QBoxLayout.Direction.TopToBottom)