- 最近遇到几次取屏幕某处颜色的场景, 用ps去取色又觉得有点麻烦(步骤太多我懒), 索性自己做一个简单的拾色器
- 功能极简单就是取屏幕某处的色号, 按下空格把颜色记录下来...
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()))