pyq5 interface design
self._color = QColor("#7F000000")
The color here has eight hexadecimal digits, and the last six digits are normal color codes, as shown in the figure below: the
first two digits are alpha transparency, and the transparency has a total of 256 levels (0~255), 255 means 100% opacity. 0% means 100% transparent
Take the first line of code as an example: first convert the hexadecimal 7F to decimal, that is, 127, 127/255 = 50%, which means 50% opaque.
If you want to get a black with 25% transparency, 25% * 255 = 63.75 is rounded to 64 and converted to hexadecimal, which is 40.
Corresponding form:
Percentile | Opacity |
---|---|
100% | FF |
95% | F2 |
90% | E6 |
85% | D9 |
80% | CC |
75% | BF |
70% | B3 |
65% | A6 |
60% | 99 |
55% | 8C |
50% | 80 |
45% | 73 |
40% | 66 |
35% | 59 |
30% | 4D |
25% | 40 |
20% | 33 |
15% | 26 |
10% | 1A |
5% | 0D |
0% | 00 |
Refer to ARGB transparency conversion