1 from PyQt4 import QtGui, QtCore
2 from PyQt4.QtCore import Qt
3
4 from customeditor import CustomEditor
5
7
8 - def __init__(self, parent=None, editable=True, **kwargs):
9 CustomEditor.__init__(self, parent)
10 layout = QtGui.QVBoxLayout(self)
11 layout.setSpacing(0)
12 layout.setMargin(0)
13 self.color_button = QtGui.QPushButton(parent)
14 self.color_button.setMaximumSize(QtCore.QSize(20, 20))
15 layout.addWidget(self.color_button)
16 if editable:
17 self.connect(self.color_button,
18 QtCore.SIGNAL('clicked(bool)'),
19 self.buttonClicked)
20 self.setLayout(layout)
21 self._color = None
22
30
39
42
44 self.color_button.setEnabled(editable)
45
47 pixmap = QtGui.QPixmap(16, 16)
48 if color:
49 pixmap.fill(color)
50 else:
51 pixmap.fill(Qt.transparent)
52 self.color_button.setIcon(QtGui.QIcon(pixmap))
53 self._color = color
54
63