summaryrefslogtreecommitdiff
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
parent7826e96e0176acadf31f02c14baf03873eef2f92 (diff)
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 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2# encoding: utf-8 2# encoding: utf-8
3 3
4from efl import evas 4import os
5
6from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
5from efl import elementary 7from efl import elementary
6from efl.elementary.window import Window 8from efl.elementary.window import StandardWindow
7from efl.elementary.background import Background
8from efl.elementary.box import Box 9from efl.elementary.box import Box
9from efl.elementary.icon import Icon 10from efl.elementary.icon import Icon
10from efl.elementary.diskselector import Diskselector 11from efl.elementary.diskselector import Diskselector
11 12
13EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
14FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
15FILL_HORIZ = EVAS_HINT_FILL, 0.5
16
12months=["January", "February", "March", "April", "May", "June", "August", "September", "October", "November", "December"] 17months=["January", "February", "March", "April", "May", "June", "August", "September", "October", "November", "December"]
13weekdays=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] 18weekdays=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
14months_short=["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] 19months_short=["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
15 20
16def disk_create(win, rnd): 21img_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "images")
17 di = Diskselector(win) 22ic_file = os.path.join(img_path, "logo_small.png")
23
24
25def disk_create(win, rnd, **kwargs):
26 di = Diskselector(win, round_enabled=rnd, **kwargs)
18 for m in months: 27 for m in months:
19 if m == "August": 28 if m == "August":
20 it = di.item_append(m) 29 it = di.item_append(m)
@@ -22,109 +31,84 @@ def disk_create(win, rnd):
22 di.item_append(m) 31 di.item_append(m)
23 32
24 it.selected = True 33 it.selected = True
25 di.round_enabled = rnd
26 34
27 return di 35 return di
28 36
29def cb_sel(ds, item): 37def cb_sel(ds, item):
30 print(("Selected item: %s" % (item.text.encode("UTF-8")))) 38 print("Selected item: " + item.text.encode("utf-8"))
31 39
32 40
33def diskselector_clicked(obj): 41def diskselector_clicked(obj):
34 win = Window("diskselector", elementary.ELM_WIN_BASIC) 42 win = StandardWindow("diskselector", "Diskselector test", autodel=True,
35 win.title = "Diskselector test" 43 size=(320, 480))
36 win.autodel = True
37 if obj is None: 44 if obj is None:
38 win.callback_delete_request_add(lambda o: elementary.exit()) 45 win.callback_delete_request_add(lambda o: elementary.exit())
39 46
40 bg = Background(win) 47 vbox = Box(win, size_hint_weight=EXPAND_BOTH)
41 win.resize_object_add(bg)
42 bg.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
43 bg.show()
44
45 vbox = Box(win)
46 vbox.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
47 win.resize_object_add(vbox) 48 win.resize_object_add(vbox)
48 vbox.show() 49 vbox.show()
49 50
50 di = disk_create(win, True) 51 di = disk_create(win, rnd=True, size_hint_weight=EXPAND_BOTH,
51 di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 52 size_hint_align=FILL_HORIZ)
52 di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
53 di.callback_selected_add(cb_sel) 53 di.callback_selected_add(cb_sel)
54 vbox.pack_end(di) 54 vbox.pack_end(di)
55 di.show() 55 di.show()
56 di.first_item.selected = True 56 di.first_item.selected = True
57 57
58 di = disk_create(win, False) 58 di = disk_create(win, rnd=False, size_hint_weight=EXPAND_BOTH,
59 di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 59 size_hint_align=FILL_HORIZ)
60 di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
61 di.callback_selected_add(cb_sel) 60 di.callback_selected_add(cb_sel)
62 vbox.pack_end(di) 61 vbox.pack_end(di)
63 di.show() 62 di.show()
64 di.first_item.next.selected = True 63 di.first_item.next.selected = True
65 64
66 di = disk_create(win, False) 65 di = disk_create(win, rnd=False, size_hint_weight=EXPAND_BOTH,
67 di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 66 size_hint_align=FILL_HORIZ, side_text_max_length=4)
68 di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
69 di.callback_selected_add(cb_sel) 67 di.callback_selected_add(cb_sel)
70 vbox.pack_end(di) 68 vbox.pack_end(di)
71 di.show() 69 di.show()
72 di.side_text_max_length = 4
73 70
74 ic = Icon(win) 71 ic = Icon(win, file=ic_file)
75 ic.file = "images/logo_small.png" 72 di = Diskselector(win, size_hint_weight=EXPAND_BOTH,
76 di = Diskselector(win) 73 size_hint_align=FILL_HORIZ)
77 di.item_append("Sunday", ic) 74 di.item_append("Sunday", ic)
78 for day in weekdays: 75 for day in weekdays:
79 di.item_append(day) 76 di.item_append(day)
80 di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
81 di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
82 di.callback_selected_add(cb_sel) 77 di.callback_selected_add(cb_sel)
83 vbox.pack_end(di) 78 vbox.pack_end(di)
84 di.show() 79 di.show()
85 80
86 ic = Icon(win) 81 ic = Icon(win, file=ic_file)
87 ic.file = "images/logo_small.png" 82 di = Diskselector(win, round_enabled=True, size_hint_weight=EXPAND_BOTH,
88 di = Diskselector(win) 83 size_hint_align=FILL_HORIZ)
89 di.item_append("머리스타일", ic) 84 di.item_append("머리스타일", ic)
90 for lan in ["プロが伝授する", "生上访要求政府", "English", "والشريعة", "עִבְרִית", "Grüßen"]: 85 for lan in ["プロが伝授する", "生上访要求政府", "English", "والشريعة", "עִבְרִית", "Grüßen"]:
91 di.item_append(lan) 86 di.item_append(lan)
92 di.round_enabled = True
93 di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
94 di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
95 di.callback_selected_add(cb_sel) 87 di.callback_selected_add(cb_sel)
96 vbox.pack_end(di) 88 vbox.pack_end(di)
97 di.show() 89 di.show()
98 90
99 di = Diskselector(win) 91 di = Diskselector(win, display_item_num=5, round_enabled=True,
100 di.display_item_num = 5 92 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ)
101 for m in months_short: 93 for m in months_short:
102 di.item_append(m) 94 di.item_append(m)
103 di.round_enabled = True
104 di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
105 di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
106 di.callback_selected_add(cb_sel) 95 di.callback_selected_add(cb_sel)
107 vbox.pack_end(di) 96 vbox.pack_end(di)
108 di.show() 97 di.show()
109 di.last_item.selected = True 98 di.last_item.selected = True
110 99
111 di = Diskselector(win) 100 di = Diskselector(win, display_item_num=7, round_enabled=True,
101 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ)
112 di.display_item_num = 7 102 di.display_item_num = 7
113 for i in range(31): 103 for i in range(31):
114 di.item_append(str(i)) 104 di.item_append(str(i))
115 di.round_enabled = True
116 di.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
117 di.size_hint_align = (evas.EVAS_HINT_FILL, 0.5)
118 di.callback_selected_add(cb_sel) 105 di.callback_selected_add(cb_sel)
119 vbox.pack_end(di) 106 vbox.pack_end(di)
120 di.show() 107 di.show()
121 di.last_item.selected = True 108 di.last_item.selected = True
122 109
123
124 win.resize(320, 480)
125 win.show() 110 win.show()
126 111
127
128if __name__ == "__main__": 112if __name__ == "__main__":
129 elementary.init() 113 elementary.init()
130 114