(self, display=None)
GNU/Linux initialisations.
GNU/Linux initialisations.
GNU / Linux initialisations .
def __init__(self, display=None):
        # type: (Optional[Union[bytes, str]]) -> None
        """ GNU/Linux initialisations. """

        super().__init__()

        if not display:
            try:
                display = os.environ["DISPLAY"].encode("utf-8")
            except KeyError:
                # pylint: disable=raise-missing-from
                raise ScreenShotError("$DISPLAY not set.")

        if not isinstance(display, bytes):
            display = display.encode("utf-8")

        if b":" not in display:
            raise ScreenShotError("Bad display value: {!r}.".format(display))

        x11 = ctypes.util.find_library("X11")
        if not x11:
            raise ScreenShotError("No X11 library found.")
        self.xlib = ctypes.cdll.LoadLibrary(x11)

        # Install the error handler to prevent interpreter crashes:
        # any error will raise a ScreenShotError exception.
        self.xlib.XSetErrorHandler(error_handler)

        xrandr = ctypes.util.find_library("Xrandr")
        if not xrandr:
            raise ScreenShotError("No Xrandr extension found.")
        self.xrandr = ctypes.cdll.LoadLibrary(xrandr)

        self._set_cfunctions()

        self.root = self.xlib.XDefaultRootWindow(self._get_display(display))

        if not self.has_extension("RANDR"):
            raise ScreenShotError("No Xrandr extension found.")

        # Fix for XRRGetScreenResources and XGetImage:
        #     expected LP_Display instance instead of LP_XWindowAttributes
        self.drawable = ctypes.cast(self.root, POINTER(Display))
def __init__ ( self , display = None ) : # type: (Optional[Union[bytes, str]]) -> None super ( ) . __init__ ( ) if not display : try : display = os . environ [ "DISPLAY" ] . encode ( "utf-8" ) except KeyError : # pylint: disable=raise-missing-from raise ScreenShotError ( "$DISPLAY not set." ) if not isinstance ( display , bytes ) : display = display . encode ( "utf-8" ) if b":" not in display : raise ScreenShotError ( "Bad display value: {!r}." . format ( display ) ) x11 = ctypes . util . find_library ( "X11" ) if not x11 : raise ScreenShotError ( "No X11 library found." ) self . xlib = ctypes . cdll . LoadLibrary ( x11 ) # Install the error handler to prevent interpreter crashes: # any error will raise a ScreenShotError exception. self . xlib . XSetErrorHandler ( error_handler ) xrandr = ctypes . util . find_library ( "Xrandr" ) if not xrandr : raise ScreenShotError ( "No Xrandr extension found." ) self . xrandr = ctypes . cdll . LoadLibrary ( xrandr ) self . _set_cfunctions ( ) self . root = self . xlib . XDefaultRootWindow ( self . _get_display ( display ) ) if not self . has_extension ( "RANDR" ) : raise ScreenShotError ( "No Xrandr extension found." ) # Fix for XRRGetScreenResources and XGetImage: #     expected LP_Display instance instead of LP_XWindowAttributes self . drawable = ctypes . cast ( self . root , POINTER ( Display ) )