aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2015-05-03 13:05:15 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2015-05-03 13:05:15 +0300
commitacf2d339691af35d1301d382920a0cb4c9ad2597 (patch)
tree82c3fccb44a0d460048bc169b685a54292cc2c73 /examples/elementary
parentExamples: Add systray test/example to the main menu (diff)
downloadpython-efl-acf2d339691af35d1301d382920a0cb4c9ad2597.tar.gz
Evas.Textgrid: Fix memleak
Had to change the type of cellrows from list to custom tuple-like type.
Diffstat (limited to 'examples/elementary')
-rw-r--r--examples/elementary/test_evas_textgrid.py47
1 files changed, 29 insertions, 18 deletions
diff --git a/examples/elementary/test_evas_textgrid.py b/examples/elementary/test_evas_textgrid.py
index 5fce834..8a281a8 100644
--- a/examples/elementary/test_evas_textgrid.py
+++ b/examples/elementary/test_evas_textgrid.py
@@ -5,34 +5,46 @@ from efl import evas
from efl.evas import Textgrid, EVAS_TEXTGRID_PALETTE_STANDARD
from efl import elementary
from efl.elementary.window import StandardWindow
-from efl.elementary.background import Background
+
+if "unichr" not in dir(__builtins__):
+ unichr = chr
def evas_textgrid_clicked(obj, item=None):
- win = StandardWindow("evastextgrid", "Evas Textgrid Test", autodel=True,
- size=(320, 320))
+ win = StandardWindow(
+ "evastextgrid", "Evas Textgrid Test", autodel=True)
if obj is None:
win.callback_delete_request_add(lambda o: elementary.exit())
- tg = Textgrid(win.evas)
- tg.size = 15, 1
- tg.size_hint_weight_set(1.0, 1.0)
+ W = 80
+ H = 26
+
+ tg = Textgrid(
+ win.evas, size_hint_weight=(1.0, 1.0), size=(W, H),
+ font=("monospace", 14))
win.resize_object_add(tg)
- tg.font = "Courier", 20
tg.palette_set(EVAS_TEXTGRID_PALETTE_STANDARD, 0, 0, 0, 0, 255)
- tg.palette_set(EVAS_TEXTGRID_PALETTE_STANDARD, 1, 255, 255, 255, 255)
- row = tg.cellrow_get(0)
- for cell in row:
- cell.codepoint="รถ"
- cell.fg = 1
- cell.bg = 0
- tg.cellrow_set(0, row)
+ win.size_step = tg.cell_size
- tg.show()
- tg.update_add(0, 0, 10, 1)
+ # XXX: Add 1 to size, else the last row/col won't fit. Unknown reason.
+ win.size = (W * tg.cell_size[0] + 1, H * tg.cell_size[1] + 1)
- rowback = tg.cellrow_get(0)
+ for i in range(H):
+ ci = i + 1
+ cv = ci * 9
+ tg.palette_set(
+ EVAS_TEXTGRID_PALETTE_STANDARD, ci, cv, cv, cv, 255)
+ row = tg.cellrow_get(i)
+ if row is not None:
+ for cell in row:
+ cell.codepoint = unichr(1000 + i)
+ cell.bg = 0
+ cell.fg = ci
+ tg.cellrow_set(i, row)
+
+ tg.show()
+ tg.update_add(0, 0, 80, 26)
win.show()
@@ -46,4 +58,3 @@ if __name__ == "__main__":
elementary.run()
elementary.shutdown()
evas.shutdown()
-