@@ -103,7 +103,8 @@ class BITMAPINFOHEADER(Structure):
103103 class BITMAPINFO (Structure ):
104104 _fields_ = [('bmiHeader' , BITMAPINFOHEADER ), ('bmiColors' , DWORD * 3 )]
105105else :
106- raise ScreenshotError ('MSS: system "{0}" not implemented.' .format (system ()))
106+ err = 'MSS: system "{0}" not implemented.' .format (system ())
107+ raise ScreenshotError (err )
107108
108109
109110# ----------------------------------------------------------------------
@@ -122,7 +123,7 @@ def debug(self, method='', scalar=None, value=None):
122123 print (':: {0}()' .format (method ))
123124 else :
124125 print ('{0}() {1} {2} {3}' .format (method , scalar ,
125- type (value ).__name__ , value ))
126+ type (value ).__name__ , value ))
126127
127128 def enum_display_monitors (self ):
128129 ''' Get positions of all monitors.
@@ -234,7 +235,8 @@ def save_img(self, data, width, height, output):
234235 fileh .write (
235236 magic + b'' .join (ihdr ) + b'' .join (idat ) + b'' .join (iend ))
236237 return
237- raise ScreenshotError ('MSS: error writing data to "{0}".' .format (output ))
238+ err = 'MSS: error writing data to "{0}".' .format (output )
239+ raise ScreenshotError (err )
238240
239241
240242class MSSMac (MSS ):
@@ -284,8 +286,10 @@ def get_pixels(self, monitor):
284286 width , height = monitor [b'width' ], monitor [b'height' ]
285287 left , top = monitor [b'left' ], monitor [b'top' ]
286288 rect = CGRect ((left , top ), (width , height ))
287- self .image = CGWindowListCreateImage (rect , kCGWindowListOptionOnScreenOnly ,
288- kCGNullWindowID , kCGWindowImageDefault )
289+ options = kCGWindowListOptionOnScreenOnly
290+ winid = kCGNullWindowID
291+ default = kCGWindowImageDefault
292+ self .image = CGWindowListCreateImage (rect , options , winid , default )
289293 if not self .image :
290294 raise ScreenshotError ('MSS: CGWindowListCreateImage() failed.' )
291295 return self .image
@@ -300,7 +304,8 @@ def save_img(self, data, width, height, output):
300304 CGImageDestinationAddImage (dest , data , None )
301305 if CGImageDestinationFinalize (dest ):
302306 return
303- raise ScreenshotError ('MSS: error writing to file "{0}".' .format (output ))
307+ err = 'MSS: error writing to file "{0}".' .format (output )
308+ raise ScreenshotError (err )
304309
305310
306311class MSSLinux (MSS ):
@@ -574,8 +579,9 @@ def _callback(monitor, dc, rect, data):
574579 def get_pixels (self , monitor ):
575580 ''' Retrieve all pixels from a monitor. Pixels have to be RGB.
576581
577- [1] A bottom-up DIB is specified by setting the height to a positive number,
578- while a top-down DIB is specified by setting the height to a negative number.
582+ [1] A bottom-up DIB is specified by setting the height to a
583+ positive number, while a top-down DIB is specified by
584+ setting the height to a negative number.
579585 https://msdn.microsoft.com/en-us/library/ms787796.aspx
580586 https://msdn.microsoft.com/en-us/library/dd144879%28v=vs.85%29.aspx
581587 '''
@@ -595,7 +601,7 @@ def get_pixels(self, monitor):
595601 bmi .bmiHeader .biHeight = - height # Why minus? See [1]
596602 bmi .bmiHeader .biPlanes = 1 # Always 1
597603 bmi .bmiHeader .biBitCount = 24
598- bmi .bmiHeader .biCompression = BI_RGB ;
604+ bmi .bmiHeader .biCompression = BI_RGB
599605 buffer_len = height * width * 3
600606 self .image = create_string_buffer (buffer_len )
601607 srcdc = windll .user32 .GetWindowDC (0 )
@@ -628,7 +634,8 @@ def get_pixels(self, monitor):
628634 # Replace pixels values: BGR to RGB
629635 # @TODO: this part takes most of the time. Need a better solution.
630636 for idx in range (0 , buffer_len - 2 , 3 ):
631- self .image [idx + 2 ], self .image [idx ] = self .image [idx ], self .image [idx + 2 ]
637+ self .image [idx + 2 ], self .image [idx ] = \
638+ self .image [idx ], self .image [idx + 2 ]
632639 return self .image
633640
634641
@@ -637,7 +644,7 @@ def main():
637644
638645 systems = {'Darwin' : MSSMac , 'Linux' : MSSLinux , 'Windows' : MSSWindows }
639646 mss = systems [system ()]()
640- #mss.DEBUG = True
647+ # mss.DEBUG = True
641648
642649 def on_exists (fname ):
643650 ''' Callback example when we try to overwrite an existing
0 commit comments