/usr/lib/python2.7/dist-packages/pyqtgraph/widgets/PathButton.py is in python-pyqtgraph 0.9.10-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | from ..Qt import QtGui, QtCore
from .. import functions as fn
__all__ = ['PathButton']
class PathButton(QtGui.QPushButton):
"""Simple PushButton extension which paints a QPainterPath on its face"""
def __init__(self, parent=None, path=None, pen='default', brush=None, size=(30,30)):
QtGui.QPushButton.__init__(self, parent)
self.path = None
if pen == 'default':
pen = 'k'
self.setPen(pen)
self.setBrush(brush)
if path is not None:
self.setPath(path)
if size is not None:
self.setFixedWidth(size[0])
self.setFixedHeight(size[1])
def setBrush(self, brush):
self.brush = fn.mkBrush(brush)
def setPen(self, *args, **kwargs):
self.pen = fn.mkPen(*args, **kwargs)
def setPath(self, path):
self.path = path
self.update()
def paintEvent(self, ev):
QtGui.QPushButton.paintEvent(self, ev)
margin = 7
geom = QtCore.QRectF(0, 0, self.width(), self.height()).adjusted(margin, margin, -margin, -margin)
rect = self.path.boundingRect()
scale = min(geom.width() / float(rect.width()), geom.height() / float(rect.height()))
p = QtGui.QPainter(self)
p.setRenderHint(p.Antialiasing)
p.translate(geom.center())
p.scale(scale, scale)
p.translate(-rect.center())
p.setPen(self.pen)
p.setBrush(self.brush)
p.drawPath(self.path)
p.end()
|