Pyqt拍摄某些屏幕区域的屏幕截图 [英] Pyqt take screenshot of certain screen area

查看:365
本文介绍了Pyqt拍摄某些屏幕区域的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个用pyqt编写的应用.您可以在 http://www.pasteall.org/62739/python 上查看源代码桌面的屏幕截图.我想知道的是如何使其也像窗口的截图工具一样对屏幕上的特定区域进行屏幕截图(

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拍摄某些屏幕区域的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