import sys
from random import randint

from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtGui import QPainter, QColor

from UI import Ui_Form

ACTIVE_AREA = [500, 500]


class MainForm(QMainWindow, Ui_Form):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.setFixedSize(self.width(), self.height())
        self.widgetName = 'Git и желтые окружности'
        self.setWindowTitle(self.widgetName)  # заголовок виджета

        self.do_paint = False
        self.pushButton.clicked.connect(self.press_button)

    def press_button(self):
        self.do_paint = True
        self.repaint()

    def paintEvent(self, event):
        if self.do_paint:
            qp = QPainter()
            qp.begin(self)
            self.draw(qp)
            qp.end()

    def draw(self, qp):
        qp.setBrush(QColor(*[int(randint(0, 255)) for _ in range(3)]))
        qp.setPen(QColor(0, 0, 0))

        x, y = randint(20, ACTIVE_AREA[0] - 20), randint(20, ACTIVE_AREA[1] - 20)
        max_size = min([x, y, ACTIVE_AREA[0] - x, ACTIVE_AREA[1] - y])
        radius = randint(
            20, max_size if max_size <= ACTIVE_AREA[0] // 8 else ACTIVE_AREA[1] // 8)

        qp.drawEllipse(x - radius, y - radius, radius * 2, radius * 2)


def except_hook(cls, exception, traceback):
    sys.__excepthook__(cls, exception, traceback)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    form = MainForm()
    form.show()
    sys.excepthook = except_hook
    sys.exit(app.exec())

2fb3a0ea45f41d2b121ee961da66ac0a3a9d9a4e
<mask token>


class MainForm(QMainWindow, Ui_Form):

    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.setFixedSize(self.width(), self.height())
        self.widgetName = 'Git и желтые окружности'
        self.setWindowTitle(self.widgetName)
        self.do_paint = False
        self.pushButton.clicked.connect(self.press_button)

    def press_button(self):
        self.do_paint = True
        self.repaint()
    <mask token>

    def draw(self, qp):
        qp.setBrush(QColor(*[int(randint(0, 255)) for _ in range(3)]))
        qp.setPen(QColor(0, 0, 0))
        x, y = randint(20, ACTIVE_AREA[0] - 20), randint(20, ACTIVE_AREA[1] -
            20)
        max_size = min([x, y, ACTIVE_AREA[0] - x, ACTIVE_AREA[1] - y])
        radius = randint(20, max_size if max_size <= ACTIVE_AREA[0] // 8 else
            ACTIVE_AREA[1] // 8)
        qp.drawEllipse(x - radius, y - radius, radius * 2, radius * 2)


<mask token>

<mask token>


class MainForm(QMainWindow, Ui_Form):

    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.setFixedSize(self.width(), self.height())
        self.widgetName = 'Git и желтые окружности'
        self.setWindowTitle(self.widgetName)
        self.do_paint = False
        self.pushButton.clicked.connect(self.press_button)

    def press_button(self):
        self.do_paint = True
        self.repaint()

    def paintEvent(self, event):
        if self.do_paint:
            qp = QPainter()
            qp.begin(self)
            self.draw(qp)
            qp.end()

    def draw(self, qp):
        qp.setBrush(QColor(*[int(randint(0, 255)) for _ in range(3)]))
        qp.setPen(QColor(0, 0, 0))
        x, y = randint(20, ACTIVE_AREA[0] - 20), randint(20, ACTIVE_AREA[1] -
            20)
        max_size = min([x, y, ACTIVE_AREA[0] - x, ACTIVE_AREA[1] - y])
        radius = randint(20, max_size if max_size <= ACTIVE_AREA[0] // 8 else
            ACTIVE_AREA[1] // 8)
        qp.drawEllipse(x - radius, y - radius, radius * 2, radius * 2)


<mask token>

<mask token>


class MainForm(QMainWindow, Ui_Form):

    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.setFixedSize(self.width(), self.height())
        self.widgetName = 'Git и желтые окружности'
        self.setWindowTitle(self.widgetName)
        self.do_paint = False
        self.pushButton.clicked.connect(self.press_button)

    def press_button(self):
        self.do_paint = True
        self.repaint()

    def paintEvent(self, event):
        if self.do_paint:
            qp = QPainter()
            qp.begin(self)
            self.draw(qp)
            qp.end()

    def draw(self, qp):
        qp.setBrush(QColor(*[int(randint(0, 255)) for _ in range(3)]))
        qp.setPen(QColor(0, 0, 0))
        x, y = randint(20, ACTIVE_AREA[0] - 20), randint(20, ACTIVE_AREA[1] -
            20)
        max_size = min([x, y, ACTIVE_AREA[0] - x, ACTIVE_AREA[1] - y])
        radius = randint(20, max_size if max_size <= ACTIVE_AREA[0] // 8 else
            ACTIVE_AREA[1] // 8)
        qp.drawEllipse(x - radius, y - radius, radius * 2, radius * 2)


def except_hook(cls, exception, traceback):
    sys.__excepthook__(cls, exception, traceback)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    form = MainForm()
    form.show()
    sys.excepthook = except_hook
    sys.exit(app.exec())

import sys
from random import randint
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtGui import QPainter, QColor
from UI import Ui_Form
ACTIVE_AREA = [500, 500]


class MainForm(QMainWindow, Ui_Form):

    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.setFixedSize(self.width(), self.height())
        self.widgetName = 'Git и желтые окружности'
        self.setWindowTitle(self.widgetName)
        self.do_paint = False
        self.pushButton.clicked.connect(self.press_button)

    def press_button(self):
        self.do_paint = True
        self.repaint()

    def paintEvent(self, event):
        if self.do_paint:
            qp = QPainter()
            qp.begin(self)
            self.draw(qp)
            qp.end()

    def draw(self, qp):
        qp.setBrush(QColor(*[int(randint(0, 255)) for _ in range(3)]))
        qp.setPen(QColor(0, 0, 0))
        x, y = randint(20, ACTIVE_AREA[0] - 20), randint(20, ACTIVE_AREA[1] -
            20)
        max_size = min([x, y, ACTIVE_AREA[0] - x, ACTIVE_AREA[1] - y])
        radius = randint(20, max_size if max_size <= ACTIVE_AREA[0] // 8 else
            ACTIVE_AREA[1] // 8)
        qp.drawEllipse(x - radius, y - radius, radius * 2, radius * 2)


def except_hook(cls, exception, traceback):
    sys.__excepthook__(cls, exception, traceback)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    form = MainForm()
    form.show()
    sys.excepthook = except_hook
    sys.exit(app.exec())

import sys
from random import randint

from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtGui import QPainter, QColor

from UI import Ui_Form

ACTIVE_AREA = [500, 500]


class MainForm(QMainWindow, Ui_Form):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.setFixedSize(self.width(), self.height())
        self.widgetName = 'Git и желтые окружности'
        self.setWindowTitle(self.widgetName)  # заголовок виджета

        self.do_paint = False
        self.pushButton.clicked.connect(self.press_button)

    def press_button(self):
        self.do_paint = True
        self.repaint()

    def paintEvent(self, event):
        if self.do_paint:
            qp = QPainter()
            qp.begin(self)
            self.draw(qp)
            qp.end()

    def draw(self, qp):
        qp.setBrush(QColor(*[int(randint(0, 255)) for _ in range(3)]))
        qp.setPen(QColor(0, 0, 0))

        x, y = randint(20, ACTIVE_AREA[0] - 20), randint(20, ACTIVE_AREA[1] - 20)
        max_size = min([x, y, ACTIVE_AREA[0] - x, ACTIVE_AREA[1] - y])
        radius = randint(
            20, max_size if max_size <= ACTIVE_AREA[0] // 8 else ACTIVE_AREA[1] // 8)

        qp.drawEllipse(x - radius, y - radius, radius * 2, radius * 2)


def except_hook(cls, exception, traceback):
    sys.__excepthook__(cls, exception, traceback)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    form = MainForm()
    form.show()
    sys.excepthook = except_hook
    sys.exit(app.exec())
