Esempio n. 1
0
def interface():
    def event_handler(source, evt):
        if evt == lv.EVENT.VALUE_CHANGED:
            date = lv.calendar.get_pressed_date(source)
            if date:
                print("Clicked date: %02d.%02d.%02d" %
                      (date.day, date.month, date.year))

    # Create a screen and load it
    scr = lv.obj()
    lv.scr_load(scr)

    # create a calendar
    calendar = lv.calendar(lv.scr_act(), None)
    calendar.set_size(235, 235)
    calendar.align(None, lv.ALIGN.CENTER, 0, 0)
    calendar.set_event_cb(event_handler)

    # Make the date number smaller to be sure they fit into their area
    calendar.set_style_local_text_font(lv.calendar.PART.DATE, lv.STATE.DEFAULT,
                                       lv.theme_get_font_small())
    today = lv.calendar_date_t()
    date = cetTime()
    today.year = date[0]
    today.month = date[1]
    today.day = date[2]

    calendar.set_today_date(today)
    calendar.set_showed_date(today)

    watch.tft.backlight_fade(100)
Esempio n. 2
0
def event_handler(evt):
    code = evt.get_code()

    if code == lv.EVENT.VALUE_CHANGED:
        source = lv.calendar.__cast__(evt.get_target())
        date = lv.calendar_date_t()
        lv.calendar.get_pressed_date(source, date)
        if date:
            print("Clicked date: %02d.%02d.%02d" %
                  (date.day, date.month, date.year))
Esempio n. 3
0
def event_handler(evt):
    code = evt.get_code()

    if code == lv.EVENT.VALUE_CHANGED:
        source = evt.get_target()
        date = lv.calendar_date_t()
        if source.get_pressed_date(date) == lv.RES.OK:
            calendar.set_today_date(date.year, date.month, date.day)
            print("Clicked date: %02d.%02d.%02d" %
                  (date.day, date.month, date.year))
    def event_handler(task, params):

        code = task.get_code()

        if code == lv.EVENT.VALUE_CHANGED:
            source = task.get_current_target()
            date = lv.calendar_date_t()

            if source.get_pressed_date(date) == lv.RES.OK:

                calendar.set_today_date(date.year, date.month, date.day)
                print("Clicked date: %02d.%02d.%02d" %
                      (date.day, date.month, date.year))
                label1.set_text('Set Date : {} - {} - {}'.format(
                    date.year, date.month, date.day))

                params['year'] = date.year
                params['month'] = date.month
                params['day'] = date.day
Esempio n. 5
0
    def main_page(self, tile_num):
        self.calendar_tile = self.mainbar.get_tile_obj(tile_num)
        self.calendar_style = lv.style_t()
        self.calendar_style.copy(self.mainbar.get_style())

        # create a calendar
        calendar = lv.calendar(self.calendar_tile, None)
        calendar.set_size(200, 200)
        calendar.align(self.calendar_tile, lv.ALIGN.CENTER, 0, -15)
        calendar.set_event_cb(self.event_handler)

        # Make the date number smaller to be sure they fit into their area
        calendar.set_style_local_text_font(lv.calendar.PART.DATE,
                                           lv.STATE.DEFAULT,
                                           lv.theme_get_font_small())

        exit_btn = lv.imgbtn(self.calendar_tile, None)
        exit_btn.set_src(lv.btn.STATE.RELEASED,
                         self.mainbar.get_exit_btn_dsc())
        exit_btn.add_style(lv.imgbtn.PART.MAIN, self.calendar_style)
        exit_btn.align(self.calendar_tile, lv.ALIGN.IN_BOTTOM_LEFT, 10, 0)
        self.log.debug("setting up exit callback")
        exit_btn.set_event_cb(self.exit_calendar_app_event_cb)

        self.calendar_style.set_text_opa(lv.obj.PART.MAIN, lv.OPA.COVER)
        # get current date and time
        today = lv.calendar_date_t()
        if self.mainbar.pcf8563:
            # read time from pcf8563
            localTime = self.mainbar.pcf8563.datetime()
            today.year = localTime[0] + 2000
        else:
            now = time.time()
            localTime = time.localtime(now)
            today.year = localTime[0]

        today.month = localTime[1]
        today.day = localTime[2]

        calendar.set_today_date(today)
        calendar.set_showed_date(today)
