Beispiel #1
0
    def __init__(self, font, size=0):
        """ Font constructor

            font    -- the memory area containing the font or its name
            size    -- the size of the memory area, or 0 if the font name is given
        """
        if size == 0:
            _lib.caca_load_font.argtypes = [ctypes.c_char_p, ctypes.c_int]
        else:
            raise FontError("Unsupported method")

        _lib.caca_load_font.restype = ctypes.c_int

        if _PYTHON3:
            font = _str_to_bytes(font)

        self._font = _lib.caca_load_font(font, size)
        if self._font == 0:
            err = ctypes.c_int.in_dll(_lib, "errno")
            if err.value == errno.ENOENT:
                raise FontError("Requested built-in font does not exist")
            elif err.value == errno.EINVAL:
                raise FontError("Invalid font data in memory area")
            elif err.value == errno.ENOMEM:
                raise FontError("Not enough memory to allocate font structure")
Beispiel #2
0
    def __init__(self, font, size=0):
        """ Font constructor

            font    -- the memory area containing the font or its name
            size    -- the size of the memory area, or 0 if the font name is given
        """
        if size == 0:
            _lib.caca_load_font.argtypes = [ctypes.c_char_p, ctypes.c_int]
        else:
            raise FontError("Unsupported method")

        _lib.caca_load_font.restype = ctypes.c_int

        if _PYTHON3:
            font = _str_to_bytes(font)

        self._font = _lib.caca_load_font(font, size)
        if self._font == 0:
            err = ctypes.c_int.in_dll(_lib, "errno")
            if err.value == errno.ENOENT:
                raise FontError("Requested built-in font does not exist")
            elif err.value == errno.EINVAL:
                raise FontError("Invalid font data in memory area")
            elif err.value == errno.ENOMEM:
                raise FontError("Not enough memory to allocate font structure")
    def set_title(self, title):
        """ Set the display title.

            title   -- the desired display title
        """
        _lib.caca_set_display_title.argtypes = [_Display, ctypes.c_char_p]
        _lib.caca_set_display_title.restype = ctypes.c_int

        if _PYTHON3 and isinstance(title, str):
            title = _str_to_bytes(title)

        return _lib.caca_set_display_title(self, title)
Beispiel #4
0
    def set_title(self, title):
        """ Set the display title.

            title   -- the desired display title
        """
        _lib.caca_set_display_title.argtypes = [_Display, ctypes.c_char_p]
        _lib.caca_set_display_title.restype  = ctypes.c_int

        if _PYTHON3 and isinstance(title, str):
            title = _str_to_bytes(title)

        return _lib.caca_set_display_title(self, title)
    def set_driver(self, driver=None):
        """ Set the output driver.

            driver  -- A string describing the desired output driver or NULL
                       to choose the best driver automatically.
        """
        _lib.caca_set_display_driver.argtypes = [_Display, ctypes.c_char_p]
        _lib.caca_set_display_driver.restype = ctypes.c_int

        if not driver:
            driver = ctypes.c_char_p(0)
        else:
            if _PYTHON3 and isinstance(driver, str):
                driver = _str_to_bytes(driver)

        return _lib.caca_set_display_driver(self, driver)
Beispiel #6
0
    def set_driver(self, driver=None):
        """ Set the output driver.

            driver  -- A string describing the desired output driver or NULL
                       to choose the best driver automatically.
        """
        _lib.caca_set_display_driver.argtypes = [_Display, ctypes.c_char_p]
        _lib.caca_set_display_driver.restype  = ctypes.c_int

        if not driver:
            driver = ctypes.c_char_p(0)
        else:
            if _PYTHON3 and isinstance(driver, str):
                driver = _str_to_bytes(driver)

        return _lib.caca_set_display_driver(self, driver)
Beispiel #7
0
    def __init__(self, cv, driver=None):
        """ Display constructor.

            cv      -- canvas to attach.
            driver  -- caca driver to set with display
        """

        if driver is None:
            _lib.caca_create_display.argtypes = [_Canvas]
            self._dp = _lib.caca_create_display(cv)
        else:
            _lib.caca_create_display_with_driver.argtypes = [
                _Canvas, ctypes.c_char_p
            ]
            if _PYTHON3 and isinstance(driver, str):
                driver = _str_to_bytes(driver)

            self._dp = _lib.caca_create_display_with_driver(cv, driver)

        if self._dp == 0:
            raise DisplayError("Failed to create display")
Beispiel #8
0
    def __init__(self, cv, driver=None):
        """ Display constructor.

            cv      -- canvas to attach.
            driver  -- caca driver to set with display
        """

        if driver is None:
            _lib.caca_create_display.argtypes = [_Canvas]
            self._dp = _lib.caca_create_display(cv)
        else:
            _lib.caca_create_display_with_driver.argtypes = [
                _Canvas, ctypes.c_char_p
            ]
            if _PYTHON3 and isinstance(driver, str):
                driver = _str_to_bytes(driver)

            self._dp = _lib.caca_create_display_with_driver(cv, driver)

        if self._dp == 0:
            raise DisplayError("Failed to create display")