Skip to main content

A screen capture utility that works with PyQt6, PySide6, PyQt5, PySide2, PyQt4, and PySide.

Project description

PyQt Screen Capture

A screen capture utility that works with PyQt6, PySide6, PyQt5, PySide2, and PySide.

Features

  • Cross-platform (Windows, Linux, macOS, etc.)
  • Supports Python 2+
  • Automatically detects available Qt bindings
  • Memory-efficient screen capture using shared ndarrays in OpenCV-compatible HWC BGRX 8888 format
  • Simple generator-based interface

Installation

Make sure you have PyQt6, PySide6, PyQt5, PySide2, or PySide installed.

Then install pyqt-screen-capture:

pip install pyqt-screen-capture

Usage

Capture single frame

from pyqt_screen_capture import hwc_bgrx_8888_screen_capturer

screen_capturer = hwc_bgrx_8888_screen_capturer()

# Get next screen frame (as numpy array in HWC BGRX 8888 format)
frame = next(screen_capturer)

# Example: Convert to RGB and display with matplotlib
import matplotlib.pyplot as plt

plt.imshow(frame[:, :, [2, 1, 0]])  # Convert BGR to RGB
plt.show()

Continuous capture

import cv2

from pyqt_screen_capture import hwc_bgrx_8888_screen_capturer

for frame in hwc_bgrx_8888_screen_capturer():
    # Process frame (OpenCV, etc.)
    cv2.imshow('Screen Capture', frame[:, :, :3])  # Use BGR channels only
    key = cv2.waitKey()
    if key & 0xFF == ord('q'):
        break

Caveat

You MUST use the shared ndarray between yields, as the underlying buffer is freed afterward:

from pyqt_screen_capture import hwc_bgrx_8888_screen_capturer
screen_capturer = hwc_bgrx_8888_screen_capturer()
r1 = next(screen_capturer)
# OK to use r1 here
r2 = next(screen_capturer)
# OK to use r2 here, DO NOT USE r1 HERE!

Acknowledgments

This project modifies code automatically determining which Qt package to use from pyqtgraph, available under the MIT License

Contributing

Contributions are welcome! Please submit pull requests or open issues on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqt_screen_capture-0.1.0a1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyqt_screen_capture-0.1.0a1-py2.py3-none-any.whl (4.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyqt_screen_capture-0.1.0a1.tar.gz.

File metadata

  • Download URL: pyqt_screen_capture-0.1.0a1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for pyqt_screen_capture-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 96c68ab888088326bf285e8605925ed32c7cd9899a7c4dc9a02e815434d29ea3
MD5 6c556c169244f5a738d608c797d09c1c
BLAKE2b-256 45a39d561f322aee2db893b0e94c49f5f0d0d6a7b11ea5ce340da40cadf0a7c9

See more details on using hashes here.

File details

Details for the file pyqt_screen_capture-0.1.0a1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pyqt_screen_capture-0.1.0a1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0c6c3287fac69c14e68420dc2d93f4d3187b311bff07fd978a68616a65fa0e97
MD5 0dad89070ecb0d986ff44fccc4bea9e2
BLAKE2b-256 3931469309f34a031b5852db58a2b106b1da0686e7ace93e8e939ec0f29a9606

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page