Esempio n. 6
0
# create a calendar
calendar = lv.calendar(lv.scr_act(), None)
calendar.set_size(235, 235)
calendar.align(None, lv.ALIGN.CENTER, 0, 0)
calendar.set_event_cb(event_handler)

# Make the date number smaller to be sure they fit into their area
calendar.set_style_local_text_font(lv.calendar.PART.DATE, lv.STATE.DEFAULT,
                                   lv.theme_get_font_small())

try:
    osVersion = os.uname()
    print("Running: ", osVersion)
    from wifi_connect import *
    # connect to the Internet and get the current time
    connect()
    now = cetTime()
except:
    print("Running on Unix")
    import time
    now = time.localtime()

today = lv.calendar_date_t()
today.year = now[0]
today.month = now[1]
today.day = now[2]

calendar.set_today_date(today)
calendar.set_showed_date(today)
Esempio n. 7
0
        date = lv.calendar.get_pressed_date(source)
        if date:
            print("Clicked date: %02d.%02d.%02d" %
                  (date.day, date.month, date.year))


# create a calendar
calendar = lv.calendar(lv.scr_act(), None)
calendar.set_size(235, 235)
calendar.align(None, lv.ALIGN.CENTER, 0, 0)
calendar.set_event_cb(event_handler)

# Make the date number smaller to be sure they fit into their area
calendar.set_style_local_text_font(lv.calendar.PART.DATE, lv.STATE.DEFAULT,
                                   lv.theme_get_font_small())
today = lv.calendar_date_t()
today.year = 2020
today.month = 10
today.day = 5

calendar.set_today_date(today)
calendar.set_showed_date(today)

# Highlight a few days
highlighted_days = []
for i in range(3):
    highlighted_days.append(lv.calendar_date_t())

highlighted_days[0].year = 2020
highlighted_days[0].month = 10
highlighted_days[0].day = 6
Esempio n. 8
0
def event_handler(obj, event):
    if event == lv.EVENT.CLICKED:
        date = obj.get_pressed_date()
        if date is not None:
            obj.set_today_date(date)  #显示按下选中的日期


if TOUCH_READY:

    calendar = lv.calendar(lv.scr_act())
    calendar.set_size(230, 230)
    calendar.align(None, lv.ALIGN.CENTER, 0, 0)
    calendar.set_event_cb(event_handler)

    #设置当前日期
    today = lv.calendar_date_t()  #构建日期对象
    today.year = 2020
    today.month = 7
    today.day = 1

    calendar.set_today_date(today)
    calendar.set_showed_date(today)  #设置当前显示日期

    #设置显示3个高亮日期
    highlihted_days = [
        lv.calendar_date_t({
            'year': 2020,
            'month': 7,
            'day': 10
        }),
        lv.calendar_date_t({
Esempio n. 9
0
                  (date.day, date.month, date.year))


calendar = lv.calendar(lv.scr_act())
calendar.set_size(200, 200)
calendar.align(lv.ALIGN.CENTER, 0, 20)
calendar.add_event_cb(event_handler, lv.EVENT.ALL, None)

calendar.set_today_date(2021, 02, 23)
calendar.set_showed_date(2021, 02)

# Highlight a few days
highlighted_days = [
    lv.calendar_date_t({
        'year': 2021,
        'month': 2,
        'day': 6
    }),
    lv.calendar_date_t({
        'year': 2021,
        'month': 2,
        'day': 11
    }),
    lv.calendar_date_t({
        'year': 2021,
        'month': 2,
        'day': 22
    })
]

calendar.set_highlighted_dates(highlighted_days, len(highlighted_days))