问题
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