"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "python/caca/display.py" between
libcaca-0.99.beta19.tar.gz and libcaca-0.99.beta20.tar.bz2

About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).

display.py  (libcaca-0.99.beta19):display.py  (libcaca-0.99.beta20.tar.bz2)
skipping to change at line 22 skipping to change at line 22
# http://www.wtfpl.net/ for more details. # http://www.wtfpl.net/ for more details.
# #
""" Libcaca Python bindings """ """ Libcaca Python bindings """
import ctypes import ctypes
from caca import _lib, _PYTHON3, _str_to_bytes from caca import _lib, _PYTHON3, _str_to_bytes
from caca.canvas import _Canvas, Canvas from caca.canvas import _Canvas, Canvas
class _DisplayStruct(ctypes.Structure):
pass
class _Display(object): class _Display(object):
""" Model for Display objects. """ Model for Display objects.
""" """
def from_param(self): def from_param(self):
""" Required by ctypes module to call object as parameter of """ Required by ctypes module to call object as parameter of
a C function. a C function.
""" """
return self._dp return self._dp
def __str__(self): def __str__(self):
return "<CacaDisplay>" return "<CacaDisplay>"
def __del__(self): def __del__(self):
if self._dp > 0: if self._dp and _lib is not None:
self._free() self._free()
def _free(self): def _free(self):
""" Free a libcaca display. """ Free a libcaca display.
""" """
_lib.caca_free_display.argtypes = [_Display] _lib.caca_free_display.argtypes = [_Display]
_lib.caca_free_display.restype = ctypes.c_int _lib.caca_free_display.restype = ctypes.c_int
return _lib.caca_free_display(self) return _lib.caca_free_display(self)
skipping to change at line 59 skipping to change at line 62
""" """
def __init__(self, cv, driver=None): def __init__(self, cv, driver=None):
""" Display constructor. """ Display constructor.
cv -- canvas to attach. cv -- canvas to attach.
driver -- caca driver to set with display driver -- caca driver to set with display
""" """
if driver is None: if driver is None:
_lib.caca_create_display.argtypes = [_Canvas] _lib.caca_create_display.argtypes = [_Canvas]
_lib.caca_create_display.restype = ctypes.POINTER(_DisplayStruct)
self._dp = _lib.caca_create_display(cv) self._dp = _lib.caca_create_display(cv)
else: else:
_lib.caca_create_display_with_driver.argtypes = [ _lib.caca_create_display_with_driver.argtypes = [
_Canvas, ctypes.c_char_p _Canvas, ctypes.c_char_p
] ]
_lib.caca_create_display_with_driver.restype = ctypes.POINTER(
_DisplayStruct
)
if _PYTHON3 and isinstance(driver, str): if _PYTHON3 and isinstance(driver, str):
driver = _str_to_bytes(driver) driver = _str_to_bytes(driver)
self._dp = _lib.caca_create_display_with_driver(cv, driver) self._dp = _lib.caca_create_display_with_driver(cv, driver)
if self._dp == 0: if self._dp == 0:
raise DisplayError("Failed to create display") raise DisplayError("Failed to create display")
def get_driver(self): def get_driver(self):
""" Return the caca graphical context's current output driver. """ Return the caca graphical context's current output driver.
 End of changes. 4 change blocks. 
1 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)