summaryrefslogtreecommitdiff
path: root/tests/elementary/test_ctxpopup.py
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2013-02-11 22:32:50 +0000
committerDavide Andreoli <dave@gurumeditation.it>2013-02-11 22:32:50 +0000
commit8b8639886059814a36f57164d5572e97bcb00a47 (patch)
tree1c5a170de002793c1402d6afcc16c63115d81caa /tests/elementary/test_ctxpopup.py
Put in a first, still wip, version of the python bindings in a merged tree.
This is meant to be the 1.8 version of the wrappers and will include everything that now is in the python folder. Atm this include evas, ecore, edje, elementary and emotion (emotion still commented in the build couse it need some more testing). Eo is used as a base for all the objects that inherit from it in C, but in real nothing is used from Eo, it is used more like a container to share code between the libs. All the docs has been stripped out because we want to use the new sphinx style docs that Kay has done in his git repo. (Kay: please wait a little bit to include it, as working on the libs without docs is much more easy) The new wrappers include a new container module called efl and thus you can live with both the old and the new installation. This also means that you need to import the new modules as: "from efl import evas" (instead of the old "import evas") The idea here is that you can make your code works with both version doing something like: try: import evas except: from efl import evas ...like is done in the gtk bindings Some stuff has been leaved out on purpose, because was old stuff (like the hacked evas rotation stuff) or because was not working as expected (like all the ecore.evas.XXX modules). See the TODO.txt file for more info. Probably some stuff is out just because I missed them, let me know if you miss something. Improvements from the old version: - Py3 compatible (still some work to be done, but really only TODO, no problems to resolv) - Should also works on other platforms, like windoz (but not tested) - Unittests greatly improved, you can also run ALL tests at once - much more simpler :) I will contine the works in the next weeks and hope someone will help too. NOTE: I switched back to setup.py instead of autotools, because that is the right way to compile python stuff. So to build just use: python setup.py install or python3 setup.py install Enjoy davemds SVN revision: 83831
Diffstat (limited to 'tests/elementary/test_ctxpopup.py')
-rw-r--r--tests/elementary/test_ctxpopup.py182
1 files changed, 182 insertions, 0 deletions
diff --git a/tests/elementary/test_ctxpopup.py b/tests/elementary/test_ctxpopup.py
new file mode 100644
index 0000000..dd6dc39
--- /dev/null
+++ b/tests/elementary/test_ctxpopup.py
@@ -0,0 +1,182 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4from efl import elementary
5from efl import evas
6
7
8def cb_items(li, item):
9 print(("ctxpopup item selected: %s" % (item.text)))
10
11def item_new(cp, label, icon = None):
12 if icon:
13 ic = elementary.Icon(cp)
14 ic.standard_set(icon)
15 ic.resizable_set(False, False)
16 return cp.item_append(label, ic, cb_items)
17 else:
18 return cp.item_append(label, None, cb_items)
19
20def cb_btn(btn):
21 cp = btn.data["ctxpopup"]
22 if "img" in cp.data:
23 return
24 img = evas.FilledImage(btn.evas)
25 img.file_set("images/sky_04.jpg")
26 img.move(40, 40)
27 img.resize(320, 320)
28 img.show()
29
30 cp = btn.data["ctxpopup"]
31 cp.data["img"] = img
32 cp.raise_()
33 # NOTE: the '_' is wanted as 'raise' is a reserved word in py
34
35def cb_dismissed(cp):
36 if "img" in cp.data:
37 cp.data["img"].delete()
38
39def cb_item1(li, item):
40 cp = elementary.Ctxpopup(li)
41 it = item_new(cp, "Go to home folder", "home")
42 it = item_new(cp, "Save file", "file")
43 it = item_new(cp, "Delete file", "delete")
44 it = item_new(cp, "Navigate to folder", "folder")
45 it.disabled = True
46 it = item_new(cp, "Edit entry", "edit")
47 it = item_new(cp, "Sate date and time", "clock")
48 it.disabled = True
49
50 (x, y) = li.evas.pointer_canvas_xy_get()
51 cp.move(x, y)
52 cp.show()
53
54def cb_item2(li, item):
55 cp = elementary.Ctxpopup(li)
56 it = item_new(cp, "", "home")
57 it = item_new(cp, "", "file")
58 it = item_new(cp, "", "delete")
59 it = item_new(cp, "", "folder")
60 it = item_new(cp, "", "edit")
61 it.disabled = True
62 it = item_new(cp, "", "clock")
63
64 (x, y) = li.evas.pointer_canvas_xy_get()
65 cp.move(x, y)
66 cp.show()
67
68def cb_item3(li, item):
69 cp = elementary.Ctxpopup(li)
70 it = item_new(cp, "Eina")
71 it = item_new(cp, "Eet")
72 it = item_new(cp, "Evas")
73 it = item_new(cp, "Ecore")
74 it.disabled = True
75 it = item_new(cp, "Embryo")
76 it = item_new(cp, "Edje")
77
78 (x, y) = li.evas.pointer_canvas_xy_get()
79 cp.move(x, y)
80 cp.show()
81
82def cb_item4(li, item):
83 cp = elementary.Ctxpopup(li)
84 cp.horizontal = True
85 it = item_new(cp, "", "home")
86 it = item_new(cp, "", "file")
87 it = item_new(cp, "", "delete")
88 it = item_new(cp, "", "folder")
89 it = item_new(cp, "", "edit")
90 it = item_new(cp, "", "clock")
91
92 (x, y) = li.evas.pointer_canvas_xy_get()
93 cp.move(x, y)
94 cp.show()
95
96def cb_item5(li, item):
97 box = elementary.Box(li)
98 box.size_hint_min = (150, 150)
99
100 sc = elementary.Scroller(li)
101 sc.bounce = (False, True)
102 sc.size_hint_align = (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
103 sc.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
104 sc.show()
105
106 bt = elementary.Button(li)
107 bt.text = "Enlightenment"
108 bt.size_hint_min = (140, 140)
109
110 sc.content = bt
111 box.pack_end(sc)
112
113 cp = elementary.Ctxpopup(li)
114 cp.content = box
115 (x, y) = li.evas.pointer_canvas_xy_get()
116 cp.move(x, y)
117 cp.show()
118
119def cb_item6(li, item):
120 box = elementary.Box(li)
121 box.size_hint_min = (200, 150)
122
123 sc = elementary.Scroller(li)
124 sc.bounce = (False, True)
125 sc.size_hint_align = (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
126 sc.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
127 sc.show()
128
129 bt = elementary.Button(li)
130 bt.text = "Ctxpop will be on the top of layer"
131 bt.callback_clicked_add(cb_btn)
132 bt.size_hint_min = (190, 140)
133
134 sc.content = bt
135 box.pack_end(sc)
136
137 cp = elementary.Ctxpopup(li)
138 cp.callback_dismissed_add(cb_dismissed)
139 cp.content = box
140 (x, y) = li.evas.pointer_canvas_xy_get()
141 cp.move(x, y)
142 cp.show()
143 bt.data["ctxpopup"] = cp
144
145def ctxpopup_clicked(obj):
146 win = elementary.Window("ctxpopup", elementary.ELM_WIN_BASIC)
147 win.title = "Context popup test"
148 win.autodel = True
149 if obj is None:
150 win.callback_delete_request_add(lambda o: elementary.exit())
151
152 bg = elementary.Background(win)
153 win.resize_object_add(bg)
154 bg.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
155 bg.show()
156
157 li = elementary.List(win)
158 win.resize_object_add(li)
159 li.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
160 li.mode = elementary.ELM_LIST_COMPRESS
161 li.show()
162
163 li.item_append("Ctxpopup with icons and labels", callback=cb_item1)
164 li.item_append("Ctxpopup with icons only", callback=cb_item2)
165 li.item_append("Ctxpopup with labels only", callback=cb_item3)
166 li.item_append("Ctxpopup at horizontal mode", callback=cb_item4)
167 li.item_append("Ctxpopup with user content", callback=cb_item5)
168 li.item_append("Ctxpopup with restacking", callback=cb_item6)
169 li.go()
170
171 win.resize(400, 400)
172 win.show()
173
174
175if __name__ == "__main__":
176 elementary.init()
177
178 ctxpopup_clicked(None)
179
180 elementary.run()
181 elementary.shutdown()
182