GridItem: Add custom line width based on pen option.

This commit is contained in:
Anthony De Bortoli 2021-04-11 11:40:11 +02:00
parent 5a08650853
commit 0e7b8a4828
2 changed files with 21 additions and 15 deletions

View File

@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
## Add path to library (just for examples; you do not need this)
from PySide2.QtGui import QPen, QColor
import initExample
from pyqtgraph.Qt import QtCore, QtGui
@ -56,6 +58,9 @@ prox.setPos(100,0)
vb.addItem(prox)
g = pg.GridItem()
p = QPen(QColor(0, 255, 255))
p.setWidthF(1)
g.opts["pen"] = p
vb.addItem(g)
if __name__ == '__main__':

View File

@ -157,6 +157,7 @@ class GridItem(UIGraphicsItem):
linePen = self.opts['pen']
lineColor = self.opts['pen'].color()
lineWidth = self.opts['pen'].width()
lineColor.setAlpha(c)
linePen.setColor(lineColor)
@ -170,9 +171,9 @@ class GridItem(UIGraphicsItem):
for x in range(0, int(nl[ax])):
linePen.setCosmetic(False)
if ax == 0:
linePen.setWidthF(self.pixelWidth())
linePen.setWidthF(lineWidth * self.pixelWidth())
else:
linePen.setWidthF(self.pixelHeight())
linePen.setWidthF(lineWidth * self.pixelHeight())
p.setPen(linePen)
p1 = np.array([0.,0.])
p2 = np.array([0.,0.])