-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
38 lines (30 loc) · 902 Bytes
/
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
import sys
import sqlite3
import random
from PyQt5.QtGui import QPainter, QColor
from PyQt5 import uic
from PyQt5.QtWidgets import QApplication, QMainWindow
class MyWidget(QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi('UI.ui', self)
self.do_paint = False
self.pushButton.clicked.connect(self.paint)
def paintEvent(self, event):
if self.do_paint:
qp = QPainter()
qp.begin(self)
self.draw_flag(qp)
qp.end()
def paint(self):
self.do_paint = True
self.repaint()
def draw_flag(self, qp):
a = random.randint(5, 500)
qp.setBrush(QColor(255, 255, 0))
qp.drawEllipse(random.randint(0, 700), random.randint(0, 500), a, a)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MyWidget()
ex.show()
sys.exit(app.exec_())