Changeset 4404
- Timestamp:
- Jun 1, 2010, 8:21:41 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/python/caca/canvas.py
r4403 r4404 69 69 raise CanvasError, "Failed to create canvas" 70 70 71 def manage(self, *args, **kw): 72 """ Not implemented. 73 """ 74 raise CanvasError, "Not implemented" 75 76 def unmanage(self, *args, **kw): 77 """ Not implemented. 78 """ 79 raise CanvasError, "Not implemented" 80 71 81 def set_size(self, width, height): 72 82 """ Resize a canvas. … … 98 108 return _lib.caca_get_canvas_height(self) 99 109 100 def get_chars(self): 101 """ Get the canvas character array, return python list. 102 """ 103 chlist = [] 104 #get canvas size 105 w, h = self.get_width(), self.get_height() 106 107 _lib.caca_get_canvas_chars.argtypes = [_Canvas] 108 _lib.caca_get_canvas_chars.restype = \ 109 ctypes.POINTER(ctypes.c_uint8 * (w * h)) 110 111 plist = _lib.caca_get_canvas_chars(self) 112 113 #build character list 114 for item in plist.contents: 115 if item != 0: 116 chlist.append(chr(item)) 117 118 return chlist 110 def get_chars(self, *args, **kw): 111 """ Not implemented. 112 """ 113 raise CanvasError, "Not implemented" 114 115 def get_attrs(self, *args, **kw): 116 """ Not implemented. 117 """ 118 raise CanvasError, "Not implemented" 119 119 120 120 def gotoxy(self, x, y): … … 201 201 return _lib.caca_printf(self, x, y, fmt, *args) 202 202 203 def vprintf(self, *args, **kw): 204 """ Not implemented. 205 """ 206 raise CanvasError, "Not implemented" 207 203 208 def clear(self): 204 209 """ Clear the canvas. … … 294 299 295 300 def get_dirty_rect(self, idx): 296 """ Get a canvas's dirty rectangle. 301 """ Get a canvas's dirty rectangle. Return python dictionnary with 302 coords as keys: x, y, width, height. 297 303 298 304 idx -- the requested rectangle index 299 305 """ 300 x = ctypes.POINTER(ctypes.c_int) 301 y = ctypes.POINTER(ctypes.c_int) 302 w = ctypes.POINTER(ctypes.c_int) 303 h = ctypes.POINTER(ctypes.c_int) 306 #initialize dictionnary and pointers 307 dct = None 308 x = ctypes.c_int() 309 y = ctypes.c_int() 310 width = ctypes.c_int() 311 height = ctypes.c_int() 304 312 305 313 _lib.caca_get_dirty_rect.argtypes = [ … … 310 318 _lib.caca_get_dirty_rect.restype = ctypes.c_int 311 319 312 _lib.caca_get_dirty_rect(self, idx, x, y, w, h) 313 314 return [x.contents.value, y.contents.value, 315 w.contents.value, h.contents.value] 320 if _lib.caca_get_dirty_rect(self, idx, x, y, width, height) > -1: 321 dct = { 322 'x': x.value, 'y': y.value, 323 'width': width.value, 'height': height.value, 324 } 325 326 return dct 316 327 317 328 def add_dirty_rect(self, x, y, width, height):
Note: See TracChangeset
for help on using the changeset viewer.