From b97a47705faa2aa659a44d06b374b6c31bc84827 Mon Sep 17 00:00:00 2001 From: Alex Foulon Date: Thu, 18 Jun 2015 19:35:49 +0200 Subject: [PATCH 1/3] python: fix drawing.py example --- python/examples/drawing.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/python/examples/drawing.py b/python/examples/drawing.py index 4a9609c..3bcf02e 100755 --- a/python/examples/drawing.py +++ b/python/examples/drawing.py @@ -96,22 +96,38 @@ if __name__ == "__main__": sys.exit() elif ch == ord('1'): draw.do_line() + dp.refresh() + time.sleep(2) elif ch == ord('2'): draw.do_line(thin=True) + dp.refresh() + time.sleep(2) elif ch == ord('3'): draw.do_polyline() + dp.refresh() + time.sleep(2) elif ch == ord('4'): draw.do_polyline(thin=True) + dp.refresh() + time.sleep(2) elif ch == ord('5'): draw.do_circle() + dp.refresh() + time.sleep(2) elif ch == ord('6'): draw.do_ellipse() + dp.refresh() + time.sleep(2) elif ch == ord('7'): draw.do_ellipse(thin=True) + dp.refresh() + time.sleep(2) elif ch == ord('8'): draw.do_box() + dp.refresh() + time.sleep(2) elif ch == ord('9'): draw.do_box(thin=True) - dp.refresh() - time.sleep(2) + dp.refresh() + time.sleep(2) From 551ad917753d7411c0b34d3f776de890c287f11d Mon Sep 17 00:00:00 2001 From: Alex Foulon Date: Thu, 18 Jun 2015 19:59:31 +0200 Subject: [PATCH 2/3] python: fix python3 problem --- python/caca/canvas.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/caca/canvas.py b/python/caca/canvas.py index 725ae49..7fc0a74 100644 --- a/python/caca/canvas.py +++ b/python/caca/canvas.py @@ -47,7 +47,10 @@ class _Canvas(object): _lib.caca_free_canvas.argtypes = [_Canvas] _lib.caca_free_canvas.restype = ctypes.c_int - return _lib.caca_free_canvas(self) + if self is not None: + return _lib.caca_free_canvas(self) + + return None class Canvas(_Canvas): """ Canvas object, methods are libcaca functions with canvas_t as From 0baf2fde066b4d621c47789ca2f925c4794fa49b Mon Sep 17 00:00:00 2001 From: Alex Foulon Date: Sun, 21 Jun 2015 12:35:22 +0200 Subject: [PATCH 3/3] fix python3 issue again. --- python/caca/canvas.py | 7 ++----- python/caca/display.py | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/python/caca/canvas.py b/python/caca/canvas.py index 7fc0a74..046a1c3 100644 --- a/python/caca/canvas.py +++ b/python/caca/canvas.py @@ -38,7 +38,7 @@ class _Canvas(object): return "" % (self.get_width(), self.get_height()) def __del__(self): - if self._cv > 0: + if self._cv > 0 and _lib is not None: self._free() def _free(self): @@ -47,10 +47,7 @@ class _Canvas(object): _lib.caca_free_canvas.argtypes = [_Canvas] _lib.caca_free_canvas.restype = ctypes.c_int - if self is not None: - return _lib.caca_free_canvas(self) - - return None + return _lib.caca_free_canvas(self) class Canvas(_Canvas): """ Canvas object, methods are libcaca functions with canvas_t as diff --git a/python/caca/display.py b/python/caca/display.py index 93e028b..7cf4d71 100644 --- a/python/caca/display.py +++ b/python/caca/display.py @@ -32,7 +32,7 @@ class _Display(object): return "" def __del__(self): - if self._dp > 0: + if self._dp > 0 and _lib is not None: self._free() def _free(self): @@ -43,6 +43,7 @@ class _Display(object): return _lib.caca_free_display(self) + class Display(_Display): """ Display objects, methods are libcaca functions with display_t as first parameter.