(self, mon=0, output="monitor-{mon}.png", callback=None)
Grab a screen shot and save it to a file.

        :param int mon: The monitor to screen shot (default=0).
                        -1: grab one screen shot of all monitors
                         0: grab one screen shot by monitor
                        N: grab the screen shot of the monitor N

        :param str output: The output filename.

            It can take several keywords to customize the filename:
            - `{mon}`: the monitor number
            - `{top}`: the screen shot y-coordinate of the upper-left corner
            - `{left}`: the screen shot x-coordinate of the upper-left corner
            - `{width}`: the screen shot's width
            - `{height}`: the screen shot's height
            - `{date}`: the current date using the default formatter

            As it is using the `format()` function, you can specify
            formatting options like `{date:%Y-%m-%s}`.

        :param callable callback: Callback called before saving the
            screen shot to a file.  Take the `output` argument as parameter.

        :return generator: Created file(s).
Grab a screen shot and save it to a file.
Grab a screen shot and save it to a file .
def save(self, mon=0, output="monitor-{mon}.png", callback=None):
        # type: (int, str, Callable[[str], None]) -> Iterator[str]
        """
        Grab a screen shot and save it to a file.

        :param int mon: The monitor to screen shot (default=0).
                        -1: grab one screen shot of all monitors
                         0: grab one screen shot by monitor
                        N: grab the screen shot of the monitor N

        :param str output: The output filename.

            It can take several keywords to customize the filename:
            - `{mon}`: the monitor number
            - `{top}`: the screen shot y-coordinate of the upper-left corner
            - `{left}`: the screen shot x-coordinate of the upper-left corner
            - `{width}`: the screen shot's width
            - `{height}`: the screen shot's height
            - `{date}`: the current date using the default formatter

            As it is using the `format()` function, you can specify
            formatting options like `{date:%Y-%m-%s}`.

        :param callable callback: Callback called before saving the
            screen shot to a file.  Take the `output` argument as parameter.

        :return generator: Created file(s).
        """

        monitors = self.monitors
        if not monitors:
            raise ScreenShotError("No monitor found.")

        if mon == 0:
            # One screen shot by monitor
            for idx, monitor in enumerate(monitors[1:], 1):
                fname = output.format(mon=idx, date=datetime.now(), **monitor)
                if callable(callback):
                    callback(fname)
                sct = self.grab(monitor)
                to_png(sct.rgb, sct.size, level=self.compression_level, output=fname)
                yield fname
        else:
            # A screen shot of all monitors together or
            # a screen shot of the monitor N.
            mon = 0 if mon == -1 else mon
            try:
                monitor = monitors[mon]
            except IndexError:
                # pylint: disable=raise-missing-from
                raise ScreenShotError("Monitor {!r} does not exist.".format(mon))

            output = output.format(mon=mon, date=datetime.now(), **monitor)
            if callable(callback):
                callback(output)
            sct = self.grab(monitor)
            to_png(sct.rgb, sct.size, level=self.compression_level, output=output)
            yield output
def save ( self , mon = 0 , output = "monitor-{mon}.png" , callback = None ) : # type: (int, str, Callable[[str], None]) -> Iterator[str] monitors = self . monitors if not monitors : raise ScreenShotError ( "No monitor found." ) if mon == 0 : # One screen shot by monitor for idx , monitor in enumerate ( monitors [ 1 : ] , 1 ) : fname = output . format ( mon = idx , date = datetime . now ( ) , * * monitor ) if callable ( callback ) : callback ( fname ) sct = self . grab ( monitor ) to_png ( sct . rgb , sct . size , level = self . compression_level , output = fname ) yield fname else : # A screen shot of all monitors together or # a screen shot of the monitor N. mon = 0 if mon == - 1 else mon try : monitor = monitors [ mon ] except IndexError : # pylint: disable=raise-missing-from raise ScreenShotError ( "Monitor {!r} does not exist." . format ( mon ) ) output = output . format ( mon = mon , date = datetime . now ( ) , * * monitor ) if callable ( callback ) : callback ( output ) sct = self . grab ( monitor ) to_png ( sct . rgb , sct . size , level = self . compression_level , output = output ) yield output