basicdrawing_rc.py

# Resource object code (Python 3)
# Created by: object code
# Created by: The Resource Compiler for Qt version 5.14.0
# WARNING! All changes made in this file will be lost!

from PySide6 import QtCore

qt_resource_data = b"\
\x00\x00\x03X\
\x89\
PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
\x00\x00 \x00\x00\x00\x10\x08\x02\x00\x00\x00\xf8b\xea\x0e\
\x00\x00\x00\x04gAMA\x00\x00\xb1\x8e|\xfbQ\x93\
\x00\x00\x00 cHRM\x00\x00z%\x00\x00\x80\x83\
\x00\x00\xf9\xff\x00\x00\x80\xe8\x00\x00u0\x00\x00\xea`\
\x00\x00:\x97\x00\x00\x17o\x97\xa9\x99\xd4\x00\x00\x02\xe3\
IDAT8\xcbE\x94\xcb\x8d\x1eE\x10\xc7\x7fU\
\xd53\xb3\xf6j\x9d\x09I\x90\x04\x0e\x05\x09\x99x\xe0\
\xc4\xc1\x12\x07B \x04\x08\xc1\x96\xd7\xcb\xb7\xf3\xcd\xf4\
\xa3\xaa8L[\xees\xbd\xfa\xff\x92\xcf\xff\xfc\xa6\x86\
\x1a(* dB\x92A\x048\x1e\xa4\x93A89\
@\x11A\x94\x8cY\x93WABb+e\xc3\x16\xac\
 \x85\xf7?\xbd/\x08\xf5\xf6o\xd9P%\x0c5\xc4\
H\xc7;1\x18\x8d\x18\xa4\x13Nt| \x82\x16\x80\
t\xdc\xf1F\x0c\xc2\x11\x00\xa4\xb0\xbc\xe1\xe1\x09\xdb\xf8\
\xf5\xc3\x87\x0c\x8a\x1a\xaa\xd4\x97\xbf\xcb\x82.\xf3\x04\x9c\
\xa8\xd4\x9d~\xa7\x9f\xf3\xd8\xd1\xf0\x93p\xb4 \x82w\
\xfa\xc1h\x10D\x02\xa8b\x0b\xeb#\xfd\x1d\x7f\xfe\xf5\
1\x02Q\x8a\x16\xd4\x10\xa5\xdd>ja{\x22 \x06\
}\xe7\xfc\xc2\xf9\x1f\xc73\xf5u\x82\xd0vFE\x94\
\x18x\xa7\xef\x8c\x8e*\xde\xc9\xc4\x0a\xdb;\x1e\x9eX\
\x1e\xf1\x0e\x01PD\x10\xc3\x0aa\x94\x07\xca\x86.\x84\
\x93\x01L2\xc6\x81\x0f\xd2i\x07^\x01\xc4\x88\x81\x18\
\x0c\xbc3\x1a\xd1\xf1B\xd9h\x85Lb\x90I\x06\xe5\
\xc2T\x0cQlE\x0b\x19d\xe2\x83v\xe7\xf8J\xdb\
Ihw\xc6\x9d\xd1\x89A\x06\xb6 J?!\x18\x8d\
\xbe\x93I\x11\xbca\x1b\xfd\xa0\xef\x8c\x13\xef\x17\x07\x05\
QD\x11!\x9cQ\xa97\xce\x17\x8e\xaf\xd4\xdb\xe4`\
\x9c\xdc\xbf\x90\x17\xb7\x83\xf5\x11Q\xfa}v\x89\x92\x8e\
\x08\x11x\x87\xa4\x9f\xf4\x93Q/\x88\x14\xb9x\x1b\x8c\
\xca\xf9\xc2\xf1\xc2\xf1<\xfb\xc9\x89\xd5hx\xbb\xb4B\
\x0c\x80QQ\xa3l,o!'n^Q\x9d\xda\x8d\
\xa0D\x00\x98\x12+\x80W\xfaI\xbbQo\xb4W2\
\x09g\x1cd\xa0\x85~\xc7;Z\xe8\x8a\x15\xc89\xb7\
\xac\x08\x88R\x1e\xa6\x823A )\x17\x99b\xa8\x11\
\x8ew\xbc\x11A8u\xa7\x1fS\x91\xa3~\xf7\x97w\
2\x88\x95p`\xee6\xc3\x16\x96G2\xbeA\xa7 \
\x14Q\x08b\xd0\x0eT\x19\x95\xe8Lb\x8cLFe\
\x1c\xd4\x1d?I\x07!\x83\x14\xa2\x91I\xef\xa0\xaco\
\x91\x85d\xb2}\xad\xbc\x0e*\x99x\xa7\xed\xec\x9f\xb0\
\x85\x18\x93\x0f5\xcaJ7\x86S_i\xfb4\xd4%\
A5\x10F#\x1d5\xfa\x1d5\xb2\x93\x81(j\x13\
\x15[(1\xe8\x07\xf7g\xf6O\xacO\xa8\xe1\x8dQ\
!\xb0\x82\x95\xefn\xb8\xac$B\x0f`\xc6Cy\x83\
m\x84\xd3O\x00\xdb\xe6\xee\xebD+\x94p|\xf0\xc7\
\xef\x1f#\xd8\x9e\xa6K\x11\xa2\xd1v\xda\x9d\xfaJ\xbb\
1*\x97\xf5/Ef\x80 \x8a\x1eX\xc5\xf6\xc9\xa2\
\x1a\xba\x00\x94o\x9bJ8\xbf\xfc\xfc\xe12\x9e\xad\x88\
\xccT\xf1A\xdd\x89+\xf2\xeaL\xba\xab\x87+h\xa1\
\xac\xe8\x82tTA\xd0\x05U\x00QtA\x8dL\xe4\
\xc7\x1f@g\x16^\xc0]\xef\x92S\xe6\x84>\x06\x04\
W]\x06\xe4\xfcAY\xbf\xb5\x08Wn\x8a\xce9\x97\
\xe4\xfe\x07\xb6\x84\x15$\x5c\xbcO\xce\x00\x00\x00\x00I\
END\xaeB`\x82\
\x00\x00\x02\x15\
\x89\
PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
\x00\x00P\x00\x00\x00P\x04\x03\x00\x00\x00|?\xef\x9e\
\x00\x00\x00\x15PLTE\xa3\xc2\x00\xf4\xf8\xe1\x8a\xa1\
\x09\x14\x14\x18?G\x16\xd3\xe2\x86p\x82\x0e\xfd\x17\x22\
9\x00\x00\x00\x09pHYs\x00\x00\x00H\x00\x00\x00\
H\x00F\xc9k>\x00\x00\x01\xa6IDATH\xc7\
\xedVKn\x840\x0cEf\xc49\xa2I\xd55\x22\
\x11k\xd4Hs\x0eT\x10\xf7?B\x0b\xc4L\xfc\x83\
\xd9u\xd1\xf1\x0a\xa2\x97\x17\xdb\xb1\x9fSUo\xfbk\
\xbb/\xcb\xfd\x1a\x05s\x0a\xbf\x16\x1f\xee\x1c\xd7l\xb0\
\x0d:\x9e\xe2Ba\xe3\x8b\xb8\x13$$\x0a\x8c\x96\x9f\
S`\xd6\xeb\xb8[\x106\xa8\xc0$\x81\xf1EB\x9d\
\x12\x09\xe3cY\xe6dSbj\xf6+\x81\xd9\xa4\xf4\
\x19\x87\xff\x1fV\xe0\x89\xaf\xe7d9=\x14'\xd2?\
\xa8'\x7f\xc9\xbd\x9dz\xf2\x93n\xc45\x167\xb0\xdd\
~u\xb6VJ\xe3F\xd7`\xfb\x06\xc5\xc9\x9a\x9e\xe2\
\xf7\xf8\x93tr\x22K\x90\xe9k\x99\xc9D\x0e\xf1\x19\
\xd0\xc8hR\x99D\xc0\x02\x07\x91r [\xf3m\xb6\
l\xffQ\x11=%\x5c\x9d\x9cx~\x080\x13v\xf8\
9\xf04v\x94\xd0a\xd6\x04\xb0\x15\x84\xfb\xba\x01\x84\
\xb2\xa9u\xe0P\x12\xf6\xd5\x05#\x84k\xc6\xb6 \xcc\
\x9473j\xa0\xca#\xa2>\xf2\xe8\xa9\x9ex\x15\x18\
\x09\xa1~3x\xd75\x93(q\xd7\xb8\x02T\x1f\x81\
6RY\x8f\x9bS\x1d\xe6R\xa9G\xacp(\x98B\
\x98d\x85\x1f=\xb3wK\x11<\xeb\x99\xa3\x0bas\
\x1eL\xe5{\xf6\xb5\xef*\x9aO\xa7)\x85\xcb\x1aQ\
PFU{:\xae\x82R{\x1av\x0e\x98\xe2\xcc\xf5\
\x11)-\xc5=\x90\xb35\xbeP\xc3{\xaa\xe1\xa66\
\xb3\xa9\xa0Q\xaas\xe6\x94\x92\xdbx1\x84O\xa6\xd7\
\xa4\xe2\xe2\x0b\xf3z\xb2\xc6a\x93d\x85\xc7\x8b\xb7\xc7\
\x1e\x84\xb7F6\x7f\xa5\x80A\xb8\xda\x92\xdf=\xf9b\
\x87\xb3\x97\xd4\xe7\xf7\xf1\x92\x02\xf7~Y\xfe?\xfb\x01\
\xbd\xf6\xdd\x91\xa2\xf3\xda\xd4\x00\x00\x00\x00IEND\
\xaeB`\x82\
"

qt_resource_name = b"\
\x00\x06\
\x07\x03}\xc3\
\x00i\
\x00m\x00a\x00g\x00e\x00s\
\x00\x09\
\x0f\x9e\x84G\
\x00b\
\x00r\x00i\x00c\x00k\x00.\x00p\x00n\x00g\
\x00\x0b\
\x05R\xbf'\
\x00q\
\x00t\x00-\x00l\x00o\x00g\x00o\x00.\x00p\x00n\x00g\
"

qt_resource_struct = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00*\x00\x00\x00\x00\x00\x01\x00\x00\x03\x5c\
\x00\x00\x01e\xaf\x16\xd2\xa1\
\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01e\xaf\x16\xd2\xa1\
"

def qInitResources():
    QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)

def qCleanupResources():
    QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)

qInitResources()

basicdrawing.qrc

<!DOCTYPE RCC><RCC version="1.0">
<qresource>
    <file>images/brick.png</file>
    <file>images/qt-logo.png</file>
</qresource>
</RCC>

basicdrawing.py

"""PySide6 port of the widgets/painting/basicdrawing example from Qt v5.x, originating from PyQt"""

from PySide6.QtCore import QPoint, QRect, QSize, Qt, qVersion
from PySide6.QtGui import (QBrush, QConicalGradient, QLinearGradient, QPainter,
        QPainterPath, QPalette, QPen, QPixmap, QPolygon, QRadialGradient)
from PySide6.QtWidgets import (QApplication, QCheckBox, QComboBox, QGridLayout,
        QLabel, QSpinBox, QWidget)

import basicdrawing_rc


class RenderArea(QWidget):
    points = QPolygon([
        QPoint(10, 80),
        QPoint(20, 10),
        QPoint(80, 30),
        QPoint(90, 70)
    ])

    Line, Points, Polyline, Polygon, Rect, RoundedRect, Ellipse, Arc, Chord, \
            Pie, Path, Text, Pixmap = range(13)

    def __init__(self, parent=None):
        super(RenderArea, self).__init__(parent)

        self.pen = QPen()
        self.brush = QBrush()
        self.pixmap = QPixmap()

        self.shape = RenderArea.Polygon
        self.antialiased = False
        self.transformed = False
        self.pixmap.load(':/images/qt-logo.png')

        self.setBackgroundRole(QPalette.Base)
        self.setAutoFillBackground(True)

    def minimumSizeHint(self):
        return QSize(100, 100)

    def sizeHint(self):
        return QSize(400, 200)

    def setShape(self, shape):
        self.shape = shape
        self.update()

    def setPen(self, pen):
        self.pen = pen
        self.update()

    def setBrush(self, brush):
        self.brush = brush
        self.update()

    def setAntialiased(self, antialiased):
        self.antialiased = antialiased
        self.update()

    def setTransformed(self, transformed):
        self.transformed = transformed
        self.update()

    def paintEvent(self, event):
        rect = QRect(10, 20, 80, 60)

        path = QPainterPath()
        path.moveTo(20, 80)
        path.lineTo(20, 30)
        path.cubicTo(80, 0, 50, 50, 80, 80)

        startAngle = 30 * 16
        arcLength = 120 * 16

        painter = QPainter(self)
        painter.setPen(self.pen)
        painter.setBrush(self.brush)
        if self.antialiased:
            painter.setRenderHint(QPainter.Antialiasing)

        for x in range(0, self.width(), 100):
            for y in range(0, self.height(), 100):
                painter.save()
                painter.translate(x, y)
                if self.transformed:
                    painter.translate(50, 50)
                    painter.rotate(60.0)
                    painter.scale(0.6, 0.9)
                    painter.translate(-50, -50)

                if self.shape == RenderArea.Line:
                    painter.drawLine(rect.bottomLeft(), rect.topRight())
                elif self.shape == RenderArea.Points:
                    painter.drawPoints(RenderArea.points)
                elif self.shape == RenderArea.Polyline:
                    painter.drawPolyline(RenderArea.points)
                elif self.shape == RenderArea.Polygon:
                    painter.drawPolygon(RenderArea.points)
                elif self.shape == RenderArea.Rect:
                    painter.drawRect(rect)
                elif self.shape == RenderArea.RoundedRect:
                    painter.drawRoundedRect(rect, 25, 25, Qt.RelativeSize)
                elif self.shape == RenderArea.Ellipse:
                    painter.drawEllipse(rect)
                elif self.shape == RenderArea.Arc:
                    painter.drawArc(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Chord:
                    painter.drawChord(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Pie:
                    painter.drawPie(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Path:
                    painter.drawPath(path)
                elif self.shape == RenderArea.Text:
                    painter.drawText(rect, Qt.AlignCenter,
                                     "PySide 2\nQt %s" % qVersion())
                elif self.shape == RenderArea.Pixmap:
                    painter.drawPixmap(10, 10, self.pixmap)

                painter.restore()

        painter.setPen(self.palette().dark().color())
        painter.setBrush(Qt.NoBrush)
        painter.drawRect(QRect(0, 0, self.width() - 1, self.height() - 1))


IdRole = Qt.UserRole

class Window(QWidget):
    def __init__(self):
        super(Window, self).__init__()

        self.renderArea = RenderArea()

        self.shapeComboBox = QComboBox()
        self.shapeComboBox.addItem("Polygon", RenderArea.Polygon)
        self.shapeComboBox.addItem("Rectangle", RenderArea.Rect)
        self.shapeComboBox.addItem("Rounded Rectangle", RenderArea.RoundedRect)
        self.shapeComboBox.addItem("Ellipse", RenderArea.Ellipse)
        self.shapeComboBox.addItem("Pie", RenderArea.Pie)
        self.shapeComboBox.addItem("Chord", RenderArea.Chord)
        self.shapeComboBox.addItem("Path", RenderArea.Path)
        self.shapeComboBox.addItem("Line", RenderArea.Line)
        self.shapeComboBox.addItem("Polyline", RenderArea.Polyline)
        self.shapeComboBox.addItem("Arc", RenderArea.Arc)
        self.shapeComboBox.addItem("Points", RenderArea.Points)
        self.shapeComboBox.addItem("Text", RenderArea.Text)
        self.shapeComboBox.addItem("Pixmap", RenderArea.Pixmap)

        shapeLabel = QLabel("&Shape:")
        shapeLabel.setBuddy(self.shapeComboBox)

        self.penWidthSpinBox = QSpinBox()
        self.penWidthSpinBox.setRange(0, 20)
        self.penWidthSpinBox.setSpecialValueText("0 (cosmetic pen)")

        penWidthLabel = QLabel("Pen &Width:")
        penWidthLabel.setBuddy(self.penWidthSpinBox)

        self.penStyleComboBox = QComboBox()
        self.penStyleComboBox.addItem("Solid", Qt.SolidLine)
        self.penStyleComboBox.addItem("Dash", Qt.DashLine)
        self.penStyleComboBox.addItem("Dot", Qt.DotLine)
        self.penStyleComboBox.addItem("Dash Dot", Qt.DashDotLine)
        self.penStyleComboBox.addItem("Dash Dot Dot", Qt.DashDotDotLine)
        self.penStyleComboBox.addItem("None", Qt.NoPen)

        penStyleLabel = QLabel("&Pen Style:")
        penStyleLabel.setBuddy(self.penStyleComboBox)

        self.penCapComboBox = QComboBox()
        self.penCapComboBox.addItem("Flat", Qt.FlatCap)
        self.penCapComboBox.addItem("Square", Qt.SquareCap)
        self.penCapComboBox.addItem("Round", Qt.RoundCap)

        penCapLabel = QLabel("Pen &Cap:")
        penCapLabel.setBuddy(self.penCapComboBox)

        self.penJoinComboBox = QComboBox()
        self.penJoinComboBox.addItem("Miter", Qt.MiterJoin)
        self.penJoinComboBox.addItem("Bevel", Qt.BevelJoin)
        self.penJoinComboBox.addItem("Round", Qt.RoundJoin)

        penJoinLabel = QLabel("Pen &Join:")
        penJoinLabel.setBuddy(self.penJoinComboBox)

        self.brushStyleComboBox = QComboBox()
        self.brushStyleComboBox.addItem("Linear Gradient",
                Qt.LinearGradientPattern)
        self.brushStyleComboBox.addItem("Radial Gradient",
                Qt.RadialGradientPattern)
        self.brushStyleComboBox.addItem("Conical Gradient",
                Qt.ConicalGradientPattern)
        self.brushStyleComboBox.addItem("Texture", Qt.TexturePattern)
        self.brushStyleComboBox.addItem("Solid", Qt.SolidPattern)
        self.brushStyleComboBox.addItem("Horizontal", Qt.HorPattern)
        self.brushStyleComboBox.addItem("Vertical", Qt.VerPattern)
        self.brushStyleComboBox.addItem("Cross", Qt.CrossPattern)
        self.brushStyleComboBox.addItem("Backward Diagonal", Qt.BDiagPattern)
        self.brushStyleComboBox.addItem("Forward Diagonal", Qt.FDiagPattern)
        self.brushStyleComboBox.addItem("Diagonal Cross", Qt.DiagCrossPattern)
        self.brushStyleComboBox.addItem("Dense 1", Qt.Dense1Pattern)
        self.brushStyleComboBox.addItem("Dense 2", Qt.Dense2Pattern)
        self.brushStyleComboBox.addItem("Dense 3", Qt.Dense3Pattern)
        self.brushStyleComboBox.addItem("Dense 4", Qt.Dense4Pattern)
        self.brushStyleComboBox.addItem("Dense 5", Qt.Dense5Pattern)
        self.brushStyleComboBox.addItem("Dense 6", Qt.Dense6Pattern)
        self.brushStyleComboBox.addItem("Dense 7", Qt.Dense7Pattern)
        self.brushStyleComboBox.addItem("None", Qt.NoBrush)

        brushStyleLabel = QLabel("&Brush Style:")
        brushStyleLabel.setBuddy(self.brushStyleComboBox)

        otherOptionsLabel = QLabel("Other Options:")
        self.antialiasingCheckBox = QCheckBox("&Antialiasing")
        self.transformationsCheckBox = QCheckBox("&Transformations")

        self.shapeComboBox.activated.connect(self.shapeChanged)
        self.penWidthSpinBox.valueChanged.connect(self.penChanged)
        self.penStyleComboBox.activated.connect(self.penChanged)
        self.penCapComboBox.activated.connect(self.penChanged)
        self.penJoinComboBox.activated.connect(self.penChanged)
        self.brushStyleComboBox.activated.connect(self.brushChanged)
        self.antialiasingCheckBox.toggled.connect(self.renderArea.setAntialiased)
        self.transformationsCheckBox.toggled.connect(self.renderArea.setTransformed)

        mainLayout = QGridLayout()
        mainLayout.setColumnStretch(0, 1)
        mainLayout.setColumnStretch(3, 1)
        mainLayout.addWidget(self.renderArea, 0, 0, 1, 4)
        mainLayout.setRowMinimumHeight(1, 6)
        mainLayout.addWidget(shapeLabel, 2, 1, Qt.AlignRight)
        mainLayout.addWidget(self.shapeComboBox, 2, 2)
        mainLayout.addWidget(penWidthLabel, 3, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penWidthSpinBox, 3, 2)
        mainLayout.addWidget(penStyleLabel, 4, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penStyleComboBox, 4, 2)
        mainLayout.addWidget(penCapLabel, 5, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penCapComboBox, 5, 2)
        mainLayout.addWidget(penJoinLabel, 6, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penJoinComboBox, 6, 2)
        mainLayout.addWidget(brushStyleLabel, 7, 1, Qt.AlignRight)
        mainLayout.addWidget(self.brushStyleComboBox, 7, 2)
        mainLayout.setRowMinimumHeight(8, 6)
        mainLayout.addWidget(otherOptionsLabel, 9, 1, Qt.AlignRight)
        mainLayout.addWidget(self.antialiasingCheckBox, 9, 2)
        mainLayout.addWidget(self.transformationsCheckBox, 10, 2)
        self.setLayout(mainLayout)

        self.shapeChanged()
        self.penChanged()
        self.brushChanged()
        self.antialiasingCheckBox.setChecked(True)

        self.setWindowTitle("Basic Drawing")

    def shapeChanged(self):
        shape = self.shapeComboBox.itemData(self.shapeComboBox.currentIndex(),
                IdRole)
        self.renderArea.setShape(shape)

    def penChanged(self):
        width = self.penWidthSpinBox.value()
        style = Qt.PenStyle(self.penStyleComboBox.itemData(
                self.penStyleComboBox.currentIndex(), IdRole))
        cap = Qt.PenCapStyle(self.penCapComboBox.itemData(
                self.penCapComboBox.currentIndex(), IdRole))
        join = Qt.PenJoinStyle(self.penJoinComboBox.itemData(
                self.penJoinComboBox.currentIndex(), IdRole))

        self.renderArea.setPen(QPen(Qt.blue, width, style, cap, join))

    def brushChanged(self):
        style = Qt.BrushStyle(self.brushStyleComboBox.itemData(
                self.brushStyleComboBox.currentIndex(), IdRole))

        if style == Qt.LinearGradientPattern:
            linearGradient = QLinearGradient(0, 0, 100, 100)
            linearGradient.setColorAt(0.0, Qt.white)
            linearGradient.setColorAt(0.2, Qt.green)
            linearGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(linearGradient))
        elif style == Qt.RadialGradientPattern:
            radialGradient = QRadialGradient(50, 50, 50, 70, 70)
            radialGradient.setColorAt(0.0, Qt.white)
            radialGradient.setColorAt(0.2, Qt.green)
            radialGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(radialGradient))
        elif style == Qt.ConicalGradientPattern:
            conicalGradient = QConicalGradient(50, 50, 150)
            conicalGradient.setColorAt(0.0, Qt.white)
            conicalGradient.setColorAt(0.2, Qt.green)
            conicalGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(conicalGradient))
        elif style == Qt.TexturePattern:
            self.renderArea.setBrush(QBrush(QPixmap(':/images/brick.png')))
        else:
            self.renderArea.setBrush(QBrush(Qt.green, style))


if __name__ == '__main__':

    import sys

    app = QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec_())