Example #1
0
    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()
Example #2
0
    def createEditor(self, parent, option, index):
        model = index.model()

        widget = QtWidgets.QPushButton(model.data(QtCore.Qt.DisplayRole),
                                       parent=parent)
        widget.clicked.connect(self.onClicked)
        return widget
Example #3
0
    def __init__(self, parent=None, size=24):
        """ Floating Button that can be placed anywhere on the screen

        Essentially a floating frameless transparent window. It doesn't float outside the parent,
        so make sure the button is within the parent bounds to be visible.

        .. code-block:: python

            # use .button to access the actual push button
            floatBtn = FloatingButton(parent=self)
            floatBtn.button.clicked.connect(self.floatButtonClicked)

            # Use .move to move it around the window. Note: It's not visible outside the parent's bounds
            floatBtn.move(20,20)

            # Use setAlignment() to align the edge of the FloatingButton when moving.
            floatBtn.setAlignment(QtCore.Qt.AlignTop) # Top of button will at the new move position
            floatBtn.setAlignment(QtCore.Qt.AlignLeft) # Bottom of button will at the new move position

            floatBtn.move(20,20) # Use move to update the position

        :param parent:
        """
        super(FloatingButton, self).__init__(parent=parent,
                                             showOnInitialize=False)
        self.button = QtWidgets.QPushButton(parent=self)
        self.mainLayout = utils.hBoxLayout(self)
        self.resize(utils.dpiScale(size), utils.dpiScale(size))
        self.alignment = QtCore.Qt.AlignBottom

        self.initUi()
        self.setStyleSheet("background-color: transparent;")
Example #4
0
    def __init__(self, label="Color:", initialRgbColor=None, initialRgbColorF=None, contentsMargins=(0, 0, 0, 0),
                 parent=None, labelWeight=1, colorWeight=1, colorWidth=None):
        """Initialize variables

        :param label: The name of the label, usually "Color:"
        :type label: str
        :param initialRgbColor: The initial rgb color in 0-255 ranges, overridden if there's a initialRgbColorF value
        :type initialRgbColor: tuple
        :param initialRgbColorF: The initial rgb color in 0-1.0 ranges, if None defaults to initialRgbColor values
        :type initialRgbColorF: tuple
        :param parent: the widget parent
        :type parent: class
        """
        super(labelColorBtn, self).__init__(parent=parent)
        self.layout = HBoxLayout(parent=None, margins=utils.marginsDpiScale(*contentsMargins),
                                 spacing=utils.dpiScale(uiconstants.SPACING))
        self.layout.addWidget(QtWidgets.QLabel(label, parent=self), labelWeight)
        self.colorPickerBtn = QtWidgets.QPushButton("", parent=self)
        # use initialRgbColor (255 range) or initialRgbColorF (float range 0-1)
        # if no color given then default to red
        self.storedRgbColor = initialRgbColor or tuple([i * 255 for i in initialRgbColorF]) or tuple([255, 0, 0])
        self.colorPickerBtn.setStyleSheet("background-color: rgb{}".format(str(self.storedRgbColor)))
        if colorWidth:
            self.colorPickerBtn.setFixedWidth(colorWidth)
        self.layout.addWidget(self.colorPickerBtn, colorWeight)
        self.setLayout(self.layout)
        self.connections()
Example #5
0
    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()
Example #6
0
 def __init__(self, parent):
     super(TabbedEditor, self).__init__(parent=parent)
     self.setTabsClosable(True)
     self.setMovable(True)
     self.newTabBtn = QtWidgets.QPushButton("+", parent=self)
     self.newTabBtn.setMaximumWidth(40)
     self.newTabBtn.setToolTip("Add New Tab")
     self.setCornerWidget(self.newTabBtn, QtCore.Qt.TopLeftCorner)
     self.newTabBtn.clicked.connect(self.addNewEditor)
     self.tabCloseRequested.connect(self.closeCurrentTab)
Example #7
0
 def __init__(self, name="", parent=None):
     super(TabWidget, self).__init__(parent=parent)
     self.setObjectName(name)
     self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
     self.customContextMenuRequested.connect(self._contextMenu)
     self.setDocumentMode(True)
     self.setTabsClosable(True)
     self.setMovable(True)
     self.newTabBtn = QtWidgets.QPushButton("+", parent=self)
     self.newTabBtn.setMaximumWidth(40)
     self.newTabBtn.setToolTip("Add New Tab")
     self.setCornerWidget(self.newTabBtn, QtCore.Qt.TopLeftCorner)
     self.newTabBtn.clicked.connect(partial(self.addTabWidget, None, True))
Example #8
0
 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)
Example #9
0
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
Example #10
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)
Example #11
0
 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)
Example #12
0
            frame.rect = proxyStyle.subControlRect(
                QtWidgets.QStyle.CC_GroupBox, option,
                QtWidgets.QStyle.SC_GroupBoxFrame, self)
            proxyStyle.drawPrimitive(QtWidgets.QStyle.PE_FrameGroupBox, frame,
                                     painter, self)
        # now draw the title
        if option.text:
            painter.setPen(QtGui.QPen(option.palette.windowText(), 1))
            alignment = int(option.textAlignment)
            if not proxyStyle.styleHint(QtWidgets.QStyle.SH_UnderlineShortcut,
                                        option, self):
                alignment = alignment | QtCore.Qt.TextHideMnemonic
            style.proxy().drawItemText(
                painter, textRect,
                QtCore.Qt.TextShowMnemonic | QtCore.Qt.AlignLeft | alignment,
                option.palette, option.state & QtWidgets.QStyle.State_Enabled,
                option.text, QtGui.QPalette.NoRole)
        # deal with the arrow icons
        proxyStyle.drawItemPixmap(
            painter, checkBoxRect, QtCore.Qt.AlignLeft,
            self.minusPixmap if self.isChecked() else self.plusPixmap)


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    box = CollapsibleGroupBox()
    box.setTitle("test")
    box.setLayout(QtWidgets.QVBoxLayout(box))
    box.layout().addWidget(QtWidgets.QPushButton("test", parent=box))
    box.show()
    sys.exit(app.exec_())