Skip to content

Commit

Permalink
Version 7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BoboTiG committed Oct 27, 2022
1 parent b05ca23 commit be3fb7b
Show file tree
Hide file tree
Showing 44 changed files with 352 additions and 404 deletions.
21 changes: 15 additions & 6 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ History:

<see Git checking messages for history>

7.0.0 2022/10/27
- added support for Python 3.11
- added support for Python 3.10
- removed support for Python 3.5
- MSS: modernized the code base (types, f-string, ran isort & black)
- MSS: fixed several Sourcery issues
- MSS: fixed typos here, and there
- doc: fixed an error when building with shpinx

6.1.0 2020/10/31
- MSS: reworked how C functions are initialised
- Mac: reduce the number of function calls
Expand Down Expand Up @@ -119,14 +128,14 @@ History:
3.0.0 2017/07/06
- big refactor, introducing the ScreenShot class
- MSS: add Numpy array interface support to the Screenshot class
- docs: add OpenCV/Numpy, PIL pixels, FPS
- doc: add OpenCV/Numpy, PIL pixels, FPS

2.0.22 2017/04/29
- new contributors: David Becker, redodo
- MSS: better use of exception mechanism
- Linux: use of hasattr to prevent Exception on early exit
- Mac: take into account extra black pixels added when screen with is not divisible by 16 (fix #14)
- docs: add an example to capture only a part of the screen
- doc: add an example to capture only a part of the screen

2.0.18 2016/12/03
- change license to MIT
Expand All @@ -138,7 +147,7 @@ History:
- Linux: skip unused monitors
- Linux: use errcheck instead of deprecated restype with callable (fix #11)
- Linux: fix security issue (reported by Bandit)
- docs: add documentation (fix #10)
- doc: add documentation (fix #10)
- tests: add tests and use Travis CI (fix #9)

2.0.0 2016/06/04
Expand Down Expand Up @@ -175,14 +184,14 @@ History:
- MSS: little code review
- Linux: fix monitor count
- tests: remove test-linux binary
- docs: add doc/TESTING
- docs: remove Bonus section from README.rst
- doc: add doc/TESTING
- doc: remove Bonus section from README.rst

0.1.0 2015/04/10
- MSS: fix code with YAPF tool
- Linux: fully functional using Xrandr library
- Linux: code purgation (no more XML files to parse)
- docs: better tests and examples
- doc: better tests and examples

0.0.8 2015/02/04
- new contributors: sergey-vin, Alexander 'thehesiod' Mohr
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MIT License
Copyright (c) 2016-2020, Mickaël 'Tiger-222' Schoentgen
Copyright (c) 2016-2022, Mickaël 'Tiger-222' Schoentgen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
7 changes: 1 addition & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ platform:
environment:
fast_finish: true
matrix:
- PYTHON_VERSION: 3.11
- PYTHON_VERSION: 3.10
- PYTHON_VERSION: 3.9
- PYTHON_VERSION: 3.8
- PYTHON_VERSION: 3.7
- PYTHON_VERSION: 3.6
- PYTHON_VERSION: 3.5

matrix:
allow_failures:
- PYTHON_VERSION: 3.10
- PYTHON_VERSION: 3.9

init:
# Update Environment Variables based on matrix/platform
Expand Down
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

# General information about the project.
project = "Python MSS"
copyright = "2013-2021, Mickaël 'Tiger-222' Schoentgen & contributors"
copyright = "2013-2022, Mickaël 'Tiger-222' Schoentgen & contributors"
author = "Tiger-222"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "6.1.0"
version = "7.0.0"

# The full version, including alpha/beta/rc tags.
release = "latest"
Expand All @@ -37,7 +37,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
8 changes: 3 additions & 5 deletions docs/source/examples/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@
Screenshot of the monitor 1, with callback.
"""

import os
import os.path

import mss


def on_exists(fname):
# type: (str) -> None
def on_exists(fname: str) -> None:
"""
Callback example when we try to overwrite an existing screenshot.
"""

if os.path.isfile(fname):
newfile = fname + ".old"
print("{} -> {}".format(fname, newfile))
newfile = f"{fname}.old"
print(f"{fname} -> {newfile}")
os.rename(fname, newfile)


Expand Down
9 changes: 6 additions & 3 deletions docs/source/examples/custom_cls_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,26 @@
Screenshot of the monitor 1, using a custom class to handle the data.
"""
from typing import Any

import mss
from mss.models import Monitor
from mss.screenshot import ScreenShot


class SimpleScreenShot:
class SimpleScreenShot(ScreenShot):
"""
Define your own custom method to deal with screen shot raw data.
Of course, you can inherit from the ScreenShot class and change
or add new methods.
"""

def __init__(self, data, monitor, **kwargs):
def __init__(self, data: bytearray, monitor: Monitor, **_: Any) -> None:
self.data = data
self.monitor = monitor


with mss.mss() as sct:
sct.cls_image = SimpleScreenShot # type: ignore
sct.cls_image = SimpleScreenShot
image = sct.grab(sct.monitors[1])
# ...
8 changes: 4 additions & 4 deletions docs/source/examples/fps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
Simple naive benchmark to compare with:
https://pythonprogramming.net/game-frames-open-cv-python-plays-gta-v/
"""

import time

import cv2
import mss
import numpy

import mss


def screen_record():
def screen_record() -> int:
try:
from PIL import ImageGrab
except ImportError:
Expand All @@ -38,7 +38,7 @@ def screen_record():
return fps


def screen_record_efficient():
def screen_record_efficient() -> int:
# 800x600 windowed mode
mon = {"top": 40, "left": 0, "width": 800, "height": 640}

Expand Down
11 changes: 3 additions & 8 deletions docs/source/examples/fps_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
Example using the multiprocessing module to speed-up screen capture.
https://github.com/pythonlessons/TensorFlow-object-detection-tutorial
"""

from multiprocessing import Process, Queue

import mss
import mss.tools


def grab(queue):
# type: (Queue) -> None

def grab(queue: Queue) -> None:
rect = {"top": 0, "left": 0, "width": 600, "height": 800}

with mss.mss() as sct:
Expand All @@ -25,9 +22,7 @@ def grab(queue):
queue.put(None)


def save(queue):
# type: (Queue) -> None

def save(queue: Queue) -> None:
number = 0
output = "screenshots/file_{}.png"
to_png = mss.tools.to_png
Expand All @@ -43,7 +38,7 @@ def save(queue):

if __name__ == "__main__":
# The screenshots queue
queue = Queue() # type: Queue
queue: Queue = Queue()

# 2 processes: one for grabing and one for saving PNG files
Process(target=grab, args=(queue,)).start()
Expand Down
4 changes: 1 addition & 3 deletions docs/source/examples/from_pil_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
Use PIL bbox style and percent values.
"""

import mss
import mss.tools


with mss.mss() as sct:
# Use the 1st monitor
monitor = sct.monitors[1]
Expand All @@ -23,7 +21,7 @@
# Grab the picture
# Using PIL would be something like:
# im = ImageGrab(bbox=bbox)
im = sct.grab(bbox) # type: ignore
im = sct.grab(bbox)

# Save it!
mss.tools.to_png(im.rgb, im.size, output="screenshot.png")
2 changes: 0 additions & 2 deletions docs/source/examples/linux_display_keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
Usage example with a specific display.
"""

import mss


with mss.mss(display=":0.0") as sct:
for filename in sct.save():
print(filename)
5 changes: 2 additions & 3 deletions docs/source/examples/opencv_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
OpenCV/Numpy example.
"""

import time

import cv2
import mss
import numpy

import mss

with mss.mss() as sct:
# Part of the screen to capture
Expand All @@ -29,7 +28,7 @@
# cv2.imshow('OpenCV/Numpy grayscale',
# cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY))

print("fps: {}".format(1 / (time.time() - last_time)))
print(f"fps: {1 / (time.time() - last_time)}")

# Press "q" to quit
if cv2.waitKey(25) & 0xFF == ord("q"):
Expand Down
2 changes: 0 additions & 2 deletions docs/source/examples/part_of_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
Example to capture part of the screen.
"""

import mss
import mss.tools


with mss.mss() as sct:
# The screen part to capture
monitor = {"top": 160, "left": 160, "width": 160, "height": 135}
Expand Down
2 changes: 0 additions & 2 deletions docs/source/examples/part_of_screen_monitor_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
Example to capture part of the screen of the monitor 2.
"""

import mss
import mss.tools


with mss.mss() as sct:
# Get information of monitor 2
monitor_number = 2
Expand Down
5 changes: 2 additions & 3 deletions docs/source/examples/pil.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
PIL example using frombytes().
"""

import mss
from PIL import Image

import mss

with mss.mss() as sct:
# Get rid of the first, as it represents the "All in One" monitor:
Expand All @@ -21,6 +20,6 @@
# img = Image.frombytes('RGB', sct_img.size, sct_img.rgb)

# And save it!
output = "monitor-{}.png".format(num)
output = f"monitor-{num}.png"
img.save(output)
print(output)
5 changes: 2 additions & 3 deletions docs/source/examples/pil_pixels.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
PIL examples to play with pixels.
"""

import mss
from PIL import Image

import mss

with mss.mss() as sct:
# Get a screenshot of the 1st monitor
Expand All @@ -17,7 +16,7 @@
img = Image.new("RGB", sct_img.size)

# Best solution: create a list(tuple(R, G, B), ...) for putdata()
pixels = zip(sct_img.raw[2::4], sct_img.raw[1::4], sct_img.raw[0::4])
pixels = zip(sct_img.raw[2::4], sct_img.raw[1::4], sct_img.raw[::4])
img.putdata(list(pixels))

# But you can set individual pixels too (slower)
Expand Down
3 changes: 2 additions & 1 deletion docs/source/support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Support
Feel free to try MSS on a system we had not tested, and let us know by creating an `issue <https://github.com/BoboTiG/python-mss/issues>`_.

- OS: GNU/Linux, macOS and Windows
- Python: 3.5 and newer
- Python: 3.6 and newer


Future
Expand All @@ -31,3 +31,4 @@ Abandoned
- Python 3.2 (2016-10-08)
- Python 3.3 (2017-12-05)
- Python 3.4 (2018-03-19)
- Python 3.5 (2022-10-27)
17 changes: 8 additions & 9 deletions mss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@
https://github.com/BoboTiG/python-mss
If that URL should fail, try contacting the author.
"""

from .exception import ScreenShotError
from .factory import mss

__version__ = "6.1.0"
__version__ = "7.0.0"
__author__ = "Mickaël 'Tiger-222' Schoentgen"
__copyright__ = """
Copyright (c) 2013-2020, Mickaël 'Tiger-222' Schoentgen
Copyright (c) 2013-2022, Mickaël 'Tiger-222' Schoentgen
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee or royalty is hereby
granted, provided that the above copyright notice appear in all copies
and that both that copyright notice and this permission notice appear
in supporting documentation or portions thereof, including
modifications, that you make.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee or royalty is hereby
granted, provided that the above copyright notice appear in all copies
and that both that copyright notice and this permission notice appear
in supporting documentation or portions thereof, including
modifications, that you make.
"""
__all__ = ("ScreenShotError", "mss")
Loading

0 comments on commit be3fb7b

Please sign in to comment.