python怎么获取鼠标附近的像素wxpython
1个回答
展开全部
wxpython没用过,不清楚,不过PyQt4用过。
"""
鼠标移动需要把鼠标的XY值读取
"""
if event.buttons() & Qt.LeftButton:
pointX = event.globalX()
pointY = event.globalY()
# img is QImage type
img = QPixmap.grabWindow(
QApplication.desktop().winId()).toImage()
rgb = img.pixel(pointX, pointY)
#十进制
red10 = QtGui.qRed(rgb)
green10 =QtGui.qGreen(rgb)
blue10 = QtGui.qBlue(rgb)
color10="("+str(red10)+","+str(green10)+","+str(blue10)+")"
#十六进制
#print str(hex(red10))
red16=str(hex(red10))[2:]
green16=str(hex(green10))[2]
blue16=str(hex(blue10))[2:]
color16=red16+green16+blue16
#print color16
print "(%s,%s) = %s (%s,%s,%s)" % (pointX, pointY, color16,red10, green10, blue10)
"""
鼠标移动需要把鼠标的XY值读取
"""
if event.buttons() & Qt.LeftButton:
pointX = event.globalX()
pointY = event.globalY()
# img is QImage type
img = QPixmap.grabWindow(
QApplication.desktop().winId()).toImage()
rgb = img.pixel(pointX, pointY)
#十进制
red10 = QtGui.qRed(rgb)
green10 =QtGui.qGreen(rgb)
blue10 = QtGui.qBlue(rgb)
color10="("+str(red10)+","+str(green10)+","+str(blue10)+")"
#十六进制
#print str(hex(red10))
red16=str(hex(red10))[2:]
green16=str(hex(green10))[2]
blue16=str(hex(blue10))[2:]
color16=red16+green16+blue16
#print color16
print "(%s,%s) = %s (%s,%s,%s)" % (pointX, pointY, color16,red10, green10, blue10)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询