Selecting area of the screen with Python

余生颓废 提交于 2021-02-08 04:14:41

问题


I'm developing a screen shot utility in Python. At the moment it is specifically for Linux. So far I have the ability to take a screen shot of the full desktop, and have it upload to Imgur, then copy the link to clipboard. Now I want to expand into functions such as screen shots of the active window, or of a specific selection. If anyone could help, I'd love to know what kind of module would work best for this, and how to implement such a module.


回答1:


The functionality will depend on what you are using for image grabbing.

With PIL

  • http://effbot.org/imagingbook/imagegrab.htm

With GTK

To take a screenshot of active window :

  • http://faq.pygtk.org/index.py?req=show&file=faq23.039.htp

Also look at the pixbuf api

  • http://library.gnome.org/devel/gdk-pixbuf/
  • http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html

Off topic

There are some screen cast tools: http://pypi.python.org/pypi/castro/1.0.4



来源:https://stackoverflow.com/questions/3895732/selecting-area-of-the-screen-with-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!