Skip to content

Commit dd97dc3

Browse files
author
BoboTiG
committed
Update comments and documentation
1 parent 96f900d commit dd97dc3

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

README.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
A cross-platform multi-screen shot module in pure python using ctypes
33
**********************************************************************
44

5-
Very basic, it will grab one screen shot by monitor or a screen shot of all monitors and save it to an optimised/progressive PNG/JPEG file, Python 2.7/3.3 compatible.
5+
Very basic, it will grab one screen shot by monitor or a screen shot of all monitors and save it to an optimised PNG file, Python 2.7/3.3 compatible.
66

77
So, while you can `pip install mss`, you may just drop it in your project and forget about it.
88

@@ -43,7 +43,7 @@ When initalising an instance of MSS, you can enable debug output::
4343
mss = MSS(debug=True)
4444

4545

46-
save(output='mss', oneshot=False, ext='png', ftype=0)
46+
save(output='mss', oneshot=False)
4747
-----------------------------------------------------
4848

4949
For each monitor, grab a screen shot and save it to a file.
@@ -52,17 +52,15 @@ Parameters::
5252

5353
output - string - the output filename without extension
5454
oneshot - boolean - grab only one screen shot of all monitors
55-
ext - string - file format to save
56-
ftype - int - PNG filter type (0..4 [slower])
5755

5856
This is a generator which returns created files::
5957

60-
'output-1.ext',
61-
'output-2.ext',
58+
'output-1.png',
59+
'output-2.png',
6260
...,
63-
'output-NN.ext'
61+
'output-NN.png'
6462
or
65-
'output-full.ext'
63+
'output-full.png'
6664

6765

6866
Example

mss.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
Note: please keep this module compatible to Python 2.6.
1111
1212
Still needed:
13-
* support for built-in JPEG format
1413
* support for additional systems
1514
1615
Many thanks to all those who helped (in no particular order):
@@ -29,7 +28,7 @@
2928
3029
You can always get the latest version of this module at:
3130
32-
https://raw.github.com/BoboTiG/python-mss/mss.py
31+
https://raw.github.com/BoboTiG/python-mss/master/mss.py
3332
3433
If that URL should fail, try contacting the author.
3534
'''
@@ -244,12 +243,12 @@ def save(self, output='mss', oneshot=False):
244243
raise ValueError('MSS: no data to process.')
245244

246245
if hasattr(self, 'save_'):
247-
img_out = self.save_(output=filename)
246+
img_out = self.save_(output=filename)
248247
else:
249248
img = MSSImage(pixels, monitor[b'width'], monitor[b'height'])
250249
img_out = img.dump(filename)
251250
self.debug('save', 'img_out', img_out)
252-
if img_out is not None:
251+
if img_out:
253252
yield img_out
254253
else:
255254
yield filename + ' (already exists)'
@@ -342,15 +341,14 @@ def get_pixels(self, monitor):
342341

343342
width, height = monitor[b'width'], monitor[b'height']
344343
left, top = monitor[b'left'], monitor[b'top']
345-
346344
rect = CGRect((left, top), (width, height))
347345
self.image = CGWindowListCreateImage(
348346
rect, kCGWindowListOptionOnScreenOnly,
349347
kCGNullWindowID, kCGWindowImageDefault)
350348
return 1
351349

352350
def save_(self, output):
353-
''' Special method to not use MSSImage class. Speedy. '''
351+
''' Special method to not use MSSImage class. '''
354352

355353
self.debug('save_')
356354

@@ -719,18 +717,17 @@ def __init__(self, data=None, width=1, height=1):
719717
self.height = int(height)
720718

721719
def dump(self, output=None):
722-
''' Dump data to the image file using file format specified by ext.
720+
''' Dump data to the image file.
723721
Returns to created file name if success, else None.
724722
'''
725723

726724
if self.data is None:
727725
raise ValueError('MSSImage: no data to process.')
728726

729727
contents = self.png()
730-
if contents:
731-
with open(output, 'wb') as fileh:
732-
fileh.write(contents)
733-
return output
728+
with open(output, 'wb') as fileh:
729+
fileh.write(contents)
730+
return output
734731
return None
735732

736733
def png(self):

0 commit comments

Comments
 (0)