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
3
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)
3
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)
3
Example 3
def __init__(self, qwidget=None, style=None):
self.qwidget = qwidget
if qwidget is None:
self.style = QApplication.instance().style()
else:
self.style = qwidget.style()
0
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)
0
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)