aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test.py
blob: f6f6e3973b427728f372f6be69773a0205e7c39d (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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#!/usr/bin/env python
# encoding: utf-8

import os

from efl import evas
from efl import elementary
from efl.elementary.window import Window
from efl.elementary.background import Background
from efl.elementary.box import Box
from efl.elementary.button import Button
from efl.elementary.frame import Frame
from efl.elementary.label import Label
from efl.elementary.check import Check
from efl.elementary.entry import Entry
from efl.elementary.scroller import Scroller


from test_3d import evas3d_clicked
from test_actionslider import actionslider_clicked
from test_bg import bg_plain_clicked, bg_image_clicked
from test_box import box_vert_clicked, box_vert2_clicked, box_horiz_clicked
from test_box import box_layout_clicked, box_transition_clicked
from test_bubble import bubble_clicked
from test_button import buttons_clicked
from test_calendar import calendar_clicked
from test_check import check_clicked
from test_clock import clock_clicked
from test_colorselector import colorselector_clicked
from test_config import config_clicked
from test_conform import conformant_clicked, conformant2_clicked
from test_core_evas_object_callbacks import core_evas_object_callbacks_clicked
from test_core_evas_canvas_callbacks import core_evas_canvas_callbacks_clicked
from test_core_evas_objects import core_evas_objects_clicked
from test_ctxpopup import ctxpopup_clicked
from test_cursor import cursor_clicked, cursor2_clicked, cursor3_clicked
from test_datetime import datetime_clicked
from test_dayselector import dayselector_clicked
from test_diskselector import diskselector_clicked
from test_entry import entry_clicked, entry_scrolled_clicked, entry_anchor_clicked
from test_external import edje_external_button_clicked, edje_external_pbar_clicked, \
    edje_external_scroller_clicked, edje_external_slider_clicked, edje_external_video_clicked
from test_fileselector import fileselector_clicked, fileselector_button_clicked, \
    fileselector_entry_clicked
from test_flip import flip_clicked, flip_interactive_clicked
from test_flipselector import flipselector_clicked
from test_floating import floating_clicked
from test_frame import frame_clicked
from test_gengrid import gengrid_clicked
from test_genlist import genlist_clicked, genlist2_clicked, genlist3_clicked, \
    genlist4_clicked, genlist5_clicked, genlist10_clicked, genlist15_clicked
from test_grid import grid_clicked
from test_hover import hover_clicked, hover2_clicked
from test_hoversel import hoversel_clicked
from test_icon import icon_clicked, icon_transparent_clicked
from test_index import index_clicked
from test_inwin import inner_window_clicked
from test_label import label_clicked
from test_layout import layout_clicked
from test_list import list_clicked, list2_clicked, list3_clicked
from test_mapbuf import mapbuf_clicked
from test_map import map_clicked
from test_map2 import map_overlays_clicked
from test_map3 import map_route_clicked
from test_menu import menu_clicked
from test_multibuttonentry import multibuttonentry_clicked
from test_naviframe import naviframe_clicked
from test_notify import notify_clicked
from test_panel import panel_clicked
from test_panes import panes_clicked
from test_photo import photo_clicked
from test_popup import popup_clicked
from test_progressbar import progressbar_clicked
from test_radio import radio_clicked
from test_scroller import scroller_clicked
from test_segment_control import segment_control_clicked
from test_separator import separator_clicked
from test_slideshow import slideshow_clicked
from test_spinner import spinner_clicked
from test_table import table_clicked
from test_thumb import thumb_clicked
from test_toolbar import toolbar_clicked
from test_tooltip import tooltip_clicked
from test_video import video_clicked
from test_web import web_clicked
from test_win import window_states_clicked


items = [
         ("Core Libs", [
            ("Evas Objects", core_evas_objects_clicked),
            ("Evas Canvas Callbacks", core_evas_canvas_callbacks_clicked),
            ("Evas Object Callbacks", core_evas_object_callbacks_clicked),
         ]),
         ("3D", [
            ("Evas Map 3D", evas3d_clicked),
         ]),
         ("Booleans", [
            ("Checks", check_clicked),
            # ("Toggles", toggles_clicked),TODO make a toggle with check
        ]),
         ("Boundaries", [
            ("Bubble", bubble_clicked),
            ("Separator", separator_clicked),
        ]),
         ("Buttons", [
            ("Buttons", buttons_clicked),
        ]),
         ("Containers", [
            ("Box Horiz", box_horiz_clicked),
            ("Box Vert", box_vert_clicked),
            ("Box Vert2", box_vert2_clicked),
            ("Box Layout", box_layout_clicked),
            ("Box Layout Transition", box_transition_clicked),
            ("Table", table_clicked),
            ("Layout", layout_clicked),
            ("Grid", grid_clicked),
            ("Frame", frame_clicked),
        ]),
         ("Cursors", [
            ("Cursor", cursor_clicked),
            ("Cursor2", cursor2_clicked),
            ("Cursor3", cursor3_clicked),
        ]),
         ("Dividers", [
            ("Panel", panel_clicked),
            ("Panes", panes_clicked),
        ]),
         ("Effects", [
            ("Flip", flip_clicked),
            ("Flip Interactive", flip_interactive_clicked),
        ]),
         ("Entries", [
            ("Entry", entry_clicked),
            ("Entry Scrolled", entry_scrolled_clicked),
            ("Entry Anchor", entry_anchor_clicked),
            ("MultiButtonEntry", multibuttonentry_clicked),
        ]),
         ("Edje External", [
            ("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),
        ]),
         ("Geographic", [
            ("Map", map_clicked),
            ("Map Overlay", map_overlays_clicked),
            ("Map Route", map_route_clicked),
        ]),
         ("Images", [
            ("Icon", icon_clicked),
            ("Icon Transparent", icon_transparent_clicked),
            ("Photo", photo_clicked),
            ("Slideshow", slideshow_clicked),
            ("Thumb", thumb_clicked),
            ("Video", video_clicked),
        ]),
         ("Lists", [
            ("List", list_clicked),
            ("List 2", list2_clicked),
            ("List 3", list3_clicked),
            ("Genlist", genlist_clicked),
            ("Genlist 2", genlist2_clicked),
            ("Genlist Group", genlist3_clicked),
            ("Genlist Sorted", genlist4_clicked),
            ("Genlist Iteration", genlist5_clicked),
            ("Genlist Decorate Item Mode", genlist10_clicked),
            ("Genlist Decorate All Mode", genlist15_clicked),
            ("Gengrid", gengrid_clicked),
        ]),
         ("Miscellaneous", [
            ("Configuration", config_clicked),
            ("Floating Objects", floating_clicked),
        ]),
         ("Naviframe", [
            ("Naviframe", naviframe_clicked),
        ]),
         ("Popups", [
            ("Hover", hover_clicked),
            ("Hover 2", hover2_clicked),
            ("Notify", notify_clicked),
            ("Tooltip", tooltip_clicked),
            ("Ctxpopup", ctxpopup_clicked),
            ("Popup", popup_clicked),
        ]),
         ("Range Values", [
            ("Spinner", spinner_clicked),
            ("Progressbar", progressbar_clicked),
        ]),
         ("Scroller", [
            ("Scroller", scroller_clicked),
        ]),
         ("Selectors", [
            ("Action Slider", actionslider_clicked),
            ("Color Selector", colorselector_clicked),
            ("Day Selector", dayselector_clicked),
            ("Disk Selector", diskselector_clicked),
            ("Flip Selector", flipselector_clicked),
            ("File Selector", fileselector_clicked),
            ("Fileselector button", fileselector_button_clicked),
            ("Fileselector entry", fileselector_entry_clicked),
            ("Hoversel", hoversel_clicked),
            ("Index", index_clicked),
            ("Menu", menu_clicked),
            ("Radios", radio_clicked),
            ("Segment Control", segment_control_clicked),
        ]),
         ("Standardization", [
            ("Conformant", conformant_clicked),
            ("Conformant 2", conformant2_clicked),
        ]),
         ("Stored Surface Buffer", [
            ("Launcher", mapbuf_clicked),
        ]),
         ("Text", [
            ("Label", label_clicked),
        ]),
         ("Times & Dates", [
            ("Calendar", calendar_clicked),
            ("Clock", clock_clicked),
            ("Datetime", datetime_clicked),
        ]),
        ("Toolbars", [
            ("Toolbar", toolbar_clicked),
        ]),
         ("Web", [
            ("Web", web_clicked),
        ]),
         ("Window / Background", [
            ("Bg Plain", bg_plain_clicked),
            ("Bg Image", bg_image_clicked),
            ("InnerWindow", inner_window_clicked),
            ("Window States", window_states_clicked),
        ])
        ]


def menu_create(search, win):
    tbx.clear()
    for category in items:
        frame = Frame(win)
        frame.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
        frame.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
        frame.text = category[0]
        frame.show()
        tbx.pack_end(frame)

        tbx2 = Box(win)
        tbx2.layout_set(elementary.ELM_BOX_LAYOUT_FLOW_HORIZONTAL)
        tbx2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
        tbx2.size_hint_align_set(evas.EVAS_HINT_FILL, 0.0)
        frame.content_set(tbx2)
        tbx2.show()

        cnt = 0
        for test in category[1]:
            if (search == None) or (test[0].lower().find(search.lower()) > -1):
                bt = Button(win)
                bt.text = test[0]
                bt.callback_clicked_add(test[1])
                bt.show()
                tbx2.pack_end(bt)
                cnt += 1

        if cnt < 1:
            frame.delete()

def destroy(obj, str1, str2, str3, str4):
    print("DEBUG: window destroy callback called!")
    print(("DEBUG: str1='%s', str2='%s', str3='%s', str4='%s'" %(str1, str2,
                                                                str3, str4)))
    elementary.exit()

def cb_mirroring(toggle):
    elementary.Configuration().mirrored = toggle.state

def cb_filter(en, win):
    menu_create(en.text_get(), win)

if __name__ == "__main__":
    elementary.init()
    win = Window("test", elementary.ELM_WIN_BASIC)
    win.title_set("python-elementary test application")
    win.callback_delete_request_add(destroy, "test1", "test2", str3="test3", str4="test4")

    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()

    tg = Check(win)
    tg.style = "toggle"
    tg.text = "UI-Mirroring:"
    tg.callback_changed_add(cb_mirroring)
    box0.pack_end(tg)
    tg.show()

    bx1 = Box(win)
    bx1.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
    bx1.size_hint_align_set(evas.EVAS_HINT_FILL, 0.0)
    bx1.horizontal_set(True)
    box0.pack_end(bx1)
    bx1.show()

    lb = Label(win)
    lb.text_set("Filter:")
    bx1.pack_end(lb)
    lb.show()

    en = Entry(win)
    en.single_line_set(True)
    en.scrollable_set(True)
    en.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    en.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    en.callback_changed_add(cb_filter, win)
    bx1.pack_end(en)
    en.show()
    en.focus_set(True)

    sc = Scroller(win)
    sc.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
    sc.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
    sc.bounce_set(False, True)
    sc.show()
    box0.pack_end(sc)

    tbx = Box(win)
    tbx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
    tbx.size_hint_align_set(evas.EVAS_HINT_FILL, 0.0)
    sc.content_set(tbx)
    tbx.show()

    menu_create(None, win)

    win.resize(320, 480)
    win.show()
    elementary.run()
    elementary.shutdown()