@@ -0,0 +1,1452 @@
+#!/usr/bin/env python3%0A# -*- coding: utf-8 -*-%0A%0A# See https://www.youtube.com/watch?v=U1Nitj0iOgU%0A%0Aimport sys%0Afrom PyQt5.QtWidgets import QApplication, QWidget%0Afrom PyQt5.QtGui import QPainter, QBrush, QPen%0Afrom PyQt5.QtCore import Qt%0A%0A%0Aclass MyPaintWidget(QWidget):%0A%0A    def __init__(self):%0A        super().__init__()%0A%0A        # Set window background color%0A        self.setAutoFillBackground(True)%0A%0A        palette = self.palette()%0A        palette.setColor(self.backgroundRole(), Qt.white)%0A%0A        self.setPalette(palette)%0A%0A    def paintEvent(self, event):%0A        qp = QPainter(self)%0A%0A        qp.setPen(QPen(Qt.black, 5, Qt.SolidLine))%0A        qp.setBrush(QBrush(Qt.red, Qt.SolidPattern))%0A        qp.setRenderHint(QPainter.Antialiasing)           # %3C- Set anti-aliasing  See https://wiki.python.org/moin/PyQt/Painting%2520and%2520clipping%2520demonstration%0A%0A        x_start, y_start, x_end, y_end = 100, 50, 50, 100%0A        qp.drawLine(x_start, y_start, x_end, y_end)%0A%0A%0Aif __name__ == '__main__':%0A    app = QApplication(sys.argv)%0A%0A    widget = MyPaintWidget()%0A    widget.show()%0A%0A    # The mainloop of the application. The event handling starts from this point.%0A    # The exec_() method has an underscore. It is because the exec is a Python keyword. And thus, exec_() was used instead.%0A    exit_code = app.exec_()%0A%0A    # The sys.exit() method ensures a clean exit.%0A    # The environment will be informed, how the application ended.%0A    sys.exit(exit_code)%0A

Add a snippet.