14 from PyQt5.QtGui import QPixmap, QColor, QRegion, QPainter, QPalette, \ |
14 from PyQt5.QtGui import QPixmap, QColor, QRegion, QPainter, QPalette, \ |
15 QPaintEngine, QPen, QBrush |
15 QPaintEngine, QPen, QBrush |
16 from PyQt5.QtWidgets import QWidget, QApplication, QToolTip |
16 from PyQt5.QtWidgets import QWidget, QApplication, QToolTip |
17 |
17 |
18 |
18 |
19 def drawRect(painter, rect, outline, fill=QColor()): |
19 def drawRect(painter, rect, outline, fill=None): |
20 """ |
20 """ |
21 Module function to draw a rectangle with the given parameters. |
21 Module function to draw a rectangle with the given parameters. |
22 |
22 |
23 @param painter reference to the painter to be used (QPainter) |
23 @param painter reference to the painter to be used (QPainter) |
24 @param rect rectangle to be drawn (QRect) |
24 @param rect rectangle to be drawn (QRect) |
33 painter.setPen(Qt.NoPen) |
33 painter.setPen(Qt.NoPen) |
34 painter.setBrush(outline) |
34 painter.setBrush(outline) |
35 painter.drawRect(rect) |
35 painter.drawRect(rect) |
36 if fill.isValid(): |
36 if fill.isValid(): |
37 painter.setClipping(False) |
37 painter.setClipping(False) |
38 painter.setBrush(fill) |
38 painter.setBrush(fill or QColor()) |
39 painter.drawRect(rect.adjusted(1, 1, -1, -1)) |
39 painter.drawRect(rect.adjusted(1, 1, -1, -1)) |
40 painter.restore() |
40 painter.restore() |
41 |
41 |
42 |
42 |
43 class SnapshotRegionGrabber(QWidget): |
43 class SnapshotRegionGrabber(QWidget): |