summaryrefslogtreecommitdiff
path: root/examples/elementary/test_bg.py
blob: a5934209def6641576695ee289e525eb552a281f (plain)
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
#!/usr/bin/env python
# encoding: utf-8

import os

from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, EXPAND_BOTH, FILL_BOTH
from efl import elementary
from efl.elementary.window import StandardWindow, Window, ELM_WIN_BASIC
from efl.elementary.background import Background, ELM_BG_OPTION_SCALE
from efl.elementary.box import Box
from efl.elementary.frame import Frame
from efl.elementary.label import Label
from efl.elementary.list import List


img_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "images")
ic_file = os.path.join(img_path, "plant_01.jpg")

def bg_plain_clicked(obj, item=None):
    win = Window("bg plain", ELM_WIN_BASIC, title="Bg Plain", autodel=True,
        size=(320, 320))

    bg = Background(win, size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bg)
    bg.show()

    win.show()


def bg_image_clicked(obj, item=None):
    win = Window("bg-image", ELM_WIN_BASIC, title="Bg Image", autodel=True,
        size=(320, 320), size_hint_min=(160, 160), size_hint_max=(320,320))

    bg = Background(win, file=ic_file, option=ELM_BG_OPTION_SCALE,
        size_hint_weight=EXPAND_BOTH)
    win.resize_object_add(bg)
    bg.show()

    win.show()

    (filename, group) = bg.file_get()
    print(("Background image: '%s'  group: '%s'" % (filename, group)))
    print(("Option: %d" % (bg.option_get())))


if __name__ == "__main__":
    win = StandardWindow("test", "python-elementary test application", size=(320,520))
    win.callback_delete_request_add(lambda x: elementary.exit())

    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<br>" \
                "by clicking the test button to show the<br>" \
                "test window."
    lb.show()

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

    items = [("Bg Plain", bg_plain_clicked),
             ("Bg Image", bg_image_clicked)]

    li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    box0.pack_end(li)
    li.show()

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

    li.go()

    win.show()
    elementary.run()