python图形模块_使用Python图形模块:有没有办法将当前窗口保存为图像?
我正在使用pythongraphics模塊。我要做的是將當(dāng)前窗口保存為圖像。在模塊中,有一個選項可以將“圖像”另存為圖像(圖像.保存()). 但這并沒有幫助,因為它只是保存一個已經(jīng)加載的圖像。或者,如果你像我一樣加載一個空白圖像,希望在上面畫畫可以改變這一點,驚喜,驚喜:你得到了一個空白圖像保存。這是我的代碼:from graphics import *
w = 300
h = 300
anchorpoint=Point(150,150)
height=300
width=300
image=Image(anchorpoint, height, width) #creates a blank image in the background
win = GraphWin("Red Circle", w, h)
# circle needs center x, y coordinates and radius
center = Point(150, 150)
radius = 80
circle = Circle(center, radius)
circle.setFill('red')
circle.setWidth(2)
circle.draw(win)
point= circle.getCenter()
print point
pointx= point.getX()
pointy= point.getY()
print pointx
print pointy
findPixel=image.getPixel(150,150)
print findPixel
image.save("blank.gif")
# wait, click mouse to go on/exit
win.getMouse()
win.close()
#######that's it#####
所以我的問題又來了:如何將屏幕上的內(nèi)容保存為“空白.gif"
謝謝!在
總結(jié)
以上是生活随笔為你收集整理的python图形模块_使用Python图形模块:有没有办法将当前窗口保存为图像?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 什么是顺周期板块?顺周期板块值得投资吗?
- 下一篇: python可以开发驱动吗_Python