Skip to content

Commit be3fb7b

Browse files
committed
Version 7.0.0
1 parent b05ca23 commit be3fb7b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+352
-404
lines changed

CHANGELOG

+15-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ History:
22

33
<see Git checking messages for history>
44

5+
7.0.0 2022/10/27
6+
- added support for Python 3.11
7+
- added support for Python 3.10
8+
- removed support for Python 3.5
9+
- MSS: modernized the code base (types, f-string, ran isort & black)
10+
- MSS: fixed several Sourcery issues
11+
- MSS: fixed typos here, and there
12+
- doc: fixed an error when building with shpinx
13+
514
6.1.0 2020/10/31
615
- MSS: reworked how C functions are initialised
716
- Mac: reduce the number of function calls
@@ -119,14 +128,14 @@ History:
119128
3.0.0 2017/07/06
120129
- big refactor, introducing the ScreenShot class
121130
- MSS: add Numpy array interface support to the Screenshot class
122-
- docs: add OpenCV/Numpy, PIL pixels, FPS
131+
- doc: add OpenCV/Numpy, PIL pixels, FPS
123132

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

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

144153
2.0.0 2016/06/04
@@ -175,14 +184,14 @@ History:
175184
- MSS: little code review
176185
- Linux: fix monitor count
177186
- tests: remove test-linux binary
178-
- docs: add doc/TESTING
179-
- docs: remove Bonus section from README.rst
187+
- doc: add doc/TESTING
188+
- doc: remove Bonus section from README.rst
180189

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

187196
0.0.8 2015/02/04
188197
- new contributors: sergey-vin, Alexander 'thehesiod' Mohr

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MIT License
2-
Copyright (c) 2016-2020, Mickaël 'Tiger-222' Schoentgen
2+
Copyright (c) 2016-2022, Mickaël 'Tiger-222' Schoentgen
33

44
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:
55

appveyor.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@ platform:
1010
environment:
1111
fast_finish: true
1212
matrix:
13+
- PYTHON_VERSION: 3.11
1314
- PYTHON_VERSION: 3.10
1415
- PYTHON_VERSION: 3.9
1516
- PYTHON_VERSION: 3.8
1617
- PYTHON_VERSION: 3.7
1718
- PYTHON_VERSION: 3.6
18-
- PYTHON_VERSION: 3.5
19-
20-
matrix:
21-
allow_failures:
22-
- PYTHON_VERSION: 3.10
23-
- PYTHON_VERSION: 3.9
2419

2520
init:
2621
# Update Environment Variables based on matrix/platform

docs/source/conf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919

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

2525
# The version info for the project you're documenting, acts as replacement for
2626
# |version| and |release|, also used in various other places throughout the
2727
# built documents.
2828
#
2929
# The short X.Y version.
30-
version = "6.1.0"
30+
version = "7.0.0"
3131

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

4242
# List of patterns, relative to source directory, that match files and
4343
# directories to ignore when looking for source files.

docs/source/examples/callback.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,20 @@
44
55
Screenshot of the monitor 1, with callback.
66
"""
7-
87
import os
98
import os.path
109

1110
import mss
1211

1312

14-
def on_exists(fname):
15-
# type: (str) -> None
13+
def on_exists(fname: str) -> None:
1614
"""
1715
Callback example when we try to overwrite an existing screenshot.
1816
"""
1917

2018
if os.path.isfile(fname):
21-
newfile = fname + ".old"
22-
print("{} -> {}".format(fname, newfile))
19+
newfile = f"{fname}.old"
20+
print(f"{fname} -> {newfile}")
2321
os.rename(fname, newfile)
2422

2523

docs/source/examples/custom_cls_image.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,26 @@
44
55
Screenshot of the monitor 1, using a custom class to handle the data.
66
"""
7+
from typing import Any
78

89
import mss
10+
from mss.models import Monitor
11+
from mss.screenshot import ScreenShot
912

1013

11-
class SimpleScreenShot:
14+
class SimpleScreenShot(ScreenShot):
1215
"""
1316
Define your own custom method to deal with screen shot raw data.
1417
Of course, you can inherit from the ScreenShot class and change
1518
or add new methods.
1619
"""
1720

18-
def __init__(self, data, monitor, **kwargs):
21+
def __init__(self, data: bytearray, monitor: Monitor, **_: Any) -> None:
1922
self.data = data
2023
self.monitor = monitor
2124

2225

2326
with mss.mss() as sct:
24-
sct.cls_image = SimpleScreenShot # type: ignore
27+
sct.cls_image = SimpleScreenShot
2528
image = sct.grab(sct.monitors[1])
2629
# ...

docs/source/examples/fps.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
Simple naive benchmark to compare with:
66
https://pythonprogramming.net/game-frames-open-cv-python-plays-gta-v/
77
"""
8-
98
import time
109

1110
import cv2
12-
import mss
1311
import numpy
1412

13+
import mss
14+
1515

16-
def screen_record():
16+
def screen_record() -> int:
1717
try:
1818
from PIL import ImageGrab
1919
except ImportError:
@@ -38,7 +38,7 @@ def screen_record():
3838
return fps
3939

4040

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

docs/source/examples/fps_multiprocessing.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@
55
Example using the multiprocessing module to speed-up screen capture.
66
https://github.com/pythonlessons/TensorFlow-object-detection-tutorial
77
"""
8-
98
from multiprocessing import Process, Queue
109

