PyQt4.QtGui.QApplication.instance.style

Here are the examples of the python api PyQt4.QtGui.QApplication.instance.style taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

5 Examples 7

Example 1

Project: orange Source File: nodeitem.py
def standard_icon(standard_pixmap):
    """
    Return return the application style's standard icon for a
    `QStyle.StandardPixmap`.

    """
    style = QApplication.instance().style()
    return style.standardIcon(standard_pixmap)

Example 2

Project: orange Source File: nodeitem.py
    def __init__(self, parent=None, icon=None, iconSize=None, **kwargs):
        QGraphicsItem.__init__(self, parent, **kwargs)
        self.setFlag(QGraphicsItem.ItemUsesExtendedStyleOption, True)

        if icon is None:
            icon = QIcon()

        if iconSize is None:
            style = QApplication.instance().style()
            size = style.pixelMetric(style.PM_LargeIconSize)
            iconSize = QSize(size, size)

        self.__transformationMode = Qt.SmoothTransformation

        self.__iconSize = QSize(iconSize)
        self.__icon = QIcon(icon)

Example 3

Project: orange Source File: OWFile.py
Function: init
    def __init__(self, qwidget=None, style=None):
        self.qwidget = qwidget
        if qwidget is None:
            self.style = QApplication.instance().style()
        else:
            self.style = qwidget.style()

Example 4

Project: spykeviewer Source File: checkable_item_delegate.py
    def paint(self, painter, option, index):
        #noinspection PyArgumentList
        style = QApplication.instance().style()

        if index.data(CheckableItemDelegate.CheckTypeRole):
            # Size and spacing in current style
            is_radio = index.data(CheckableItemDelegate.CheckTypeRole) == \
                CheckableItemDelegate.RadioCheckType
            if is_radio:
                button_width = style.pixelMetric(
                    QStyle.PM_ExclusiveIndicatorWidth, option)
                spacing = style.pixelMetric(
                    QStyle.PM_RadioButtonLabelSpacing, option)
            else:
                button_width = style.pixelMetric(
                    QStyle.PM_IndicatorWidth, option)
                spacing = style.pixelMetric(
                    QStyle.PM_CheckBoxLabelSpacing, option)

            # Draw default appearance shifted to right
            myOption = option
            left = myOption.rect.left()
            myOption.rect.setLeft(left + spacing + button_width)
            QStyledItemDelegate.paint(self, painter, myOption, index)

            # Draw check button to open space (where expand indicator would be)
            myOption.rect.setLeft(left)
            myOption.rect.setWidth(button_width)

            if index.data(CheckableItemDelegate.CheckedRole):
                myOption.state |=  QStyle.State_On
            else:
                myOption.state |= QStyle.State_Off

            if is_radio:
                style.drawPrimitive(
                    QStyle.PE_IndicatorRadioButton, myOption, painter)
            else:
                style.drawPrimitive(
                    QStyle.PE_IndicatorCheckBox, myOption, painter)
        else:
            QStyledItemDelegate.paint(self, painter, option, index)

Example 5

Project: spykeviewer Source File: filter_dock.py
    def _filter_mouse_released(self, event):
        index = self.filterTreeWidget.indexAt(event.pos())
        if index.data(CheckableItemDelegate.CheckTypeRole) and \
                event.button() == Qt.LeftButton:
            style = QApplication.instance().style()
            radio_button_width = style.pixelMetric(
                QStyle.PM_ExclusiveIndicatorWidth)
            spacing = style.pixelMetric(QStyle.PM_RadioButtonLabelSpacing)

            item = self.filterTreeWidget.itemFromIndex(index)
            ind = 1
            while item.parent():
                ind += 1
                item = item.parent()
            indent = ind * self.filterTreeWidget.indentation()
            if indent < event.x() < indent + radio_button_width + spacing:
                self._switch_check_state(index)
                event.accept()
                # Hack to repaint the whole current item:
                self.filterTreeWidget.currentItem().setExpanded(False)
                return

        QTreeWidget.mouseReleaseEvent(self.filterTreeWidget, event)