我过去 3 天在 google 上搜索,如何使用 PyGTK+3 创建屏幕截图?
有关于 pyqt、pygtk+2、wx 和 PIL 的 gallizion 教程。
顺便说一句,我不需要 scrot、imlib2、imagemagick 等外部程序。
由于没有其他人发布 GTK3 的翻译,所以您可以:
from gi.repository import Gdk
win = Gdk.get_default_root_window()
h = win.get_height()
w = win.get_width()
print ("The size of the window is %d x %d" % (w, h))
pb = Gdk.pixbuf_get_from_window(win, 0, 0, w, h)
if (pb != None):
pb.savev("screenshot.png","png", (), ())
print("Screenshot saved to screenshot.png.")
else:
print("Unable to get the screenshot.")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)