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(_CameraButton, self).__init__(parent) self.setStyleSheet( "background-color: rgba( 0, 0, 0, 0 );border: none;") self.enterIcon = iconlib.icon("cameraSolid") self.leaveIcon = iconlib.icon("cameraBorder") self.setMaximumSize(QtCore.QSize(999999, 9999999)) self.setIcon(self.leaveIcon)
def __init__(self, parent=None): super(CollapsibleGroupBox, self).__init__(parent) self.setCheckable(True) self.setChecked(True) self.toggled.connect(self.resizeGroupBox) plusIcon = iconlib.icon('arrowSingleUp') self.plusPixmap = plusIcon.pixmap(plusIcon.availableSizes()[0]) icon = iconlib.icon('arrowSingleDown') self.minusPixmap = icon.pixmap(icon.availableSizes()[0])
def __init__(self, title="", width=600, height=800, icon="", parent=None, showOnInitialize=True): super(Dialog, self).__init__(parent=parent) # self.setStyleSheet(qdarkstyle.load_stylesheet(pyside=True)) self.setContentsMargins(2, 2, 2, 2) self.title = title self.setObjectName(title) self.setWindowTitle(title) self.resize(width, height) if icon: if isinstance(icon, QtGui.QIcon): self.setWindowIcon(icon) else: self.setWindowIcon(iconlib.icon(icon)) if showOnInitialize: self.center() self.show() self.resize(width, height)
def __init__(self, title="", width=600, height=800, icon="", parent=None, showOnInitialize=True, transparent=False): super(MainWindow, self).__init__(parent=parent) self.setContentsMargins(2, 2, 2, 2) self.setDockNestingEnabled(True) self.setDocumentMode(True) self.title = title self.setObjectName(title or self.__class__.__name__) self.setWindowTitle(title) self.resize(width, height) self.docks = [] self.toolBars = {} self.hasMainMenu = False self.centralWidget = QtWidgets.QWidget(parent=self) self.setCentralWidget(self.centralWidget) if transparent: self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setDockOptions(QtWidgets.QMainWindow.AllowNestedDocks | QtWidgets.QMainWindow.AnimatedDocks | QtWidgets.QMainWindow.AllowTabbedDocks) self.setTabPosition(QtCore.Qt.AllDockWidgetAreas, QtWidgets.QTabWidget.North) if icon: if isinstance(icon, QtGui.QIcon): self.setWindowIcon(icon) else: self.setWindowIcon(iconlib.icon(icon)) if showOnInitialize: self.center() self.show() self.reapplySettings()
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 setupMenuBar(self): self.hasMainMenu = True self.fileMenu = self.menuBar().addMenu("File") self.viewMenu = self.menuBar().addMenu("View") self.exitAction = QtWidgets.QAction(self) self.exitAction.setIcon(iconlib.icon("close")) self.exitAction.setText("Close") self.exitAction.setShortcut("ctrl+Q") self.exitAction.setToolTip("Closes application") self.fileMenu.addAction(self.exitAction) self.exitAction.triggered.connect(self.close) for i in self.docks: self.viewMenu.addAction(i.toggleViewAction())
def __init__(self, name, title, parent=None): super(HeaderToolbar, self).__init__(parent) self.setObjectName(name) self.setWindowTitle(title) self.setWindowFlags(QtCore.Qt.FramelessWindowHint) self.setMovable(False) self.isFloatable = False self.spacer = QtWidgets.QWidget() self.spacer.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.minimizeBtn = QtWidgets.QToolButton(self) self.minimizeBtn.setText("-") self.minimizeBtn.clicked.connect(self.parent().showMinimized) self.minimizeBtn.setMaximumWidth(20) self.minimizeBtn.setMaximumHeight(20) self.maximizeBtn = QtWidgets.QToolButton(self) self.maximizeBtn.setText('+') self.maximizeBtn.clicked.connect(self.parent().toggleMaximized) self.maximizeBtn.setMaximumWidth(20) self.maximizeBtn.setMaximumHeight(20) self.closeBtn = QtWidgets.QToolButton(self) self.closeBtn.setText('X') self.closeBtn.clicked.connect(self.parent().close) self.closeBtn.setMaximumWidth(20) self.closeBtn.setMaximumHeight(20) self.addWidget(self.spacer) self.addWidget(self.minimizeBtn) self.addWidget(self.maximizeBtn) self.addWidget(self.closeBtn) self.minimizeBtn.setIcon(iconlib.icon("minusHollow")) self.minimizeBtn.setIcon(iconlib.icon("window")) self.minimizeBtn.setIcon(iconlib.icon("close"))
def BtnRegular(**kwargs): """Creates regular pyside button with text or an icon *Note WIP: Will fill out more options with time * should probably override ExtendedButton and not QtWidgets.QPushButton for full options :param kwargs: See the doc string from the function BtnStyle :type kwargs: dict :return qtBtn: returns a qt button widget :rtype qtBtn: object """ parent = kwargs.get("parent") text = kwargs.get("text") icon = kwargs.get("icon", (255, 255, 255)) toolTip = kwargs.get("toolTip", "") iconSize = kwargs.get("iconSize") minWidth = kwargs.get("minWidth") maxWidth = kwargs.get("maxWidth") minHeight = kwargs.get("maxHeight") maxHeight = kwargs.get("maxHeight") btn = QtWidgets.QPushButton(text, parent=parent) if icon: btn.setIcon(iconlib.icon(icon)) btn.setIconSize(QtCore.QSize(iconSize, iconSize)) """ todo: icon colorized anti aliasing is not working correctly? Icons appear thicker self.setIcon(iconlib.iconColorized(icon, size=iconSize, color=iconColor, overlayName=overlayIconName, overlayColor=overlayIconColor)) """ btn.setToolTip(toolTip) if minWidth is not None: btn.setMinimumWidth(utils.dpiScale(minWidth)) if maxWidth is not None: btn.setMaximumWidth(utils.dpiScale(maxWidth)) if minHeight is not None: btn.setMinimumHeight(utils.dpiScale(minHeight)) if maxHeight is not None: btn.setMaximumHeight(utils.dpiScale(maxHeight)) # todo: button height padding should be set in the prefs stylesheet padWidth = utils.dpiScale(3) padHeight = utils.dpiScale(4) padding = "{0} {1} {0} {1}".format(padHeight, padWidth) btn.setStyleSheet("QPushButton {padding: " + padding + ";}") return btn
def setup(self): toolTip = """Name: {name} path: {path} Icon: {icon} tooltip: {tooltip} label: {label} color: {color} background: {backgroundColor}""" for command in self.executor.commands.values(): uiData = command.uiData item = QtWidgets.QListWidgetItem() item.setText(uiData.get("label", "")) icon = iconlib.icon(uiData.get("icon", "")) data = {"name": command.id, "path": inspect.getfile(command)} data.update(uiData) info = toolTip.format(**data) item.setToolTip(info) if icon is not None: item.setIcon(icon) self.listWidget.addItem(item)
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 __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 create(self, parent=None): uiData = self.command.uiData self.item = QtWidgets.QWidgetAction(parent) text = uiData.get("label", "NOLABEL") actionLabel = QtWidgets.QLabel(text) self.item.setDefaultWidget(actionLabel) color = uiData.get("color", "") backColor = uiData.get("backgroundColor", "") if color or backColor: actionLabel.setStyleSheet( "QLabel {background-color: %s; color: %s;}" % (backColor, color)) icon = uiData.get("icon") if icon: if isinstance(icon, QtGui.QIcon): self.item.setIcon(icon) else: icon = iconlib.icon(icon) if not icon.isNull(): self.item.setIcon(icon) self.item.setStatusTip(uiData.get("tooltip")) self.item.triggered.connect(partial(self.triggered.emit, self.command.id)) logger.debug("Added commandAction, {}".format(text)) return self.item
class CollapsableFrameLayout(QtWidgets.QWidget): closeRequested = QtCore.Signal() openRequested = QtCore.Signal() _collapsedIcon = iconlib.icon("sortClosed") _expandIcon = iconlib.icon("sortDown") def __init__(self, title, collapsed=False, collapsable=True, contentMargins=uiconstants.MARGINS, contentSpacing=uiconstants.SPACING, color=uiconstants.DARKBGCOLOR, parent=None): """Collapsable framelayout, similar to Maya's cmds.frameLayout Title is inside a bg colored frame layout that can open and collapse Code example for how to use is as follows... self.collapseLayout = layouts.collapsableFrameLayout("Custom Title Goes Here", parent=self) self.collapseLayout.addWidget(self.customWidget) # for adding widgets self.collapseLayout.addLayout(self.customLayout) # for adding layouts :param title: The name of the collapsable frame layout :type title: str :param collapsed: Is the default state collapsed, if False it's open :type collapsed: bool :param collapsable: Are the contents collapsable? If False the contents are always open :type collapsed: bool :param contentMargins: The margins for the collapsable contents section, left, top, right, bottom (pixels) :type contentMargins: tuple :param contentSpacing: spacing (padding) for the collapsable contents section, in pixels :type contentSpacing: int :param parent: the widget parent :type parent: class """ # todo: STYLSHEET, cleanup this class, remove margin hardcoding and colors use stylesheet instead super(CollapsableFrameLayout, self).__init__(parent=parent) self.layout = QtWidgets.QVBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.title = title self.color = color self.contentMargins = contentMargins self.contentSpacing = contentSpacing self.collapsable = collapsable self.collapsed = collapsed if not collapsable: # if not collapsable must be open self.collapsed = False self.initUi() self.setLayout(self.layout) self.connections() def initUi(self): """Builds the UI, the title and the collapsable widget that' the container for self.hiderLayout """ self.buildTitleFrame() self.buildHiderWidget() self.layout.addWidget(self.titleFrame) self.layout.addWidget(self.widgetHider) 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 setFrameColor(self, color): self.titleFrame.setStyleSheet("background-color: rgb{0}; " "border-radius: 3px;" "border: 1px solid rgb{0}".format(str(color))) def addWidget(self, widget): self.hiderLayout.addWidget(widget) def addLayout(self, layout): self.hiderLayout.addLayout(layout) def buildHiderWidget(self): """Builds widget that is collapsable Widget can be toggled so it's a container for the layout """ self.widgetHider = QtWidgets.QFrame() self.widgetHider.setContentsMargins(0, 0, 0, 0) self.hiderLayout = QtWidgets.QVBoxLayout(self.widgetHider) self.hiderLayout.setContentsMargins(*self.contentMargins) self.hiderLayout.setSpacing(self.contentSpacing) self.widgetHider.setHidden(self.collapsed) def onCollapsed(self): self.widgetHider.setHidden(True) self.iconButton.setIcon(self._collapsedIcon) self.closeRequested.emit() self.collapsed = 1 def onExpand(self): self.widgetHider.setHidden(False) self.iconButton.setIcon(self._expandIcon) self.openRequested.emit() self.collapsed = 0 def showHideWidget(self, *args): """Shows and hides the widget `self.widgetHider` this contains the layout `self.hiderLayout` which will hold the custom contents that the user specifies """ if not self.collapsable: return # If we're already collapsed then expand the layout if self.collapsed: self.onExpand() return self.onCollapsed() def connections(self): """toggle widgetHider vis """ self.iconButton.clicked.connect(self.showHideWidget) self.titleFrame.mouseReleased.connect(self.showHideWidget)
msz.width(), self.searchButton.sizeHint().width() + self.clearButton.sizeHint().width() + frameWidth * 2 + 2), max(msz.height(), self.clearButton.sizeHint().height() + frameWidth * 2 + 2)) def resizeEvent(self, event): sz = self.clearButton.sizeHint() frameWidth = self.style().pixelMetric( QtWidgets.QStyle.PM_DefaultFrameWidth) rect = self.rect() yPos = (rect.bottom() + 1 - sz.height()) * 0.5 self.clearButton.move(self.rect().right() - frameWidth - sz.width(), yPos) self.searchButton.move(self.rect().left() + 1, yPos) def updateCloseButton(self, text): if text: self.clearButton.setVisible(True) return self.clearButton.setVisible(False) if __name__ == "__name__": app = QtWidgets.QApplication([]) searchIcon = QtGui.QPixmap(iconlib.icon("magnifier"), 16) closeIcon = QtGui.QPixmap(iconlib.icon("code", 16)) w = SearchLineEdit(searchIcon, closeIcon) w.show() app.exec_()
def __init__(self, label): self.label = label self.dataField = 10 self.icon = iconlib.icon("brick") self.values = ["translate", "rotate", "scale", "visibility"] self.currentIndex = 0
class GroupWidget(QtWidgets.QWidget): """ The Widget used for groups in TreeWidget """ _deleteIcon = iconlib.icon("xMark") _itemIcon = iconlib.icon("openFolder01") _collapsedIcon = iconlib.icon("sortClosed") _expandIcon = iconlib.icon("sortDown") 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): self.setLayout(self.mainLayout) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.folderIcon.setIcon(self._itemIcon) self.deleteBtn.setIcon(self._deleteIcon) self.buildTitleFrame() def setTreeItem(self, treeItem): self.treeItem = treeItem def connections(self): self.expandToggleButton.clicked.connect(self.expandToggle) def text(self): """ Returns the text of the text edit :return: """ return self.groupTextEdit.text() 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 expandToggle(self): if self.collapsed: self.expand() self.collapsed = False else: self.collapse() self.collapsed = True def onCollapsed(self): """ Collapse and hide the item contents :return: """ self.expandToggleButton.setIcon(self._collapsedIcon) self.treeItem.setExpanded(False) def onExpand(self): self.expandToggleButton.setIcon(self._expandIcon) self.treeItem.setExpanded(True) def expand(self): """ Extra Code for convenience """ self.onExpand() def collapse(self): """ Extra Code for convenience """ self.onCollapsed() def mousePressEvent(self, event): event.ignore() def passThroughMouseEvent(self, event): event.ignore()
class StackWidget(QtWidgets.QWidget): """The overall layout widget. The table underneath (self.stackTableWgt) holds all the stack items. StackWidget is the overall view, StackTableWidget is the actual widget that holds the StackItems themselves. """ _expandIcon = iconlib.icon("roundedsquare") _collapseIcon = iconlib.icon("minus") def __init__(self, label="", parent=None, showToolbar=True, showArrows=True, showClose=True, titleEditable=True): super(StackWidget, self).__init__(parent=parent) self.stackTableWgt = StackTableWidget(showArrows=showArrows, showClose=showClose, parent=self) self.stackItems = self.stackTableWgt.stackItems self.stackSearchEdit = QtWidgets.QLineEdit(parent=self) self.collapseBtn = QtWidgets.QPushButton(parent=self) self.expandBtn = QtWidgets.QPushButton(parent=self) self.text = label self.showToolbar = showToolbar self.showArrows = showArrows self.showClose = showClose self.titleEditable = titleEditable self.initUi() self.connections() def __len__(self): return len(self.stackItems) def __iter__(self): for i in self.stackItems: yield i 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 connections(self): """ Connections for the buttons and the search edit :return: """ self.stackSearchEdit.textChanged.connect(self.onStackSearchChanged) self.collapseBtn.clicked.connect(self.collapseClicked) self.expandBtn.clicked.connect(self.expandClicked) def collapseClicked(self): """Collapse all the StackItems in the Table """ self.stackTableWgt.collapseAll() def expandClicked(self): """Expand all the StackItems in the Table """ self.stackTableWgt.expandAll() def onStackSearchChanged(self): """Filter the results based on the text inputted into the search bar """ text = self.stackSearchEdit.text().lower() self.stackTableWgt.filter(text) self.stackTableWgt.updateSize() def clearStack(self): """Clear all the items in the stack """ self.stackTableWgt.clearStack() def addStackItem(self, item): """Add item to the StackTableWidget :param item: StackItem to add to the table """ item.setArrowsVisible(self.showArrows) self.stackTableWgt.addStackItem(item) def replaceStackItems(self, items): """Clear all items and replace it with the items :param items: List of items to add to the stack table """ self.clearStack() for i in items: self.stackTableWgt.addStackItem(i) def clearSearchEdit(self): """Clear the search bar """ self.stackSearchEdit.setText("") def shiftItem(self, wgt, dir): """Shift the item up or down in the table :param wgt: The StackItem to shift :param dir: The direction to shift -1 is upwards, 1 is downwards """ self.stackTableWgt.shiftTableItem(wgt, dir) def deleteItem(self, wgt): """Delete the stack item from the table :param wgt: """ self.stackTableWgt.deleteTableItem(wgt)