1110
import mss
1211
import mss.tools
1312

1413

15-
def grab(queue):
16-
# type: (Queue) -> None
17-
14+
def grab(queue: Queue) -> None:
1815
rect = {"top": 0, "left": 0, "width": 600, "height": 800}
1916

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

2724

28-
def save(queue):
29-
# type: (Queue) -> None
30-
25+
def save(queue: Queue) -> None:
3126
number = 0
3227
output = "screenshots/file_{}.png"
3328
to_png = mss.tools.to_png
@@ -43,7 +38,7 @@ def save(queue):
4338

4439
if __name__ == "__main__":
4540
# The screenshots queue
46-
queue = Queue() # type: Queue
41+
queue: Queue = Queue()
4742

4843
# 2 processes: one for grabing and one for saving PNG files
4944
Process(target=grab, args=(queue,)).start()

docs/source/examples/from_pil_tuple.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
55
Use PIL bbox style and percent values.
66
"""
7-
87
import mss
98
import mss.tools
109

11-
1210
with mss.mss() as sct:
1311
# Use the 1st monitor
1412
monitor = sct.monitors[1]
@@ -23,7 +21,7 @@
2321
# Grab the picture
2422
# Using PIL would be something like:
2523
# im = ImageGrab(bbox=bbox)
26-
im = sct.grab(bbox) # type: ignore
24+
im = sct.grab(bbox)
2725

2826
# Save it!
2927
mss.tools.to_png(im.rgb, im.size, output="screenshot.png")

docs/source/examples/linux_display_keyword.py

-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
55
Usage example with a specific display.
66
"""
7-
87
import mss
98

10-
119
with mss.mss(display=":0.0") as sct:
1210
for filename in sct.save():
1311
print(filename)

docs/source/examples/opencv_numpy.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
55
OpenCV/Numpy example.
66
"""
7-
87
import time
98

109
import cv2
11-
import mss
1210
import numpy
1311

12+
import mss
1413

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

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

3433
# Press "q" to quit
3534
if cv2.waitKey(25) & 0xFF == ord("q"):

docs/source/examples/part_of_screen.py

-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
55
Example to capture part of the screen.
66
"""
7-
87
import mss
98
import mss.tools
109

11-
1210
with mss.mss() as sct:
1311
# The screen part to capture
1412
monitor = {"top": 160, "left": 160, "width": 160, "height": 135}

docs/source/examples/part_of_screen_monitor_2.py

-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
55
Example to capture part of the screen of the monitor 2.
66
"""
7-
87
import mss
98
import mss.tools
109

11-
1210
with mss.mss() as sct:
1311
# Get information of monitor 2
1412
monitor_number = 2

docs/source/examples/pil.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
55
PIL example using frombytes().
66
"""
7-
8-
import mss
97
from PIL import Image
108

9+
import mss
1110

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

2322
# And save it!
24-
output = "monitor-{}.png".format(num)
23+
output = f"monitor-{num}.png"
2524
img.save(output)
2625
print(output)

docs/source/examples/pil_pixels.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
55
PIL examples to play with pixels.
66
"""
7-
8-
import mss
97
from PIL import Image
108

9+
import mss
1110

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

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

2322
# But you can set individual pixels too (slower)

docs/source/support.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Support
55
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>`_.
66

77
- OS: GNU/Linux, macOS and Windows
8-
- Python: 3.5 and newer
8+
- Python: 3.6 and newer
99

1010

1111
Future
@@ -31,3 +31,4 @@ Abandoned
3131
- Python 3.2 (2016-10-08)
3232
- Python 3.3 (2017-12-05)
3333
- Python 3.4 (2018-03-19)
34+
- Python 3.5 (2022-10-27)

mss/__init__.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88
https://github.com/BoboTiG/python-mss
99
If that URL should fail, try contacting the author.
1010
"""
11-
1211
from .exception import ScreenShotError
1312
from .factory import mss
1413

15-
__version__ = "6.1.0"
14+
__version__ = "7.0.0"
1615
__author__ = "Mickaël 'Tiger-222' Schoentgen"
1716
__copyright__ = """
18-
Copyright (c) 2013-2020, Mickaël 'Tiger-222' Schoentgen
17+
Copyright (c) 2013-2022, Mickaël 'Tiger-222' Schoentgen
1918
20-
Permission to use, copy, modify, and distribute this software and its
21-
documentation for any purpose and without fee or royalty is hereby
22-
granted, provided that the above copyright notice appear in all copies
23-
and that both that copyright notice and this permission notice appear
24-
in supporting documentation or portions thereof, including
25-
modifications, that you make.
19+
Permission to use, copy, modify, and distribute this software and its
20+
documentation for any purpose and without fee or royalty is hereby
21+
granted, provided that the above copyright notice appear in all copies
22+
and that both that copyright notice and this permission notice appear
23+
in supporting documentation or portions thereof, including
24+
modifications, that you make.
2625
"""
2726
__all__ = ("ScreenShotError", "mss")

0 commit comments

Comments
 (0)