feat(globalmenu) #43
@@ -38,9 +38,11 @@ Once compiled, you can easily load the library into any Python script using PyGO
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
gi.require_version("AppCapture", "1.0")
|
gi.require_version("AppCapture", "1.0")
|
||||||
from gi.repository import AppCapture
|
from gi.repository import AppCapture
|
||||||
|
|
||||||
|
|
||||||
def on_frame_ready(capture, address, data, width, height, stride):
|
def on_frame_ready(capture, address, data, width, height, stride):
|
||||||
# 'data' is a GLib.Bytes object containing the raw ARGB32 pixel data
|
# 'data' is a GLib.Bytes object containing the raw ARGB32 pixel data
|
||||||
# Convert it to a Cairo Surface or GdkPixbuf
|
# Convert it to a Cairo Surface or GdkPixbuf
|
||||||
@@ -49,9 +51,11 @@ def on_frame_ready(capture, address, data, width, height, stride):
|
|||||||
# Example: Request the next frame, but wait for damage (0% CPU idle)
|
# Example: Request the next frame, but wait for damage (0% CPU idle)
|
||||||
capture.capture_by_handle(address, 300, 168, True)
|
capture.capture_by_handle(address, 300, 168, True)
|
||||||
|
|
||||||
|
|
||||||
def on_frame_failed(capture, address, reason):
|
def on_frame_failed(capture, address, reason):
|
||||||
print(f"Failed to capture {address}: {reason}")
|
print(f"Failed to capture {address}: {reason}")
|
||||||
|
|
||||||
|
|
||||||
# 1. Initialize the capture module
|
# 1. Initialize the capture module
|
||||||
capture = AppCapture.Capture()
|
capture = AppCapture.Capture()
|
||||||
capture.connect("frame-ready", on_frame_ready)
|
capture.connect("frame-ready", on_frame_ready)
|
||||||
|
|||||||
Reference in new issue
Block a user