-
Notifications
You must be signed in to change notification settings - Fork 0
/
slideColor.py
103 lines (64 loc) · 2.19 KB
/
slideColor.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import sys
from PyQt5.QtWidgets import QApplication , QWidget , QFrame, QSlider
from PyQt5.QtGui import QColor
from PyQt5.QtCore import Qt
import random
class F(QWidget):
def __init__(self):
super().__init__()
self.setUI()
def setUI(self):
self.setGeometry(500,400,500,600)
self.setWindowTitle("Table")
self.Qf = QFrame(self)
self.Qf.setGeometry(100 , 10 , 300 , 300)
self.Qs = QSlider(Qt.Horizontal , self)
self.Qs.setGeometry(100 , 520 , 300 ,15)
self.pa = self.Qf.palette()
role = self.Qf.backgroundRole()
self.pa.setColor(role,QColor( 255 , 255 , 255))
self.Qf.setPalette(self.pa)
self.Qf.setAutoFillBackground(True)
self.Qs.valueChanged.connect(self.paint)
self.show()
def paint(self):
R = []
G = []
B = []
for i in range(0 , 100):
R.append(random.randrange(0, 256))
G.append(random.randrange(0, 256))
B.append(random.randrange(0, 256))
rang = []
jam = []
slideval= self.Qs.value()
for b in range(0 , 100):
rang=[R[b] , G[b] , B[b]]
jam.append(rang)
print(jam)
self.palette = self.Qf.palette()
r = self.Qf.backgroundRole()
if slideval == 0 :
self.x= 255
self.y= 255
self.z= 250
self.palette.setColor(r , QColor(self.x , self.y, self.z))
self.Qf.setPalette(self.palette)
self.Qf.setAutoFillBackground(True)
elif slideval== 99:
self.x = 0
self.y= 0
self.z=0
self.palette.setColor(r , QColor(self.x,self.y,self.z))
self.Qf.setPalette(self.palette)
self.Qf.setAutoFillBackground(True)
else :
self.x,self.y,self.z=jam[slideval]
self.palette.setColor(r , QColor(self.x,self.y,self.z))
self.Qf.setPalette(self.palette)
self.Qf.setAutoFillBackground(True)
if __name__== "__main__":
print(__name__)
app = QApplication(sys.argv)
ex=F()
sys.exit(app.exec_())