aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test_fileselector_entry.py
blob: 4c4b5db1f1447bdeba507307a3c0e90dd5ec3c00 (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
#!/usr/bin/env python
# encoding: utf-8

from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, EXPAND_BOTH, FILL_BOTH
from efl import elementary
from efl.elementary.window import StandardWindow
from efl.elementary.box import Box
from efl.elementary.check import Check
from efl.elementary.fileselector_entry import FileselectorEntry
from efl.elementary.separator import Separator


def toggle_is_save(bt, fse):
    print("Toggle is save")
    fse.is_save = not fse.is_save

def toggle_inwin(bt, fse):
    print("Toggle inwin mode")
    fse.inwin_mode = not fse.inwin_mode

def toggle_folder_only(bt, fse):
    print("Toggle folder_only")
    fse.folder_only = not fse.folder_only

def toggle_expandable(bt, fse):
    print("Toggle expandable")
    fse.expandable = not fse.expandable


def fileselector_entry_clicked(obj, item=None):
    win = StandardWindow("fileselector", "File selector test",
                         autodel=True, size=(240, 150))

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

    fse = FileselectorEntry(win, text="Select a file", inwin_mode=False,
                            size_hint_align=FILL_BOTH,
                            size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(fse)
    fse.show()

    sep = Separator(win, horizontal=True)
    vbox.pack_end(sep)
    sep.show()

    hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
    vbox.pack_end(hbox)
    hbox.show()

    ck = Check(win, text="inwin", state=fse.inwin_mode)
    ck.callback_changed_add(toggle_inwin, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="folder_only", state=fse.folder_only)
    ck.callback_changed_add(toggle_folder_only, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="is_save", state=fse.is_save)
    ck.callback_changed_add(toggle_is_save, fse)
    hbox.pack_end(ck)
    ck.show()

    ck = Check(win, text="expandable", state=fse.expandable)
    ck.callback_changed_add(toggle_expandable, fse)
    hbox.pack_end(ck)
    ck.show()

    win.show()


if __name__ == "__main__":
    elementary.init()

    fileselector_entry_clicked(None)

    elementary.run()
    elementary.shutdown()