Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 07ab78c

Browse files
author
Mickaël Schoentgen
committed
Version 2.0.22
2 parents 86f6dea + e98012e commit 07ab78c

27 files changed

+257
-174
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ build/
22
.cache/
33
dist/
44
*.egg-info/
5+
.idea/
56
MANIFEST*
67
.DS_Store
78
*.orig

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ python:
44
- 3.3
55
- 3.4
66
- 3.5
7-
- 3.6-dev
8-
- nightly # currently points to 3.7-dev
7+
- 3.6
8+
# - nightly # currently points to 3.7-dev
99

1010
addons:
1111
apt:
@@ -22,7 +22,7 @@ install:
2222

2323
script:
2424
- py.test --display=":42.0"
25-
- flake8
25+
- flake8 mss
2626
- pylint mss
2727

2828
after_script:

CHANGELOG

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ History:
22

33
<see Git checkin messages for history>
44

5+
2.0.22 2017/04/29
6+
- new contributors: David Becker, redodo
7+
- add an example to capture only a part of the screen
8+
- better use of exception mechanism
9+
- Linux: use of hasattr to prevent Exception on early exit
10+
- Mac: take into account extra black pixels added when screen with is not divisible by 16 (fix #14)
11+
512
2.0.18 2016/12/03
613
- change license to MIT
714
- new contributor: Jochen 'cycomanic' Schroeder

CONTRIBUTORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ bubulle [http://indexerror.net/user/bubulle]
1515
Condé 'Eownis' Titouan <[email protected]> <[email protected]> [https://titouan.co]
1616
- MacOS X tester
1717

18+
David Becker [https://davide.me] and redodo [https://github.com/redodo]
19+
- Mac: Take into account extra black pixels added when screen with is not divisible by 16
20+
1821
Jochen 'cycomanic' Schroeder [https://github.com/cycomanic]
1922
- GNU/Linux: use errcheck instead of deprecated restype with callable, for enum_display_monitors()
2023

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MIT License
2-
Copyright (c) 2016, Mickaël 'Tiger-222' Schoentgen
2+
Copyright (c) 2016-2017, 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

docs/source/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@
5151

5252
# General information about the project.
5353
project = 'Python MSS'
54-
copyright = '2016, Tiger-222'
54+
copyright = '2013-2017, Tiger-222'
5555
author = 'Tiger-222'
5656

5757
# The version info for the project you're documenting, acts as replacement for
5858
# |version| and |release|, also used in various other places throughout the
5959
# built documents.
6060
#
6161
# The short X.Y version.
62-
version = '2.0.18'
62+
version = '2.0.21'
6363
# The full version, including alpha/beta/rc tags.
6464
release = 'latest'
6565

@@ -319,7 +319,7 @@
319319
# dir menu entry, description, category)
320320
texinfo_documents = [
321321
(master_doc, 'PythonMSS', 'Python MSS Documentation',
322-
author, 'PythonMSS', 'One line description of project.',
322+
author, 'PythonMSS', 'An ultra fast cross-platform multiple screenshots module in pure python using ctypes.',
323323
'Miscellaneous'),
324324
]
325325

docs/source/examples.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,20 @@ This is an example using `frombytes() <http://pillow.readthedocs.io/en/latest/re
130130

131131
# And save it!
132132
img.save('monitor-{0}.jpg'.format(num))
133+
134+
135+
Part of the screen
136+
==================
137+
138+
You can capture only a part of the screen::
139+
140+
from mss import mss
141+
142+
143+
with mss() as sct:
144+
# The screen part to capture
145+
mon = {'top': 160, 'left': 160, 'width': 222, 'height': 42}
146+
147+
# Save the picture
148+
output = 'sct-{top}x{left}_{width}x{height}.png'.format(**mon)
149+
sct.to_png(sct.get_pixels(mon), output)

examples/callback.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#!/usr/bin/env python
21
# coding: utf-8
3-
''' This is part of the MSS Python's module.
2+
""" This is part of the MSS Python's module.
43
Source: https://github.com/BoboTiG/python-mss
5-
'''
4+
"""
65

76
from os import rename
87
from os.path import isfile
@@ -13,13 +12,13 @@
1312

1413
def main():
1514
# type: () -> int
16-
''' Usage example. '''
15+
""" Usage example. """
1716

1817
def on_exists(fname):
1918
# type: (str) -> None
20-
''' Callback example when we try to overwrite an existing
19+
""" Callback example when we try to overwrite an existing
2120
screenshot.
22-
'''
21+
"""
2322

2423
if isfile(fname):
2524
newfile = fname + '.old'
@@ -28,8 +27,7 @@ def on_exists(fname):
2827

2928
try:
3029
with mss() as sct:
31-
# For MacOS X only
32-
# sct.max_displays = 32
30+
# sct.max_displays = 32 # macOS only
3331

3432
print('One screenshot per monitor')
3533
for filename in sct.save():

examples/linux-display_keyword.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
#!/usr/bin/env python
21
# coding: utf-8
3-
''' This is part of the MSS Python's module.
2+
""" This is part of the MSS Python's module.
43
Source: https://github.com/BoboTiG/python-mss
5-
'''
4+
"""
65

76
from mss.exception import ScreenshotError
87
from mss.linux import MSS
98

109

1110
def main():
1211
# type: () -> int
13-
''' Usage example with a specific display. '''
12+
""" Usage example with a specific display. """
1413

1514
display = ':0.0'
1615
print('Screenshot of display "{0}"'.format(display))

examples/part-of-screen.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# coding: utf-8
2+
""" This is part of the MSS Python's module.
3+
Source: https://github.com/BoboTiG/python-mss
4+
"""
5+
6+
from mss.exception import ScreenshotError
7+
from mss import mss
8+
9+
10+
def main():
11+
# type: () -> int
12+
""" Example to capture part of the screen. """
13+
14+
try:
15+
with mss() as sct:
16+
# The screen part to capture
17+
mon = {'top': 160, 'left': 160, 'width': 160, 'height': 135}
18+
19+
# Save the picture
20+
output = 'sct-{top}x{left}_{width}x{height}.png'.format(**mon)
21+
sct.to_png(sct.get_pixels(mon), output)
22+
print(output)
23+
24+
return 0
25+
except ScreenshotError as ex:
26+
print(ex)
27+
28+
return 1
29+
30+
31+
if __name__ == '__main__':
32+
exit(main())

0 commit comments

Comments
 (0)