Beispiel #1
0
 def addButton(self, icon=None, title='', handler=None, shortcut=None, statusTip=None):
     """
     Add a button to the bottom
     """
     btn = createButton(icon, title, handler, shortcut, statusTip)
     self._mainLayout.addWidget(btn)
     if shortcut != None:
         sh = QtWidgets.QShortcut(shortcut, self)
         sh.activated.connect(lambda arg=btn: self._handleShortcut(arg))
         self._shortcuts.append(sh)
         self._shortcutAdded.emit()
     return btn
Beispiel #2
0
    def addArrowButton(self, panel, icon=None, title='', handler=None, shortcut=None, statusTip=None):
        """
        Add a button with an arrow to the bottom
        """
        btn = createButton(icon, title, handler, shortcut, statusTip)
        self._panels.append(panel)

        # Add an arrowbutton
        arrowBtn = QtWidgets.QToolButton()
        arrowBtn.setAutoRaise(True)
        sp = arrowBtn.sizePolicy()
        sp.setVerticalPolicy(sp.Expanding)
        arrowBtn.setSizePolicy(sp)
        arrowBtn.setArrowType(Qt.RightArrow)
        arrowBtn.setCheckable(True)
        self._arrowBtns.append(arrowBtn)

        # Add it to self.arrowBtns, and set up a handler
        idx = self._dynContentStack.addWidget(panel)
        arrowBtn.clicked.connect(lambda checked, idxarg=idx: self._handleArrowBtnClicked(checked, idxarg))

        # Final setup
        L = QtWidgets.QHBoxLayout()
        L.setSpacing(0)
        L.setContentsMargins(0, 0, 0, 0)
        L.addWidget(btn)
        L.addWidget(arrowBtn)
        w = QtWidgets.QWidget()
        w.setLayout(L)
        self._addBtn(w)

        # Do stuff with the shortcut
        if shortcut != None:
            sh = QtWidgets.QShortcut(shortcut, self)
            sh.activated.connect(lambda arg=btn: self._handleShortcut(arg))
            self._shortcuts.append(sh)
            self._shortcutAdded.emit()
        panel._shortcutAdded.connect(self._handleShortcutAddedToPanel)
        for s in panel._shortcuts: self._shortcuts.append(s)
        self._shortcutAdded.emit()
        
        return w