-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcolorbutton.py
More file actions
31 lines (26 loc) · 862 Bytes
/
colorbutton.py
File metadata and controls
31 lines (26 loc) · 862 Bytes
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
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QIcon, QColor
from PyQt5.QtWidgets import QToolButton
########################################
#
########################################
class ColorButton(QToolButton):
########################################
#
########################################
def __init__(self, parent=None):
super().__init__(parent)
self.setColor(QColor(Qt.black))
########################################
#
########################################
def color(self):
return self._color
########################################
#
########################################
def setColor(self, color):
self._color = color
pm = QPixmap(16, 16)
pm.fill(self._color)
self.setIcon(QIcon(pm))