summaryrefslogtreecommitdiff
path: root/examples/elementary/test_spinner.py
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2013-11-03 10:42:50 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2013-11-03 10:42:50 +0200
commitcf1f98bbf611ad14662254988a48529cfedcf49c (patch)
tree870be59a45571058abf7d380dbf6ecc359ad5748 /examples/elementary/test_spinner.py
parent23e9d4920875906c7f90fb4a8dd91c68e9522c07 (diff)
Elementary: Improve the rest of the examples.
Summary of changes: - Make use of constructor keyword args - Most scripts are now working directory agnostic - Enabled evas textgrid example - Printed messages are slightly better formatted
Diffstat (limited to 'examples/elementary/test_spinner.py')
-rw-r--r--examples/elementary/test_spinner.py87
1 files changed, 29 insertions, 58 deletions
diff --git a/examples/elementary/test_spinner.py b/examples/elementary/test_spinner.py
index 323227d..0c88b84 100644
--- a/examples/elementary/test_spinner.py
+++ b/examples/elementary/test_spinner.py
@@ -1,88 +1,61 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2# encoding: utf-8 2# encoding: utf-8
3 3
4from efl import evas 4from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
5from efl import elementary 5from efl import elementary
6from efl.elementary.window import Window 6from efl.elementary.window import StandardWindow
7from efl.elementary.background import Background
8from efl.elementary.box import Box 7from efl.elementary.box import Box
9from efl.elementary.spinner import Spinner 8from efl.elementary.spinner import Spinner
10 9
10EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
11EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
12FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
13FILL_HORIZ = EVAS_HINT_FILL, 0.5
11 14
12def spinner_clicked(obj): 15def spinner_clicked(obj):
13 win = Window("spinner", elementary.ELM_WIN_BASIC) 16 win = StandardWindow("spinner", "Spinner test", autodel=True,
14 win.title_set("Spinner test") 17 size=(300, 300))
15 win.autodel_set(True)
16 if obj is None: 18 if obj is None:
17 win.callback_delete_request_add(lambda o: elementary.exit()) 19 win.callback_delete_request_add(lambda o: elementary.exit())
18 20
19 bg = Background(win) 21 bx = Box(win, size_hint_weight=EXPAND_BOTH)
20 win.resize_object_add(bg)
21 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
22 bg.show()
23
24 bx = Box(win)
25 bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
26 win.resize_object_add(bx) 22 win.resize_object_add(bx)
27 bx.show() 23 bx.show()
28 24
29 sp = Spinner(win) 25 sp = Spinner(win, editable=True, label_format="%1.1f units", step=1.3,
30 sp.editable = True 26 wrap=True, min_max=(-50.0, 250.0), size_hint_weight=EXPAND_BOTH,
31 sp.label_format = "%1.1f units" 27 size_hint_align=FILL_HORIZ)
32 sp.step = 1.3
33 sp.wrap = True
34 sp.min_max = -50.0, 250.0
35 sp.size_hint_align = evas.EVAS_HINT_FILL, 0.5
36 sp.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
37 bx.pack_end(sp) 28 bx.pack_end(sp)
38 sp.show() 29 sp.show()
39 30
40 sp = Spinner(win) 31 sp = Spinner(win, label_format="Base 5.5, Round 2 : %1.1f",
41 sp.label_format = "Base 5.5, Round 2 : %1.1f" 32 min_max=(-100.0, 100.0), round=2, base=5.5, value=5.5,
42 sp.min_max = -100.0, 100.0 33 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ)
43 sp.round = 2
44 sp.base = 5.5
45 sp.value = 5.5
46 sp.size_hint_align = evas.EVAS_HINT_FILL, 0.5
47 sp.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
48 bx.pack_end(sp) 34 bx.pack_end(sp)
49 sp.show() 35 sp.show()
50 36
51 sp = Spinner(win) 37 sp = Spinner(win, label_format="Percentage %%%1.2f something",
52 sp.label_format = "Percentage %%%1.2f something" 38 step=5.0, min_max=(0.0, 100.0), size_hint_weight=EXPAND_BOTH,
53 sp.step = 5.0 39 size_hint_align=FILL_HORIZ)
54 sp.min_max = 0.0, 100.0
55 sp.size_hint_align = evas.EVAS_HINT_FILL, 0.5
56 sp.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
57 bx.pack_end(sp) 40 bx.pack_end(sp)
58 sp.show() 41 sp.show()
59 42
60 sp = Spinner(win) 43 sp = Spinner(win, label_format="%1.1f units", step=1.3, wrap=True,
61 sp.label_format = "%1.1f units" 44 style="vertical", min_max=(-50.0, 250.0), size_hint_weight=EXPAND_BOTH,
62 sp.step = 1.3 45 size_hint_align=FILL_HORIZ)
63 sp.wrap = True
64 sp.style = "vertical"
65 sp.min_max = -50.0, 250.0
66 sp.size_hint_align = evas.EVAS_HINT_FILL, 0.5
67 sp.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
68 bx.pack_end(sp) 46 bx.pack_end(sp)
69 sp.show() 47 sp.show()
70 48
71 sp = Spinner(win) 49 sp = Spinner(win, label_format="Disabled %.0f", disabled=True,
72 sp.label_format = "Disabled %.0f" 50 min_max=(-50.0, 250.0), size_hint_weight=EXPAND_BOTH,
73 sp.disabled = True 51 size_hint_align=FILL_HORIZ)
74 sp.min_max = -50.0, 250.0
75 sp.size_hint_align = evas.EVAS_HINT_FILL, 0.5
76 sp.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
77 bx.pack_end(sp) 52 bx.pack_end(sp)
78 sp.show() 53 sp.show()
79 54
80 sp = Spinner(win) 55 sp = Spinner(win, wrap=True, min_max=(1, 12), value=1,
81 sp.wrap = True 56 label_format="%.0f", editable=False, size_hint_weight=EXPAND_BOTH,
82 sp.min_max = 1, 12 57 size_hint_align=FILL_HORIZ)
83 sp.value = 1 58
84 sp.label_format = "%.0f"
85 sp.editable = False
86 sp.special_value_add(1, "January") 59 sp.special_value_add(1, "January")
87 sp.special_value_add(2, "February") 60 sp.special_value_add(2, "February")
88 sp.special_value_add(3, "March") 61 sp.special_value_add(3, "March")
@@ -95,12 +68,10 @@ def spinner_clicked(obj):
95 sp.special_value_add(10, "October") 68 sp.special_value_add(10, "October")
96 sp.special_value_add(11, "November") 69 sp.special_value_add(11, "November")
97 sp.special_value_add(12, "December") 70 sp.special_value_add(12, "December")
98 sp.size_hint_align = evas.EVAS_HINT_FILL, 0.5 71
99 sp.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
100 bx.pack_end(sp) 72 bx.pack_end(sp)
101 sp.show() 73 sp.show()
102 74
103 win.resize(300, 300)
104 win.show() 75 win.show()
105 76
106if __name__ == "__main__": 77if __name__ == "__main__":