问题描述
我有这个用pyqt编写的应用.您可以在 http://www.pasteall.org/62739/python 上查看源代码桌面的屏幕截图.我想知道的是如何使其也像窗口的截图工具一样对屏幕上的特定区域进行屏幕截图( http://sjcblogs.sanjac.edu/its/files/2011/09/Snipping-Tool-selection-types1.jpg 和gilsmethod.wpengine.netdna-cdn.com/images/snipping-tool-windows-73.png).我该怎么写?
I have this app written in pyqt. You can view the source at http://www.pasteall.org/62739/python It takes screen shots of the desktop. what I want to know is how to make it also take a screen shot of a certain area on the screen like window's snipping tool can do (http://sjcblogs.sanjac.edu/its/files/2011/09/Snipping-Tool-selection-types1.jpg and gilsmethod.wpengine.netdna-cdn.com/images/snipping-tool-windows-73.png). How do I write this?
提前谢谢!
推荐答案
您应该使用
img = QPixmap.grabWindow(QApplication.desktop().winId(), x, y, width, height)
pyqt发行版有一个很好的pyqt screeshoting python示例.该示例的C ++代码易于转换为Python,位于 http ://doc.qt.io/qt-4.8/qt-desktop-screenshot-example.html
The pyqt distro has a very good python example of screeshoting with pyqt. The C++ code of the example, easily converted to Python, is at http://doc.qt.io/qt-4.8/qt-desktop-screenshot-example.html
这篇关于Pyqt拍摄某些屏幕区域的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!