Загрузка данных


import sys
from PyQt6.QtWidgets import QApplication, QMainWindow
from PyQt6.QtGui import QPainter, QPen
from PyQt6.QtCore import Qt, QPointF,QLineF


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        # Настройка окна
        self.setWindowTitle("Окно с диагональю")
        self.setGeometry(100, 100, 500, 400)

    def paintEvent(self, event):
        points = [QPointF(0,78),QPointF(1,80),QPointF(2,79)]
        """Рисуем диагональ"""
        painter = QPainter(self)

        pen = QPen()
        pen.setWidth(2)  # Толщина линии
        pen.setColor(Qt.GlobalColor.blue)  # Цвет линии
        painter.setPen(pen)

        line1 = QLineF(points[0],points[1])
        line2 = QLineF(points[1], points[2])
        # for point in points:


        w = self.width()
        h = self.height()
        m = 50.0
        x0 = 0.0
        x1 = 2.0
        y0 = 78.0
        y1 = 80.0
        a = (w - 2*m)/(x1 - x0)
        b = m -a * x0
        c = (h - 2*m)/(y0 -y1)
        d = m - c* y1
        points_real = [QPointF(0,0),]
        points_real.clear()
        for point in points:
            points_real.append(QPointF(point.x()*a + b, point.y()*c + d))

        line1 = QLineF(points_real[0],points_real[1])
        line2 = QLineF(points_real[1], points_real[2])
        painter.drawLine(line1)
        painter.drawLine(line2)

# Создаем приложение
app = QApplication(sys.argv)

# Создаем и показываем окно
window = MainWindow()
window.show()

# Запускаем приложение
app.exec()