aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test.py
blob: 3c010070d049d46442ca3edb328f0d176eb9e68d (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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#!/usr/bin/env python
# encoding: utf-8

import platform
import logging
elog = logging.getLogger("efl")
elog.setLevel(logging.INFO)

elog_form = logging.Formatter(
    "[%(name)s] %(levelname)s in %(funcName)s:%(lineno)d - %(message)s"
    )
elog_hdlr = logging.StreamHandler()
elog_hdlr.setFormatter(elog_form)

elog.addHandler(elog_hdlr)

eolog = logging.getLogger("efl.eo")
eolog.setLevel(logging.INFO)

evaslog = logging.getLogger("efl.evas")
evaslog.setLevel(logging.INFO)

elmlog = logging.getLogger("efl.elementary")
elmlog.setLevel(logging.INFO)

from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, EXPAND_BOTH, FILL_BOTH
from efl import elementary, __version__
from efl.elementary.window import StandardWindow
from efl.elementary.box import Box, ELM_BOX_LAYOUT_FLOW_HORIZONTAL
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 efl.elementary.configuration import Configuration
elm_conf = Configuration()

elog.setLevel(logging.DEBUG)


items = [
    ("Core Libs", [
        ("Ecore Events In Elm", "test_core_ecore_events_in_elm",
         "core_ecore_events_in_elm_clicked"),
        ("Evas Objects", "test_core_evas_objects", "core_evas_objects_clicked"),
        ("Evas Canvas Callbacks", "test_core_evas_canvas_callbacks",
         "core_evas_canvas_callbacks_clicked"),
        ("Evas Object Callbacks", "test_core_evas_object_callbacks",
         "core_evas_object_callbacks_clicked"),
        ("Evas Textgrid", "test_evas_textgrid", "evas_textgrid_clicked"),
        ("Evas Smart Object","test_core_evas_smart","core_evas_smart_clicked"),
    ]),
    ("3D", [
        ("Evas Map 3D", "test_3d", "evas3d_clicked"),
    ]),
    ("Booleans", [
        ("Check", "test_check", "check_clicked"),
        #TODO: ("Toggle", "test_check", "toggle_clicked"),
    ]),
    ("Boundaries", [
        ("Bubble", "test_bubble", "bubble_clicked"),
        ("Separator", "test_separator", "separator_clicked"),
    ]),
    ("Buttons", [
        ("Button", "test_button", "buttons_clicked"),
    ]),
    ("Containers", [
        ("Box Horiz", "test_box", "box_horiz_clicked"),
        ("Box Vert", "test_box", "box_vert_clicked"),
        ("Box Vert2", "test_box", "box_vert2_clicked"),
        ("Box Layout", "test_box", "box_layout_clicked"),
        ("Box Layout Transition", "test_box", "box_transition_clicked"),
        ("Frame", "test_frame", "frame_clicked"),
        ("Grid", "test_grid", "grid_clicked"),
        ("Layout", "test_layout", "layout_clicked"),
        ("Table", "test_table", "table_clicked"),
        ("Table Homogeneous", "test_table", "table2_clicked"),
        ("Table Repack", "test_table", "table3_clicked"),
        ("Table Repack 2", "test_table", "table4_clicked"),
        ("Table Percent", "test_table", "table5_clicked"),
        ("Table Multi", "test_table", "table6_clicked"),
        ("Table Multi 2", "test_table", "table7_clicked"),
        ("Table Padding", "test_table", "table8_clicked"),
    ]),
    ("Cursors", [
        ("Cursor", "test_cursor", "cursor_clicked"),
        ("Cursor2", "test_cursor", "cursor2_clicked"),
        ("Cursor3", "test_cursor", "cursor3_clicked"),
    ]),
    ("Dividers", [
        ("Panel", "test_panel", "panel_clicked"),
        ("Panel Scrollable", "test_panel_scroll", "panel_scroll_clicked"),
        ("Panes", "test_panes", "panes_clicked"),
    ]),
    # ("Drag & Drop", [
    #     (
    #         "Genlist DnD Default Anim",
    #         "test_dnd",
    #         "dnd_genlist_default_anim_clicked"
    #         ),
    #     (
    #         "Genlist DnD User Anim",
    #         "test_dnd",
    #         "dnd_genlist_user_anim_clicked"
    #         ),
    #     (
    #         "Genlist + Gengrid DnD",
    #         "test_dnd",
    #         "dnd_genlist_gengrid_clicked"
    #         ),
    # ]),
    ("Edje External", [
        ("Ext Button", "test_external", "edje_external_button_clicked"),
        ("Ext ProgressBar", "test_external", "edje_external_pbar_clicked"),
        ("Ext Scroller", "test_external", "edje_external_scroller_clicked"),
        ("Ext Slider", "test_external", "edje_external_slider_clicked"),
        ("Ext Video", "test_external", "edje_external_video_clicked"),
        ("Ext Icon", "test_external", "edje_external_icon_clicked"),
    ]),
    ("Effects", [
        ("Flip", "test_flip", "flip_clicked"),
        ("Flip Interactive", "test_flip", "flip_interactive_clicked"),
        ("Transit", "test_transit", "transit_clicked"),
        ("Transit Resize", "test_transit", "transit2_clicked"),
        ("Transit Flip", "test_transit", "transit3_clicked"),
        ("Transit Zoom", "test_transit", "transit4_clicked"),
        ("Transit Blend", "test_transit", "transit5_clicked"),
        ("Transit Fade", "test_transit", "transit6_clicked"),
        ("Transit Resizable", "test_transit", "transit7_clicked"),
        ("Transit Custom", "test_transit", "transit8_clicked"),
        ("Transit Chain", "test_transit", "transit9_clicked"),
        ("Transit Bezier", "test_transit_bezier", "transit_bezier_clicked"),
    ]),
    ("Entries", [
        ("Entry", "test_entry", "entry_clicked"),
        ("Entry Scrolled", "test_entry", "entry_scrolled_clicked"),
        ("Entry Anchor", "test_entry", "entry_anchor_clicked"),
        ("Entry Notepad", "test_entry", "entry_notepad_clicked"),
        ("MultiButtonEntry","test_multibuttonentry","multibuttonentry_clicked"),
    ]),
    ("Focus", [
        ("Focus", "test_focus", "focus_clicked"),
        ("Focus 2", "test_focus", "focus2_clicked"),
        ("Focus 3", "test_focus", "focus3_clicked"),
        ("Focus 4", "test_focus", "focus4_clicked"),
        ("Focus Custom", "test_focus", "focus5_clicked"),
        ("Focus Move Policy", "test_focus", "focus6_clicked"),
    ]),
    ("Geographic", [
        ("Map", "test_map", "map_clicked"),
    ]),
    ("Images", [
        ("Icon", "test_icon", "icon_clicked"),
        ("Icon Transparent", "test_icon", "icon_transparent_clicked"),
        ("Icon Standard", "test_icon", "icon_standard_clicked"),
        ("Image", "test_image", "test_image"),
        ("Image with memfile", "test_image_memfile", "test_image_memfile"),
        ("Image async load", "test_image_async", "test_image_async"),
        ("Photo", "test_photo", "photo_clicked"),
        ("Photocam", "test_photocam", "photocam_clicked"),
        ("Slideshow", "test_slideshow", "slideshow_clicked"),
        ("Thumb", "test_thumb", "thumb_clicked"),
        ("Video", "test_video", "video_clicked"),
    ]),
    ("Input", [
        ("Input events", "test_input_events", "elm_input_events_clicked"),
        ("Gesture Layer", "test_gesture_layer", "gesture_layer_clicked"),
    ]),
    ("Lists - Gengrid", [
        ("Gengrid", "test_gengrid", "gengrid_clicked"),
    ]),
    ("Lists - Genlist", [
        ("Genlist 1", "test_genlist_1", "test_genlist_1"),
        ("Genlist 2", "test_genlist_2", "test_genlist_2"),
        ("Genlist Multi Select", "test_genlist_multiselect", "test_genlist_multiselect"),
        ("Genlist Tree", "test_genlist_tree", "test_genlist_tree"),
        ("Genlist Group", "test_genlist_group", "test_genlist_group"),
        ("Genlist Filter", "test_genlist_filter", "test_genlist_filter"),
        ("Genlist Sorted", "test_genlist_sorted", "test_genlist_sorted"),
        ("Genlist Iteration", "test_genlist_iteration", "test_genlist_iteration"),
        ("Genlist Decorate Item Mode", "test_genlist_decorate", "test_genlist_decorate"),
        ("Genlist Decorate All Mode", "test_genlist_decorate_all", "test_genlist_decorate_all"),
        ("Genlist Search by Text", "test_genlist_search", "test_genlist_search"),
        ("Genlist Reorder Mode", "test_genlist_reorder", "test_genlist_reorder"),
        ("Genlist Reusable Contents", "test_genlist_reusable", "test_genlist_reusable"),
    ]),
    ("Lists - List", [
        ("List", "test_list", "list_clicked"),
        ("List 2", "test_list", "list2_clicked"),
        ("List 3", "test_list", "list3_clicked"),
    ]),
    ("Miscellaneous", [
        # ("Accessibility", "test_access", "access_clicked"),
        # ("Accessibility 2", "test_access", "access2_clicked"),
        # ("Accessibility 3", "test_access", "access3_clicked"),
        ("Configuration", "test_config", "config_clicked"),
        ("Copy And Paste", "test_cnp", "cnp_clicked"),
        ("Floating Objects", "test_floating", "floating_clicked"),
        ("Themes", "test_theme", "theme_clicked"),
    ]),
    ("Naviframe", [
        ("Naviframe", "test_naviframe", "test_naviframe"),
    ]),
    ("Popups", [
        ("Ctxpopup", "test_ctxpopup", "ctxpopup_clicked"),
        ("Hover", "test_hover", "hover_clicked"),
        ("Hover 2", "test_hover", "hover2_clicked"),
        ("Notify", "test_notify", "notify_clicked"),
        ("Popup", "test_popup", "popup_clicked"),
        ("Tooltip", "test_tooltip", "tooltip_clicked"),
    ]),
    ("Range Values", [
        ("Progressbar", "test_progressbar", "progressbar_clicked"),
        ("Slider", "test_slider", "slider_clicked"),
        ("Spinner", "test_spinner", "spinner_clicked"),
    ]),
    ("Scroller", [
        ("Scroller", "test_scroller", "scroller_clicked"),
    ]),
    ("Selectors", [
        ("Action Slider", "test_actionslider", "actionslider_clicked"),
        ("Color Selector", "test_colorselector", "colorselector_clicked"),
        ("Combobox", "test_combobox", "combobox_clicked"),
        ("Day Selector", "test_dayselector", "dayselector_clicked"),
        ("Disk Selector", "test_diskselector", "diskselector_clicked"),
        ("File Selector", "test_fileselector", "fileselector_clicked"),
        ("Fileselector button", "test_fileselector_button",
         "fileselector_button_clicked"),
        ("Fileselector entry", "test_fileselector_entry",
         "fileselector_entry_clicked"),
        ("Flip Selector", "test_flipselector", "flipselector_clicked"),
        ("Hoversel", "test_hoversel", "hoversel_clicked"),
        ("Index", "test_index", "index_clicked"),
        ("Main Menu", "test_main_menu", "main_menu_clicked"),
        ("Menu", "test_menu", "menu_clicked"),
        ("Radios", "test_radio", "radio_clicked"),
        ("Segment Control", "test_segment_control", "segment_control_clicked"),
    ]),
    ("Standardization", [
        ("Conformant", "test_conform", "conformant_clicked"),
        ("Conformant 2", "test_conform", "conformant2_clicked"),
    ]),
    ("Stored Surface Buffer", [
        ("Launcher", "test_mapbuf", "mapbuf_clicked"),
    ]),
    ("System", [
        ("Notification", "test_sys_notify", "sys_notify_clicked"),
        ("Systray", "test_systray", "systray_clicked"),
    ]),
    ("Text", [
        ("Label", "test_label", "label_clicked"),
    ]),
    ("Times & Dates", [
        ("Calendar", "test_calendar", "calendar_clicked"),
        ("Calendar 2", "test_calendar", "calendar2_clicked"),
        ("Calendar 3", "test_calendar", "calendar3_clicked"),
        ("Clock", "test_clock", "clock_clicked"),
        ("Datetime", "test_datetime", "datetime_clicked"),
    ]),
    ("Toolbars", [
        ("Toolbar", "test_toolbar", "toolbar_clicked"),
        ("Toolbar Item States", "test_toolbar", "toolbar5_clicked"),
    ]),
    ("Web", [
        ("Web", "test_web", "web_clicked"),
    ]),
    ("Window / Background", [
        ("Window Standard/Dialog", "test_win_dialog", "window_dialog_clicked"),
        ("InnerWindow", "test_inwin", "inner_window_clicked"),
        ("Window States", "test_win", "window_states_clicked"),
        ("Bg Plain", "test_bg", "bg_plain_clicked"),
        ("Bg Image", "test_bg", "bg_image_clicked"),
    ])
    ]


def selected_cb(o, mod, func):
    exec("from {0} import {1}; {1}(o)".format(mod, func))


def menu_create(search, win):
    tbx.clear()
    for category in items:
        frame = Frame(win, size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH, text=category[0])
        frame.show()
        tbx.pack_end(frame)

        tbx2 = Box(win, layout=ELM_BOX_LAYOUT_FLOW_HORIZONTAL,
                   size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
                   size_hint_align=(EVAS_HINT_FILL, 0.0))
        frame.content_set(tbx2)
        tbx2.show()

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

        if cnt < 1:
            frame.delete()


def destroy(obj, str1, str2, str3, str4):
    elementary.exit()


def cb_mirroring(toggle):
    elm_conf.mirrored = toggle.state


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

if __name__ == "__main__":
    title = "Python EFL version %s (on python: %s)" % (
             __version__, platform.python_version())
    win = StandardWindow("test", title)
    win.callback_delete_request_add(destroy, "test1", "test2",
                                    str3="test3", str4="test4")

    box0 = Box(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(box0)
    box0.show()

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

    fr = Frame(win, text="Information", content=lb)
    box0.pack_end(fr)
    fr.show()

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

    bx1 = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
              size_hint_align=(EVAS_HINT_FILL, 0.0), horizontal=True)
    box0.pack_end(bx1)
    bx1.show()

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

    en = Entry(win, single_line=True, scrollable=True,
               size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    en.part_text_set("guide", "Type widget name here to search.")
    en.callback_changed_add(cb_filter, win)
    bx1.pack_end(en)
    en.show()
    en.focus_set(True)

    sc = Scroller(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
                  bounce=(False, True))
    sc.show()
    box0.pack_end(sc)

    tbx = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
              size_hint_align=(EVAS_HINT_FILL, 0.0))
    sc.content_set(tbx)
    tbx.show()

    menu_create(None, win)

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