Exemple #1
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;")
    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()
Exemple #3
0
    def __init__(self, parent=None):
        super(Editor, self).__init__(parent=parent)
        self.setFrameStyle(QtWidgets.QFrame.StyledPanel | QtWidgets.QFrame.Sunken)
        self._locals = {}
        self.textEdit = TextEditor(parent=self)
        self.numberBar = NumberBar(self.textEdit)

        hbox = qtutils.hBoxLayout(parent=self)
        hbox.addWidget(self.numberBar)
        hbox.addWidget(self.textEdit)

        self.textEdit.blockCountChanged.connect(self.numberBar.adjustWidth)
        self.textEdit.updateRequest.connect(self.numberBar.updateContents)
        self.pythonHighlighter = highlighter.highlighterFromJson(os.path.join(os.path.dirname(highlighter.__file__),
                                                                              "highlightdata.json"),
                                                                 self.textEdit.document())
Exemple #4
0
    def __init__(self,
                 parent=None,
                 menuIndicatorIcon="arrowmenu",
                 iconSize=20,
                 iconPadding=2):
        super(FlowToolBar, self).__init__(parent)
        self.mainLayout = utils.hBoxLayout(self)

        self.flowLayout = flowlayout.FlowLayout(margin=0,
                                                spacingX=1,
                                                spacingY=1)
        self.mainLayout.addLayout(self.flowLayout)
        self.setLayout(self.mainLayout)
        self.iconSize = iconSize
        self.iconPadding = iconPadding
        self.overflowBtnColor = (128, 128, 128)
        self.menuIndicatorIcon = menuIndicatorIcon

        self.overflowMenu = False
        self.overflowMenuBtn = None  # type: iconmenu.IconMenuButton
        self.overflowMenuDlg = FlowToolbarMenu(parent=self)
        self.overflowLayout = self.overflowMenuDlg.layout()

        self.initUi()
Exemple #5
0
    def buildTitleFrame(self):
        """ Builds the title part of the layout with a QFrame widget
        """

        self.titleFrame.setContentsMargins(1, 1, 1, 1)

        # the horizontal layout
        self.horizontalLayout = qtutils.hBoxLayout(self.titleFrame)
        # the icon and title and spacer
        self.expandToggleButton.setParent(self.titleFrame)
        if self.collapsed:
            self.expandToggleButton.setIconByName(self._collapsedIconName)
        else:
            self.expandToggleButton.setIconByName(self._expandIconName)

        spacerItem = QtWidgets.QSpacerItem(10, 10,
                                           QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Minimum)

        # add to horizontal layout
        self.horizontalLayout.addWidget(self.expandToggleButton)
        self.horizontalLayout.addWidget(self.itemIcon)
        self.horizontalLayout.addItem(spacerItem)
        self.titleFrame.setFixedHeight(self.titleFrame.sizeHint().height())
        self.titleFrame.setObjectName("title")

        self.setMinimumSize(self.titleFrame.sizeHint().width(),
                            self.titleFrame.sizeHint().height() + 1)

        self.horizontalLayout.addWidget(self.stackTitleWgt)
        self.horizontalLayout.addLayout(self.titleExtrasLayout)
        self.horizontalLayout.addWidget(self.shiftUpBtn)
        self.horizontalLayout.addWidget(self.shiftDownBtn)
        self.horizontalLayout.addWidget(self.deleteBtn)

        self.horizontalLayout.setStretchFactor(self.stackTitleWgt, 4)
Exemple #6
0
    def __init__(self,
                 title,
                 parent,
                 collapsed=False,
                 collapsable=True,
                 icon=None,
                 startHidden=False,
                 shiftArrowsEnabled=True,
                 deleteButtonEnabled=True,
                 titleEditable=True,
                 itemIconSize=12):
        """ The item in each StackTableWidget.

        :param title:
        :param parent:
        :param collapsed:
        :param collapsable:
        :param icon:
        :param startHidden:
        :param shiftArrowsEnabled:
        :param deleteButtonEnabled:
        :param titleEditable:
        """

        super(StackItem, self).__init__(parent=parent)

        if startHidden:
            self.hide()

        self._itemIcon = icon or self._itemIcon
        self.stackWidget = parent
        self.hide()
        self.itemIconSize = itemIconSize

        # Init
        self.itemIcon = extendedbutton.ExtendedButton(parent=self)
        self.shiftDownBtn = extendedbutton.ExtendedButton(parent=self)
        self.shiftUpBtn = extendedbutton.ExtendedButton(parent=self)
        self.deleteBtn = extendedbutton.ExtendedButton(parent=self)
        self.stackTitleWgt = LineClickEdit(title)
        self.titleExtrasLayout = qtutils.hBoxLayout()
        self.horizontalLayout = qtutils.hBoxLayout()

        self.spacesToUnderscore = True

        self.layout = qtutils.vBoxLayout(parent=self)
        self.title = title
        self.color = uiconstants.DARKBGCOLOR
        self.contentMargins = uiconstants.MARGINS
        self.contentSpacing = uiconstants.SPACING
        self.collapsable = collapsable
        self.collapsed = collapsed
        self.titleFrame = frame.QFrame(parent=self)
        self.expandToggleButton = extendedbutton.ExtendedButton(parent=self)

        if not shiftArrowsEnabled:
            self.shiftDownBtn.hide()
            self.shiftUpBtn.hide()

        if not deleteButtonEnabled:
            self.deleteBtn.hide()

        if not titleEditable:
            self.stackTitleWgt.setReadOnly(True)

        self._init()

        self.initUi()
        self.connections()

        if not collapsable:  # if not collapsable must be open
            self.collapsed = False
            self.expand()

        if self.collapsed:
            self.collapse()
        else:
            self.expand()