A screenshot module writen in python with pyQt5.
It supports:
Flag | Description |
---|---|
pyqt_screenshot.constant.RECT |
tool for drawing rectangle |
pyqt_screenshot.constant.ELLIPSE |
tool for drawing ellipse |
pyqt_screenshot.constant.LINE |
tool for drawing line |
pyqt_screenshot.constant.FREEPEN |
tool for drawing freely |
pyqt_screenshot.constant.TEXT |
tool for adding text |
pyqt_screenshot.constant.ARROW |
tool for drawing arrow |
pyqt_screenshot.constant.CLIPBOARD |
tool for saving to clipboard |
pyqt_screenshot.constant.SAVE_TO_FILE |
tool for saving to file |
You can take some simple changes after taking a screenshot without opening an image editor.
Save image as png or jpg file, or cpoy to clipboard
from pyqt_screenshot.screenshot import Screenshot, constant
img = Screenshot.take_screenshot(constant.CLIPBOARD) # QImage or None
None will be returned if canceled.
import sys
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication, QLabel
from pyqt_screenshot.screenshot import Screenshot, constant
if __name__ == "__main__":
qtApp = QApplication(sys.argv)
main_window = QLabel()
img = Screenshot.take_screenshot(constant.CLIPBOARD | constant.LINE)
main_window.show()
if img is not None:
main_window.setPixmap(QPixmap(img))
qtApp.exec()
Before starting, you should make sure you have python and pyqt5 installed.
- git clone https://github.com/SeptemberHX/screenshot.git
- cd ./screenshot
- python ./main.py
Can't save screenshot to clipboard on Linux because the clipboard on Linux only stores the reference to the picture object, which means the clipboard can't hold the screenshot after closing the screenshot.