-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (31 loc) · 1.04 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys, random
from PyQt6 import uic
from PyQt6.QtCore import QSize, QRectF
from PyQt6.QtGui import QPainter, QPixmap, QColor
from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QPushButton, QLabel
class Main_widget(QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi('Circle.ui', self)
self.do_paint = False
self.buttonCircle.clicked.connect(self.paint)
self.sizes = QSize(self.buttonCircle.size().width(), self.buttonCircle.size().height() - 70)
def paintEvent(self, event):
if self.do_paint:
qp = QPainter()
qp.begin(self)
self.draw_flag(qp)
qp.end()
self.do_paint = False
def paint(self):
self.do_paint = True
self.update()
def draw_flag(self, qp):
r = random.randint(0, 100)
qp.setBrush(QColor(255, 255, 0))
qp.drawEllipse(150, 100, r, r)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Main_widget()
ex.show()
sys.exit(app.exec())