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