Куда копать?
#!/usr/bin/python import sys try: from PySide import QtCore, QtGui from PySide.QtGui import * from PySide.QtCore import * except ImportError: from PyQt4 import QtCore, QtGui from PyQt4.QtGui import * from PyQt4.QtCore import * class ColorWidget(QWidget): def __init__(self, parent): super(ColorWidget, self).__init__(parent) self.parent = parent self.setToolTip('Color') self.colorimage = QImage() self.maskimage = QImage() def paintEvent(self, event): w = self.width() h = self.height() qp = QPainter(self) pen = QtGui.QPen(QColor.fromRgbF(1,1,1,0), 1, Qt.SolidLine) qp.setPen(pen) qp.setBrush(QColor.fromRgbF(0.34,0.34,0.34,1)) qp.drawRect(0,0,w,h) qp.setBrush(QColor.fromRgbF(0.67,0.67,0.67,1)) step = int(w/10) wh = int(step/4) side = int(wh/2) for x in range(step): for y in range(step): qp.drawRect(x*wh,y*wh,side,side) qp.drawRect(x*wh+side,y*wh+side,side,side) self.colorimage=QImage(w,h,QImage.Format_ARGB32_Premultiplied) ip = QPainter() ip.begin(self.colorimage) ip.setBrush(QColor.fromRgbF(0,0,0,0)) ip.drawRect(0, 0, w, h) ip.setBrush(QColor.fromRgbF(0.67,0.67,0.67,1)) ip.drawRect(100, 100, w, h) ip.end() pix = QPixmap() pix.convertFromImage(self.colorimage) qp.drawPixmap(QtCore.QPoint(0, 0), pix) class EditorWindow(QMainWindow): def __init__(self): super(EditorWindow, self).__init__() centralWidget = QWidget() layout = QVBoxLayout() widget = ColorWidget(self) layout.addWidget(widget) centralWidget.setLayout(layout) self.setCentralWidget(centralWidget) self.pixmap = QPixmap() self.setGeometry(300, 300, 600, 400) self.setWindowTitle('Colors') self.show() def main(): app = QApplication(sys.argv) ex = EditorWindow() sys.exit(app.exec_()) if __name__ == '__main__': main()