-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (38 loc) · 1.1 KB
/
main.py
File metadata and controls
47 lines (38 loc) · 1.1 KB
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
43
44
45
46
47
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtGui import QPainter, QColor
from PyQt5 import uic
import sys
import random
class YellowCircles(QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi('UI.ui', self)
self.Init()
def Init(self):
self.setGeometry(821, 400, 621, 621)
self.setFixedSize(533, 493)
self.do_paint = False
self.setWindowTitle('Yellow Circles')
self.pushButton.clicked.connect(self.circle)
def paintEvent(self, event):
if self.do_paint:
qp = QPainter()
qp.begin(self)
self.run(qp)
qp.end()
self.do_paint = False
def circle(self):
self.do_paint = True
self.update()
def run(self, qp):
x = random.randint(10, 500)
y = random.randint(10, 300)
w = random.randint(10, 100)
h = w
qp.setBrush(QColor(255, 255, 0))
qp.drawEllipse(x, y, w, h)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = YellowCircles()
ex.show()
sys.exit(app.exec_())