aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test_external.py
blob: 97da8b7e1ec5521e1f73d3c1875bb7f3e40fbfaa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env python
# encoding: utf-8

from efl import evas
from efl import ecore
from efl import elementary
from efl.elementary.window import Window
from efl.elementary.background import Background
from efl.elementary.layout import Layout
from efl.elementary.box import Box
from efl.elementary.frame import Frame
from efl.elementary.label import Label
from efl.elementary.list import List


def edje_external_button_clicked(obj, item=None):
    win = Window("edje-external-button", elementary.ELM_WIN_BASIC)
    win.title_set("Edje External Button")
    win.autodel_set(True)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    ly = Layout(win)
    ly.file_set("test_external.edj", "external/button")
    ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    win.resize_object_add(ly)
    ly.show()

    win.resize(320, 400)
    win.show()


def animate(ly):
    val = ly.edje_get().part_external_object_get("ext_pbar1").value
    val += 0.0123

    for part_name in ["ext_pbar1", "ext_pbar3", "ext_pbar4", "ext_pbar6"]:
        ly.edje_get().part_external_object_get(part_name).value = val

    if val < 1:
        ecore.timer_add(0.1, animate, ly)
    else:
        for part_name in ["ext_pbar2", "ext_pbar5", "ext_pbar7"]:
            ly.edje_get().part_external_object_get(part_name).pulse(False)
        for part_name in ["ext_button1", "ext_button2", "ext_button3"]:
            ly.edje_get().part_external_object_get(part_name).disabled = False

    return False

def cb_btn3_clicked(bt, ly):
    ly.edje_get().part_external_object_get("ext_pbar1").value = 0.0

    for part_name in ["ext_pbar2", "ext_pbar5", "ext_pbar7"]:
        ly.edje_get().part_external_object_get(part_name).pulse(True)
    for part_name in ["ext_button1", "ext_button2", "ext_button3"]:
        ly.edje_get().part_external_object_get(part_name).disabled = True

    ecore.timer_add(0.1, animate, ly)

def edje_external_pbar_clicked(obj, item=None):
    win = Window("edje-external-pbar", elementary.ELM_WIN_BASIC)
    win.title_set("Edje External Progress Bar")
    win.autodel_set(True)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    ly = Layout(win)
    ly.file_set("test_external.edj", "external/pbar")
    ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    win.resize_object_add(ly)
    ly.show()

    bt = ly.edje_get().part_external_object_get("ext_button3")
    bt.text = "...or from Python"
    bt.callback_clicked_add(cb_btn3_clicked, ly)

    win.resize(320, 400)
    win.show()


def edje_external_scroller_clicked(obj, item=None):
    win = Window("edje-external-scroller", elementary.ELM_WIN_BASIC)
    win.title_set("Edje External Scroller")
    win.autodel_set(True)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    ly = Layout(win)
    ly.file_set("test_external.edj", "external/scroller")
    ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    win.resize_object_add(ly)
    ly.show()

    win.resize(320, 400)
    win.show()


def edje_external_slider_clicked(obj, item=None):
    win = Window("edje-external-slider", elementary.ELM_WIN_BASIC)
    win.title_set("Edje External Slider")
    win.autodel_set(True)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    ly = Layout(win)
    ly.file_set("test_external.edj", "external/slider")
    ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    win.resize_object_add(ly)
    ly.show()

    win.resize(320, 400)
    win.show()


def edje_external_video_clicked(obj, item=None):
    win = Window("edje-external-video", elementary.ELM_WIN_BASIC)
    win.title_set("Edje External Video")
    win.autodel_set(True)
    if obj is None:
        win.callback_delete_request_add(lambda o: elementary.exit())

    ly = Layout(win)
    ly.file_set("test_external.edj", "external/video")
    ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    win.resize_object_add(ly)
    ly.show()

    win.resize(320, 400)
    win.show()



if __name__ == "__main__":
    def destroy(obj):
        elementary.exit()

    elementary.init()
    win = Window("test", elementary.ELM_WIN_BASIC)
    win.title_set("python-elementary test application")
    win.callback_delete_request_add(destroy)

    bg = Background(win)
    win.resize_object_add(bg)
    bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    bg.show()

    box0 = Box(win)
    box0.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    win.resize_object_add(box0)
    box0.show()

    fr = Frame(win)
    fr.text_set("Information")
    box0.pack_end(fr)
    fr.show()

    lb = Label(win)
    lb.text_set("Please select a test from the list below<br>"
                 "by clicking the test button to show the<br>"
                 "test window.")
    fr.content_set(lb)
    lb.show()

    items = [("Ext Button", edje_external_button_clicked),
            ("Ext ProgressBar", edje_external_pbar_clicked),
            ("Ext Scroller", edje_external_scroller_clicked),
            ("Ext Slider", edje_external_slider_clicked),
            ("Ext Video", edje_external_video_clicked)]
 
    li = List(win)
    li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    li.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    box0.pack_end(li)
    li.show()

    for item in items:
        li.item_append(item[0], callback=item[1])

    li.go()

    win.resize(320,520)
    win.show()
    elementary.run()
    elementary.shutdown()
    ecore.shutdown()
    evas.shutdown()