1 2 3 4 5 6 7 8 9 10 11 12 13 14
| def catch(self): x = QCursor.pos().x() y = QCursor.pos().y() pixmap = QGuiApplication.primaryScreen().grabWindow(QApplication.desktop().winId(), x, y, 1, 1) if not pixmap.isNull(): image = pixmap.toImage() if not image.isNull(): if (image.valid(0, 0)): color = QColor(image.pixel(0, 0)) r, g, b, _ = color.getRgb() self.nowColor = color self.ui.lineEditMove.setText('(%d, %d, %d) %s' % (r, g, b, color.name().upper())) self.ui.lineEditMove.setStyleSheet('QLineEdit{border:2px solid %s;}' % (color.name()))
|