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


from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, EXPAND_BOTH, \
    FILL_BOTH, FILL_HORIZ
from efl import elementary
from efl.elementary.window import StandardWindow
from efl.elementary.background import Background
from efl.elementary.box import Box
from efl.elementary.datetime_elm import Datetime, ELM_DATETIME_MINUTE, \
    ELM_DATETIME_HOUR, ELM_DATETIME_AMPM, ELM_DATETIME_DATE, \
    ELM_DATETIME_MONTH, ELM_DATETIME_YEAR

from datetime import datetime


def changed_cb(obj):
    print("Datetime value is changed")

def datetime_clicked(obj):
    win = StandardWindow("dt", "DateTime")
    win.autodel = True

    bx = Box(win, size_hint_weight=EXPAND_BOTH, horizontal=False,
        size_hint_min=(360, 240))
    win.resize_object_add(bx)
    bx.show()

    dt = Datetime(bx, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ)
    dt.field_visible_set(ELM_DATETIME_HOUR, False)
    dt.field_visible_set(ELM_DATETIME_MINUTE, False)
    dt.field_visible_set(ELM_DATETIME_AMPM, False)
    bx.pack_end(dt)
    dt.show()

    dt = Datetime(bx, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ)
    dt.field_visible_set(ELM_DATETIME_YEAR, False)
    dt.field_visible_set(ELM_DATETIME_MONTH, False)
    dt.field_visible_set(ELM_DATETIME_DATE, False)
    bx.pack_end(dt)
    dt.show()

    dt = Datetime(bx, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ)

    # get the current local time
    time1 = datetime.now()
    # set the max year as 2030 and the remaining fields are equal to current time values
    time1.replace(year = 130)
    dt.value_max = time1
    # set the min time limit as "1980 January 10th 02:30 PM"
    time1.replace(year = 80, month = 4, day = 10, hour = 14, minute = 30)
    dt.value_min = time1
    # minutes can be input only in between 15 and 45
    dt.field_limit_set(ELM_DATETIME_MINUTE, 15, 45)
    dt.callback_changed_add(changed_cb)
    bx.pack_end(dt)
    dt.show()

    win.show()

if __name__ == "__main__":

    datetime_clicked(None)

    elementary.run()