summaryrefslogtreecommitdiff
path: root/examples/elementary/test_win.py
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2015-01-23 20:07:50 +0100
committerDave Andreoli <dave@gurumeditation.it>2015-01-23 20:07:50 +0100
commit6ac80225fbb2e6d66fd6af808b9d9dc0ea858ec0 (patch)
treeb26a10c541c53c0db7c3e7cfda912b53624c418f /examples/elementary/test_win.py
parentd4572bf26ac625af9663de6cb8f50b3d0fac0a05 (diff)
Improve a bit the Window test
Diffstat (limited to 'examples/elementary/test_win.py')
-rw-r--r--examples/elementary/test_win.py110
1 files changed, 83 insertions, 27 deletions
diff --git a/examples/elementary/test_win.py b/examples/elementary/test_win.py
index 8e2ca76..ad87b3c 100644
--- a/examples/elementary/test_win.py
+++ b/examples/elementary/test_win.py
@@ -1,8 +1,9 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2# encoding: utf-8 2# encoding: utf-8
3 3
4from efl.ecore import Timer
4from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, \ 5from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, \
5 EXPAND_BOTH, FILL_BOTH, EXPAND_HORIZ, FILL_HORIZ 6 EXPAND_BOTH, FILL_BOTH, EXPAND_HORIZ, FILL_HORIZ, FILL_VERT
6from efl import elementary 7from efl import elementary
7from efl.elementary.window import Window, ELM_WIN_BASIC 8from efl.elementary.window import Window, ELM_WIN_BASIC
8from efl.elementary.background import Background 9from efl.elementary.background import Background
@@ -12,15 +13,10 @@ from efl.elementary.check import Check
12from efl.elementary.slider import Slider 13from efl.elementary.slider import Slider
13 14
14 15
15def cb_alpha(bt, win, bg, on): 16def cb_alpha(ck, win, bg):
16 win.alpha = on 17 win.alpha = ck.state
17 print("alpha: %s" % win.alpha) 18 print("alpha: %s" % win.alpha)
18 19 bg.hide() if ck.state is True else bg.show()
19 bg.hide() if on else bg.show()
20
21def cb_fullscreen(bt, win, fs):
22 win.fullscreen = fs
23 print("fullscreen: %s" % win.fullscreen)
24 20
25def cb_rot(bt, win, ck, rot): 21def cb_rot(bt, win, ck, rot):
26 if ck.state: 22 if ck.state:
@@ -28,12 +24,20 @@ def cb_rot(bt, win, ck, rot):
28 else: 24 else:
29 win.rotation = rot 25 win.rotation = rot
30 26
27def cb_iconify_and_activate(bt, win):
28 win.iconified = True
29 Timer(3.0, lambda: win.activate())
30
31def cb_iconify_and_deiconify(bt, win):
32 win.iconified = True
33 Timer(3.0, lambda: win.iconified_set(False))
34
31def cb_win_moved(win): 35def cb_win_moved(win):
32 print("MOVE - win geom: x %d, y %d, w %d, h %d" % win.geometry) 36 print("MOVE - win geom: x %d, y %d, w %d, h %d" % win.geometry)
33 37
34def window_states_clicked(obj): 38def window_states_clicked(obj):
35 win = Window("window-states", ELM_WIN_BASIC, 39 win = Window("window-states", ELM_WIN_BASIC, autodel=True,
36 title="Window States test", autodel=True, size=(280, 400)) 40 title="Window States test", size=(280, 400))
37 win.callback_moved_add(cb_win_moved) 41 win.callback_moved_add(cb_win_moved)
38 if obj is None: 42 if obj is None:
39 win.callback_delete_request_add(lambda o: elementary.exit()) 43 win.callback_delete_request_add(lambda o: elementary.exit())
@@ -49,27 +53,79 @@ def window_states_clicked(obj):
49 vbox.show() 53 vbox.show()
50 54
51 hbox = Box(win, horizontal=True, size_hint_align=FILL_HORIZ, 55 hbox = Box(win, horizontal=True, size_hint_align=FILL_HORIZ,
52 size_hint_weight=EXPAND_HORIZ) 56 size_hint_weight=EXPAND_HORIZ)
53 vbox.pack_end(hbox) 57 vbox.pack_end(hbox)
54 hbox.show() 58 hbox.show()
55 59
56 for state in [True, False]: 60 hbox = Box(win, horizontal=True, size_hint_align=FILL_HORIZ,
57 bt = Button(win, text="Alpha " + ("On" if state else "Off"), 61 size_hint_weight=EXPAND_HORIZ)
58 size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) 62 vbox.pack_end(hbox)
59 bt.callback_clicked_add(cb_alpha, win, bg, state) 63 hbox.show()
60 hbox.pack_end(bt)
61 bt.show()
62 64
63 for state in [True, False]: 65 bt = Button(win, text="Lower", size_hint_align=FILL_HORIZ,
64 bt = Button(win, text="FS " + ("On" if state else "Off"), 66 size_hint_weight=EXPAND_HORIZ)
65 size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) 67 bt.callback_clicked_add(lambda b: win.lower())
66 bt.callback_clicked_add(cb_fullscreen, win, state) 68 hbox.pack_end(bt)
67 hbox.pack_end(bt) 69 bt.show()
68 bt.show() 70
71 bt = Button(win, text="Iconify and Activate", size_hint_align=FILL_HORIZ,
72 size_hint_weight=EXPAND_HORIZ)
73 bt.callback_clicked_add(cb_iconify_and_activate, win)
74 hbox.pack_end(bt)
75 bt.show()
76
77 bt = Button(win, text="Iconify and Deiconify", size_hint_align=FILL_HORIZ,
78 size_hint_weight=EXPAND_HORIZ)
79 bt.callback_clicked_add(cb_iconify_and_deiconify, win)
80 hbox.pack_end(bt)
81 bt.show()
82
83 hbox = Box(win, horizontal=True, size_hint_align=FILL_HORIZ,
84 size_hint_weight=EXPAND_HORIZ)
85 vbox.pack_end(hbox)
86 hbox.show()
87
88 bt = Button(win, text="Move 0 0", size_hint_align=FILL_HORIZ,
89 size_hint_weight=EXPAND_HORIZ)
90 bt.callback_clicked_add(lambda b: win.move(0,0))
91 hbox.pack_end(bt)
92 bt.show()
93
94 bt = Button(win, text="Move 20 20", size_hint_align=FILL_HORIZ,
95 size_hint_weight=EXPAND_HORIZ)
96 bt.callback_clicked_add(lambda b: win.move(20,20))
97 hbox.pack_end(bt)
98 bt.show()
99
100 bt = Button(win, text="Center", size_hint_align=FILL_HORIZ,
101 size_hint_weight=EXPAND_HORIZ)
102 bt.callback_clicked_add(lambda b: win.center(True, True))
103 hbox.pack_end(bt)
104 bt.show()
105
106 hbox = Box(win, horizontal=True, size_hint_align=FILL_HORIZ,
107 size_hint_weight=EXPAND_HORIZ)
108 vbox.pack_end(hbox)
109 hbox.show()
110
111 ck = Check(win, text="Alpha")
112 ck.callback_changed_add(cb_alpha, win, bg)
113 hbox.pack_end(ck)
114 ck.show()
115
116 ck = Check(win, text="Borderless")
117 ck.callback_changed_add(lambda c: win.borderless_set(c.state))
118 hbox.pack_end(ck)
119 ck.show()
120
121 ck = Check(win, text="Fullscreen")
122 ck.callback_changed_add(lambda c: win.fullscreen_set(c.state))
123 hbox.pack_end(ck)
124 ck.show()
69 125
70 sl = Slider(win, text="Visual test", indicator_format="%3.0f", 126 sl = Slider(win, text="Visual test", indicator_format="%3.0f",
71 min_max=(50, 150), value=50, inverted=True, 127 min_max=(50, 150), value=50, inverted=True,
72 size_hint_weight=EXPAND_BOTH, size_hint_align=(0.5, EVAS_HINT_FILL)) 128 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ)
73 vbox.pack_end(sl) 129 vbox.pack_end(sl)
74 sl.show() 130 sl.show()
75 131
@@ -84,7 +140,7 @@ def window_states_clicked(obj):
84 140
85 for rot in [0, 90, 180, 270]: 141 for rot in [0, 90, 180, 270]:
86 bt = Button(win, text="Rot " + str(rot), size_hint_align=FILL_HORIZ, 142 bt = Button(win, text="Rot " + str(rot), size_hint_align=FILL_HORIZ,
87 size_hint_weight=EXPAND_HORIZ) 143 size_hint_weight=EXPAND_HORIZ)
88 bt.callback_clicked_add(cb_rot, win, ck, rot) 144 bt.callback_clicked_add(cb_rot, win, ck, rot)
89 hbox.pack_end(bt) 145 hbox.pack_end(bt)
90 bt.show() 146 bt.show()