在Python3.x中获取屏幕上像素的颜色

时间:2012-02-03 15:18:56

标签: colors get python-3.x screen

我想在Python3.x中获得屏幕上的像素颜色。 (例如x,y) 我在窗户上工作。并使用tkinter。 但是,它不能在Python 3.x中使用PIL。

我该怎么办? 谢谢。

1 个答案:

答案 0 :(得分:0)

您可以在Python3.x上使用PIL;有一个binary installer for Windows。代码可能无法在Python2.x和Python3.x上运行:

try: import Image         # Python 2.x
except ImportError:
    from PIL import Image # Python 3.x

您可以使用grab() method类似物捕获屏幕区域。