Metadata-Version: 2.1
Name: XWindowSystem_Screenshoter
Version: 0.0.4
Summary: A simple use to capture a screenshot of single window in linux Systems
Author: Matheus Verginio Fernandes
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

# XWindowSystem_Screenshoter
<h3>A simple use and little size python library to get screenshot of a single window on linux!</h3>

# How use
There are two ways to use it, in synchronous and asynchronous mode (in reference to the screenshot) But the statement is very similar.

## Declaration

### sync
```python
window_sync = WindowCaptureSync("firefox")
```

### async
```
window_async = WindowCaptureAsync("firefox")
```

The biggest difference is that in synchronous mode you must call a function to take the screenshot, whereas in asynchronous mode, a capture function is run in a loop and you will only need to call a property that will contain the most recently captured screenshot

## To get Screenshot

### sync
```python
window_sync = WindowCaptureSync("firefox")
screenshot = window_sync.get_screenshot()
```

### async
```python
window_async = WindowCaptureAsync("firefox")
window_async.start() # Start thread to screenshot loop
...
screenshot = window_async.screenshot
...
window_async.stop() # Stop thread when not used anymore
```

## Examples

### sync
```python
import cv2 as cv
from XWindowSystem_Screenshoter import WindowCaptureSync

wincap = WindowCaptureSync("firefox")

# first capture 
image = wincap.get_screenshot()
image = cv.resize(image, (0,0), fx=0.6, fy=0.6)
cv.imshow("Test", image)

while True:
    # press c to update image    
    if cv.waitKey(1) == ord('c'):
        image = wincap.get_screenshot()
        image = cv.resize(image, (0,0), fx=0.6, fy=0.6)
        cv.imshow("Test", image)

    
    if cv.waitKey(1) == ord('q'):
        cv.destroyAllWindows()
        break

```

### async
```python
import cv2 as cv
from XWindowSystem_Screenshoter import WindowCaptureAsync

wincap = WindowCaptureAsync("firefox")
wincap.start()

while True:
    if wincap.screenshot is not None:
        image = wincap.screenshot
        image = cv.resize(image, (0,0), fx=0.6, fy=0.6)

        cv.imshow("Test", image)
        
        if cv.waitKey(1) == ord('q'):
            cv.destroyAllWindows()
            break
wincap.stop() # don't forget to stop thread!
exit(0)

```
