-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (33 loc) · 1.01 KB
/
main.py
File metadata and controls
42 lines (33 loc) · 1.01 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
import PyQt5
import random
from PyQt5 import uic
from PIL import Image, ImageDraw
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel
from PyQt5.QtGui import QPixmap
import os
class MyWidget(QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi('Ui.ui', self)
self.pushButton.clicked.connect(self.draw)
self.do_paint = False
def draw(self):
b = 240
new_image = Image.new("RGB", (200, 200), (b, b, b))
drawer = ImageDraw.Draw(new_image)
a = random.randrange(10, 100)
drawer.ellipse(((a, a), (200 - a, 200 - a)), 'yellow')
new_image.save('ball.png')
self.pixmap = QPixmap('ball.png')
self.image = QLabel(self)
self.image.move(100, 10)
self.image.resize(200, 200)
self.image.setPixmap(self.pixmap)
self.image.show()
os.remove('ball.png')
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MyWidget()
ex.show()
sys.exit(app.exec_())