aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test_diskselector.py
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2013-11-01 01:52:48 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2013-11-01 01:52:48 +0200
commit944234bccdd02e53d14490373fa15930667bb50b (patch)
tree4acbfc7f477d19450664add6f75639ac5daaa182 /examples/elementary/test_diskselector.py
parentElementary.datetime_elm: Fix an API bug. (diff)
downloadpython-efl-944234bccdd02e53d14490373fa15930667bb50b.tar.gz
Elementary: Examplifying examples.
Diffstat (limited to 'examples/elementary/test_diskselector.py')
-rw-r--r--examples/elementary/test_diskselector.py84
1 files changed, 34 insertions, 50 deletions
diff --git a/examples/elementary/test_diskselector.py b/examples/elementary/test_diskselector.py
index e95a79d..b068301 100644
--- a/examples/elementary/test_diskselector.py
+++ b/examples/elementary/test_diskselector.py
@@ -1,20 +1,29 @@
#!/usr/bin/env python
# encoding: utf-8
-from efl import evas
+import os
+
+from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
from efl import elementary
-from efl.elementary.window import Window
-from efl.elementary.background import Background
+from efl.elementary.window import StandardWindow
from efl.elementary.box import Box
from efl.elementary.icon import Icon
from efl.elementary.diskselector import Diskselector
+EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
+FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
+FILL_HORIZ = EVAS_HINT_FILL, 0.5
+
months=["January", "February", "March", "April", "May", "June", "August", "September", "October", "November", "December"]
weekdays=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
months_short=["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
-def disk_create(win, rnd):
- di = Diskselector(win)
+img_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "images")
+ic_file = os.path.join(img_path, "logo_small.png")
+
+
+def disk_create(win, rnd, **kwargs):
+ di = Diskselector(win, round_enabled=rnd, **kwargs)
for m in months:
if m == "August":
it = di.item_append(m)
@@ -22,109 +31,84 @@ def disk_create(win, rnd):
di.item_append(m)
it.selected = True
- di.round_enabled = rnd
return di
def cb_sel(ds, item):
- print(("Selected item: %s" % (item.text.encode("UTF-8"))))
+ print("Selected item: " + item.text.encode("utf-8"))
def diskselector_clicked(obj):
- win = Window("diskselector", elementary.ELM_WIN_BASIC)
- win.title = "Diskselector test"
- win.autodel = True
+ win = StandardWindow("diskselector", "Diskselector test", autodel=True,
+ size=(320, 480))
if obj is None:
win.callback_delete_request_add(lambda o: elementary.exit())
- bg = Background(win)
- win.resize_object_add(bg)
- bg.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- bg.show()
-
- vbox = Box(win)
- vbox.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ vbox = Box(win, size_hint_weight=EXPAND_BOTH)
win.resize_object_add(vbox)
vbox.show()
- di = disk_create(win, True)
- di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
+ di = disk_create(win, rnd=True, size_hint_weight=EXPAND_BOTH,
+ size_hint_align=FILL_HORIZ)
di.callback_selected_add(cb_sel)
vbox.pack_end(di)
di.show()
di.first_item.selected = True
- di = disk_create(win, False)
- di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
+ di = disk_create(win, rnd=False, size_hint_weight=EXPAND_BOTH,
+ size_hint_align=FILL_HORIZ)
di.callback_selected_add(cb_sel)
vbox.pack_end(di)
di.show()
di.first_item.next.selected = True
- di = disk_create(win, False)
- di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
+ di = disk_create(win, rnd=False, size_hint_weight=EXPAND_BOTH,
+ size_hint_align=FILL_HORIZ, side_text_max_length=4)
di.callback_selected_add(cb_sel)
vbox.pack_end(di)
di.show()
- di.side_text_max_length = 4
- ic = Icon(win)
- ic.file = "images/logo_small.png"
- di = Diskselector(win)
+ ic = Icon(win, file=ic_file)
+ di = Diskselector(win, size_hint_weight=EXPAND_BOTH,
+ size_hint_align=FILL_HORIZ)
di.item_append("Sunday", ic)
for day in weekdays:
di.item_append(day)
- di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
di.callback_selected_add(cb_sel)
vbox.pack_end(di)
di.show()
- ic = Icon(win)
- ic.file = "images/logo_small.png"
- di = Diskselector(win)
+ ic = Icon(win, file=ic_file)
+ di = Diskselector(win, round_enabled=True, size_hint_weight=EXPAND_BOTH,
+ size_hint_align=FILL_HORIZ)
di.item_append("머리스타일", ic)
for lan in ["プロが伝授する", "生上访要求政府", "English", "والشريعة", "עִבְרִית", "Grüßen"]:
di.item_append(lan)
- di.round_enabled = True
- di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
di.callback_selected_add(cb_sel)
vbox.pack_end(di)
di.show()
- di = Diskselector(win)
- di.display_item_num = 5
+ di = Diskselector(win, display_item_num=5, round_enabled=True,
+ size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ)
for m in months_short:
di.item_append(m)
- di.round_enabled = True
- di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
di.callback_selected_add(cb_sel)
vbox.pack_end(di)
di.show()
di.last_item.selected = True
- di = Diskselector(win)
+ di = Diskselector(win, display_item_num=7, round_enabled=True,
+ size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ)
di.display_item_num = 7
for i in range(31):
di.item_append(str(i))
- di.round_enabled = True
- di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
di.callback_selected_add(cb_sel)
vbox.pack_end(di)
di.show()
di.last_item.selected = True
-
- win.resize(320, 480)
win.show()
-
if __name__ == "__main__":
elementary.init()