from PyQt5 import QtGui
from PyQt5.QtWidgets import QApplication, QMainWindow
import sys
from PyQt5.QtGui import QBrush, QPen,QPainter, QPolygon
from PyQt5.QtCore import QPoint, Qt
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.title = "PyQt5 Drawing Polygon"
self.InitWindow()
def InitWindow(self):
self.setWindowIcon(QtGui.QIcon("icon.png"))
self.setWindowTitle(self.title)
self.show()
self.resize(1000,1000)
def paintEvent(self, event):
painter = QPainter(self)
painter.setPen(QPen(Qt.red, 2, Qt.SolidLine))
# '601,164,396,899,601', '315,358,812,782,315'
points = QPolygon([
QPoint(601,315),
QPoint(164,358),
QPoint(396,812),
QPoint(899,782),
QPoint(601,315)
])
painter.drawPolygon(points)
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())