Przeglądaj źródła

Merge pull request #5 from alxf/python

Fix python 3 issue
tags/v0.99.beta20
alxf 9 lat temu
rodzic
commit
203d33361e
3 zmienionych plików z 21 dodań i 4 usunięć
  1. +1
    -1
      python/caca/canvas.py
  2. +2
    -1
      python/caca/display.py
  3. +18
    -2
      python/examples/drawing.py

+ 1
- 1
python/caca/canvas.py Wyświetl plik

@@ -38,7 +38,7 @@ class _Canvas(object):
return "<CacaCanvas %dx%d>" % (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):


+ 2
- 1
python/caca/display.py Wyświetl plik

@@ -32,7 +32,7 @@ class _Display(object):
return "<CacaDisplay>"

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.


+ 18
- 2
python/examples/drawing.py Wyświetl plik

@@ -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)


Ładowanie…
Anuluj
Zapisz