Exemplo n.º 1
0
    def showPopup(self):
        """Override Qt method."""
        index = self.currentIndex()
        menu = QMenu(self)

        # See: https://github.com/ContinuumIO/navigator/issues/1565
        try:
            menu.setToolTipsVisible(True)
        except AttributeError:
            pass

        actions = []

        for i in range(self.count()):
            tip = self.itemData(i, Qt.ToolTipRole)
            text = self.itemText(i)
            action = create_action(
                self,
                text,
                toggled=lambda v=None, i=i: self.setCurrentIndex(i),
                tip=tip
            )

            actions.append(action)

            if i == index:
                action.setChecked(True)

        add_actions(menu, actions)
        menu.setFixedWidth(self.width())
        bottom_left = self.contentsRect().bottomLeft()
        menu.popup(self.mapToGlobal(bottom_left))
Exemplo n.º 2
0
    def showPopup(self):
        """Override Qt method."""
        index = self.currentIndex()
        menu = QMenu(self)
        menu.setToolTipsVisible(True)
        actions = []

        for i in range(self.count()):
            tip = self.itemData(i, Qt.ToolTipRole)
            text = self.itemText(i)
            action = create_action(
                self,
                text,
                toggled=lambda v=None, i=i: self.setCurrentIndex(i),
                tip=tip)

            actions.append(action)

            if i == index:
                action.setChecked(True)

        add_actions(menu, actions)
        menu.setFixedWidth(self.width())
        bottom_left = self.contentsRect().bottomLeft()
        menu.popup(self.mapToGlobal(bottom_left))