from PySide2.QtGui import QPainter, QPen from PySide2.QtWidgets import QWidget class MyWidget(QWidget): def paintEvent(self, event): painter = QPainter(self) painter.setPen(QPen(Qt.black, 2)) painter.drawLine(10, 10, 100, 100)
class MyWidget(QWidget): def paintEvent(self, event): painter = QPainter(self) painter.setPen(QPen(Qt.black, 2)) painter.drawRect(50, 50, 100, 100)
class MyWidget(QWidget): def paintEvent(self, event): painter = QPainter(self) painter.setPen(QPen(Qt.black, 2)) painter.drawEllipse(50, 50, 100, 50)The PySide2.QtGui QPainter class is part of the PySide2 package, which is a set of Python bindings for the Qt application framework. It provides a Python interface to the Qt libraries, allowing developers to create cross-platform GUI applications using the Python programming language.