Skip to content

Commit a9230da

Browse files
committed
save(): set callback to None by default
1 parent 82ec65a commit a9230da

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

docs/source/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Methods
6666
It stocks pixels data into :attr:`image` (RGB) and returns it.
6767

6868

69-
.. method:: save(mon=0, output='monitor-%d.png', callback=lambda *x: True) -> generator
69+
.. method:: save(mon=0, output='monitor-%d.png', callback=None) -> generator
7070

7171
:param int mon: the monitor's number.
7272
:param str output: the output's file name. ``%d``, if present, will be replaced by the monitor number.

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
# built documents.
6060
#
6161
# The short X.Y version.
62-
version = '2.0.7'
62+
version = '2.0.8'
6363
# The full version, including alpha/beta/rc tags.
6464
release = 'latest'
6565

mss/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from .exception import ScreenshotError
1616
from .factory import mss
1717

18-
__version__ = '2.0.7'
18+
__version__ = '2.0.8'
1919
__author__ = "Mickaël 'Tiger-222' Schoentgen"
2020
__copyright__ = '''
2121
Copyright (c) 2013-2016, Mickaël 'Tiger-222' Schoentgen

mss/base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get_pixels(self, monitor):
7171

7272
raise NotImplementedError('Subclasses need to implement this!')
7373

74-
def save(self, mon=0, output='monitor-%d.png', callback=lambda *x: True):
74+
def save(self, mon=0, output='monitor-%d.png', callback=None):
7575
''' Grab a screenshot and save it to a file.
7676
7777
mon (integer, default: 0)
@@ -100,7 +100,8 @@ def save(self, mon=0, output='monitor-%d.png', callback=lambda *x: True):
100100
fname = output
101101
if '%d' in output:
102102
fname = output.replace('%d', str(i))
103-
callback(fname)
103+
if callable(callback):
104+
callback(fname)
104105
self.to_png(self.get_pixels(monitor), fname)
105106
yield fname
106107
else:
@@ -115,7 +116,8 @@ def save(self, mon=0, output='monitor-%d.png', callback=lambda *x: True):
115116

116117
if '%d' in output:
117118
output = output.replace('%d', str(mon_number))
118-
callback(output)
119+
if callable(callback):
120+
callback(output)
119121
self.to_png(self.get_pixels(monitor), output)
120122
yield output
121123

0 commit comments

Comments
 (0)