A simple use to capture a screenshot of single window in linux Systems
Project description
XWindowSystem_Screenshoter
A simple use and little size python library to get screenshot of a single window on linux!
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
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
window_sync = WindowCaptureSync("firefox")
screenshot = window_sync.get_screenshot()
async
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
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
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)
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
Built Distribution
Close
Hashes for XWindowSystem_Screenshoter-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fdcf6fa897a0de6614dc08bf0acad48ea3c5b1cc0742a34cc3a9d9a5e1f0db7 |
|
MD5 | a66fd567e18513e337e391e6490660da |
|
BLAKE2b-256 | 97503578aa93fde47bc555b64c15721ae1f38607452409b3600000a36bd50c7b |
Close
Hashes for XWindowSystem_Screenshoter-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7759ca73b6a4d881473259953a62101e280d0a57abd4885ce3a454d9e1e12f9a |
|
MD5 | bfa523ac8fbada5444b762c2a252df07 |
|
BLAKE2b-256 | 11d778c2bb59233dc265866568e509ea48ca1c666d507b75a2c54b2b231c2075 |