summaryrefslogtreecommitdiff
path: root/examples/elementary/test_win.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_win.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_win.py')
-rw-r--r--examples/elementary/test_win.py75
1 files changed, 27 insertions, 48 deletions
diff --git a/examples/elementary/test_win.py b/examples/elementary/test_win.py
index d1527af..366664d 100644
--- a/examples/elementary/test_win.py
+++ b/examples/elementary/test_win.py
@@ -1,25 +1,25 @@
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 ecore
6from efl import elementary 5from efl import elementary
7from efl.elementary.window import Window 6from efl.elementary.window import Window, ELM_WIN_BASIC
8from efl.elementary.background import Background 7from efl.elementary.background import Background
9from efl.elementary.box import Box 8from efl.elementary.box import Box
10from efl.elementary.button import Button 9from efl.elementary.button import Button
11from efl.elementary.check import Check 10from efl.elementary.check import Check
12from efl.elementary.slider import Slider 11from efl.elementary.slider import Slider
13 12
14 13EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
14EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
15FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
16FILL_HORIZ = EVAS_HINT_FILL, 0.5
15 17
16def cb_alpha(bt, win, bg, on): 18def cb_alpha(bt, win, bg, on):
17 win.alpha = on 19 win.alpha = on
18 print("alpha: %s" % win.alpha) 20 print("alpha: %s" % win.alpha)
19 if on: 21
20 bg.hide() 22 bg.hide() if on else bg.show()
21 else:
22 bg.show()
23 23
24def cb_fullscreen(bt, win, fs): 24def cb_fullscreen(bt, win, fs):
25 win.fullscreen = fs 25 win.fullscreen = fs
@@ -32,87 +32,66 @@ def cb_rot(bt, win, ck, rot):
32 win.rotation = rot 32 win.rotation = rot
33 33
34def cb_win_moved(win): 34def cb_win_moved(win):
35 print(("MOVE - win geom:", win.geometry)) 35 print("MOVE - win geom: x %d, y %d, w %d, h %d" % win.geometry)
36 36
37def window_states_clicked(obj): 37def window_states_clicked(obj):
38 win = Window("window-states", elementary.ELM_WIN_BASIC) 38 win = Window("window-states", ELM_WIN_BASIC,
39 win.title = "Window States test" 39 title="Window States test", autodel=True, size=(280, 400))
40 win.autodel = True
41 win.callback_moved_add(cb_win_moved) 40 win.callback_moved_add(cb_win_moved)
42 if obj is None: 41 if obj is None:
43 win.callback_delete_request_add(lambda o: elementary.exit()) 42 win.callback_delete_request_add(lambda o: elementary.exit())
44 43
45 print(win.available_profiles) 44 print(win.available_profiles)
46 45
47 bg = Background(win) 46 bg = Background(win, size_hint_weight=EXPAND_BOTH)
48 win.resize_object_add(bg) 47 win.resize_object_add(bg)
49 bg.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
50 bg.show() 48 bg.show()
51 49
52 vbox = Box(win) 50 vbox = Box(win, size_hint_weight=EXPAND_BOTH)
53 vbox.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
54 win.resize_object_add(vbox) 51 win.resize_object_add(vbox)
55 vbox.show() 52 vbox.show()
56 53
57 hbox = Box(win) 54 hbox = Box(win, horizontal=True, size_hint_align=FILL_HORIZ,
58 hbox.horizontal = True 55 size_hint_weight=EXPAND_HORIZ)
59 hbox.size_hint_align = (evas.EVAS_HINT_FILL, 0.0)
60 hbox.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
61 vbox.pack_end(hbox) 56 vbox.pack_end(hbox)
62 hbox.show() 57 hbox.show()
63 58
64 for state in [True, False]: 59 for state in [True, False]:
65 bt = Button(win) 60 bt = Button(win, text="Alpha " + ("On" if state else "Off"),
66 bt.text = "Alpha " + ("On" if state else "Off") 61 size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ)
67 bt.size_hint_align = (evas.EVAS_HINT_FILL, 0.0)
68 bt.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
69 bt.callback_clicked_add(cb_alpha, win, bg, state) 62 bt.callback_clicked_add(cb_alpha, win, bg, state)
70 hbox.pack_end(bt) 63 hbox.pack_end(bt)
71 bt.show() 64 bt.show()
72 65
73 for state in [True, False]: 66 for state in [True, False]:
74 bt = Button(win) 67 bt = Button(win, text="FS " + ("On" if state else "Off"),
75 bt.text = "FS " + ("On" if state else "Off") 68 size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ)
76 bt.size_hint_align = (evas.EVAS_HINT_FILL, 0.0)
77 bt.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
78 bt.callback_clicked_add(cb_fullscreen, win, state) 69 bt.callback_clicked_add(cb_fullscreen, win, state)
79 hbox.pack_end(bt) 70 hbox.pack_end(bt)
80 bt.show() 71 bt.show()
81 72
82 sl = Slider(win) 73 sl = Slider(win, text="Visual test", indicator_format="%3.0f",
83 sl.text = "Visual test" 74 min_max=(50, 150), value=50, inverted=True,
84 sl.indicator_format = "%3.0f" 75 size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, EVAS_HINT_FILL))
85 sl.min_max = (50, 150)
86 sl.value = 50
87 sl.inverted = True
88 sl.size_hint_align = (0.5, evas.EVAS_HINT_FILL)
89 sl.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
90 vbox.pack_end(sl) 76 vbox.pack_end(sl)
91 sl.show() 77 sl.show()
92 78
93 ck = Check(win) 79 ck = Check(win, text="Resize on rotate", size_hint_align=(0.0, 0.0))
94 ck.text = "Resize on rotate"
95 ck.size_hint_align = (0.0, 0.0)
96 vbox.pack_end(ck) 80 vbox.pack_end(ck)
97 ck.show() 81 ck.show()
98 82
99 hbox = Box(win) 83 hbox = Box(win, horizontal=True, size_hint_align=FILL_HORIZ,
100 hbox.horizontal = True 84 size_hint_weight=EXPAND_HORIZ)
101 hbox.size_hint_align = (evas.EVAS_HINT_FILL, 0.0)
102 hbox.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
103 vbox.pack_end(hbox) 85 vbox.pack_end(hbox)
104 hbox.show() 86 hbox.show()
105 87
106 for rot in [0, 90, 180, 270]: 88 for rot in [0, 90, 180, 270]:
107 bt = Button(win) 89 bt = Button(win, text="Rot " + str(rot), size_hint_align=FILL_HORIZ,
108 bt.text = "Rot " + str(rot) 90 size_hint_weight=EXPAND_HORIZ)
109 bt.size_hint_align = (evas.EVAS_HINT_FILL, 0.0)
110 bt.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
111 bt.callback_clicked_add(cb_rot, win, ck, rot) 91 bt.callback_clicked_add(cb_rot, win, ck, rot)
112 hbox.pack_end(bt) 92 hbox.pack_end(bt)
113 bt.show() 93 bt.show()
114 94
115 win.resize(280, 400)
116 win.show() 95 win.show()
117 96
118 97