Ejemplo n.º 1
0
    def __init__(self, watchface_cfg, lv_cont=None):
        super().__init__(watchface_cfg=watchface_cfg, parent_cont=lv_cont)

        self.label = lv.label(self.parent_cont)
        self.label.set_recolor(True)
        self.label.set_align(lv.label.ALIGN.CENTER)
        self.label.add_style(
            self.label.PART.MAIN,
            styles.get_style_text(int(self.styles['text']['size']),
                                  self.styles['text']['color']))

        self.label.set_text('{}'.format('label'))
Ejemplo n.º 2
0
    def __init__(self, watchface_cfg, lv_cont=None):
        super().__init__(watchface_cfg=watchface_cfg, parent_cont=lv_cont)

        self.symbol_button = lv.btn(self.parent_cont)
        # self.symbol_button.set_size(self.parent_cont.size_x - 10, self.parent_cont.size_y - 10)
        self.symbol_button.set_size(self.styles['button']['size_x'],
                                    self.styles['button']['size_y'])
        self.symbol_button.align(self.parent_cont, lv.ALIGN.CENTER, 0, 0)
        self.symbol_button_style = styles.button_style_3D
        self.symbol_button.add_style(self.symbol_button.PART.MAIN,
                                     self.symbol_button_style)

        self.symbol_button_label = lv.label(self.symbol_button)
        self.symbol_button_label.set_recolor(True)
        self.symbol_button_label.add_style(
            self.symbol_button_label.PART.MAIN,
            styles.get_style_text(int(self.styles['text']['size']),
                                  self.styles['text']['color']))

        if 'symbol_text_separator' in self.options:
            self.cur_sep = self.options['symbol_text_separator']
        else:
            self.cur_sep = ''

        self.cur_text = ''
        if 'text' in self.options and 'val' in self.options['text']:
            if 'color' in self.options['text']:
                self.cur_text += '#{} '.format(self.options['text']['color'])
            self.cur_text += self.options['text']['val']
            if 'color' in self.options['text']:
                self.cur_text += '#'

        self.cur_symbol = ''
        if 'symbol' in self.options and 'val' in self.options['symbol']:
            if 'color' in self.options['symbol']:
                self.cur_symbol += '#{} '.format(
                    self.options['symbol']['color'])

            if self.options['symbol']['val'] in styles.LV_SYMBOL.__dict__:
                self.cur_symbol += getattr(styles.LV_SYMBOL,
                                           self.options['symbol']['val'])
            else:
                print('Invalid Symbol label symbol:',
                      self.options['symbol']['val'])

            if 'color' in self.options['symbol']:
                self.cur_symbol += '#'

        self.label_text = '{}{}{}'.format(self.cur_symbol, self.cur_sep,
                                          self.cur_text)
        self.symbol_button_label.set_text(self.label_text)
Ejemplo n.º 3
0
    def __init__(self, watchface_cfg, lv_cont=None):
        super().__init__(watchface_cfg=watchface_cfg, parent_cont=lv_cont)

        # self.parent_cont.set_fit(lv.FIT.NONE)
        # self.parent_cont.set_layout(lv.LAYOUT.CENTER)

        self.wifi_label = lv.label(self.parent_cont)
        self.wifi_label.set_recolor(True)
        self.wifi_label.set_align(lv.label.ALIGN.CENTER)
        self.wifi_label.add_style(
            self.wifi_label.PART.MAIN,
            styles.get_style_text(int(self.styles['text']['size']),
                                  self.styles['text']['color']))

        self.wifi_label.set_text('#d3d3d3 {}#'.format(lv.SYMBOL.WIFI))
Ejemplo n.º 4
0
    def __init__(self, watchface_cfg, lv_cont=None):
        super().__init__(watchface_cfg=watchface_cfg, parent_cont=lv_cont)

        self.date_label = lv.label(self.parent_cont)
        self.date_label.set_recolor(True)
        self.date_label.set_align(lv.label.ALIGN.CENTER)
        self.date_label.add_style(
            self.date_label.PART.MAIN,
            styles.get_style_text(int(self.styles['text']['size']),
                                  self.styles['text']['color']))

        # self.date_label.set_pos(self.pos_x, self.pos_y)
        # self.date_label.set_size(self.size_x, self.size_y)
        (self.year, self.month, self.mday, _hour, _minute, _second,
         self.weekday, self.yearday) = time.localtime()
        self.date_text = self.format_date()
        self.date_label.set_text(self.date_text)
Ejemplo n.º 5
0
    def __init__(self, watchface_cfg, lv_cont=None):
        super().__init__(watchface_cfg=watchface_cfg, parent_cont=lv_cont)

        self.blink_second_on = True
        self.time_label = lv.label(self.parent_cont)
        self.time_label.set_recolor(True)
        self.time_label.set_align(lv.label.ALIGN.CENTER)
        self.time_label.add_style(
            self.time_label.PART.MAIN,
            styles.get_style_text(int(self.styles['text']['size']),
                                  self.styles['text']['color']))
        self.time_label.set_text('00:00:00')
        # self.time_label.set_long_mode(lv.label.LONG.SROLL_CIRC)

        # Do we need this after containers???
        # self.time_label.set_pos(self.pos_x, self.pos_y)
        # self.time_label.set_size(self.size_x, self.size_y)
        '''
Ejemplo n.º 6
0
    def __init__(self, watchface_cfg, lv_cont=None):
        super().__init__(watchface_cfg=watchface_cfg, parent_cont=lv_cont)

        self.symbol_label = lv.label(self.parent_cont)
        self.symbol_label.set_recolor(True)
        self.symbol_label.set_align(lv.label.ALIGN.CENTER)
        self.symbol_label.add_style(
            self.symbol_label.PART.MAIN,
            styles.get_style_text(int(self.styles['text']['size']),
                                  self.styles['text']['color']))

        if 'states' in self.options:
            self.states = self.options['states']
        else:
            self.states = []

        self.cur_label_text = ''
        self.cur_symbol = ''
        self.cur_sep = ' '
        self.cur_text = ''

        # Build symbol text & colors for each state
        for sl_state in self.states:

            sl_state['symbol']['text'] = ''
            if 'symbol' in sl_state and 'val' in sl_state[
                    'symbol'] and sl_state['symbol']['val'] != "":
                if 'color' in sl_state['symbol']:
                    sl_state['symbol']['text'] += '#{} '.format(
                        sl_state['symbol']['color'])

                if sl_state['symbol']['val'] in styles.LV_SYMBOL.__dict__:
                    # sl_state['symbol']['text'] += globals()[sl_state['symbol']['val']]
                    sl_state['symbol']['text'] += getattr(
                        styles.LV_SYMBOL, sl_state['symbol']['val'])
                else:
                    print('Invalid Symbol:', sl_state['symbol']['val'])

                if 'color' in sl_state['symbol']:
                    sl_state['symbol']['text'] += '#'

            if sl_state['on'] == 'init':
                self.cur_symbol = sl_state['symbol']['text']
                self.cur_sep = sl_state['symbol_text_seperator']
                # Default value
                if 'default_val' in sl_state['text']:
                    if 'color' in sl_state['text']:
                        self.cur_text += '#{} '.format(
                            sl_state['text']['color'])

                    if 'fixed_num_chars' in sl_state['text'] and sl_state[
                            'text']['fixed_num_chars'] > 0:
                        self.cur_text += '{0:0{1}}'.format(
                            sl_state['text']['default_val'],
                            sl_state['text']['fixed_num_chars'])
                    else:
                        self.cur_text += '{}'.format(
                            sl_state['text']['default_val'])

                    if 'units' in sl_state['text']:
                        self.cur_text += '{}'.format(sl_state['text']['units'])
                    if 'color' in sl_state['text']:
                        self.cur_text += '#'

        self.cur_label_text = '{}{}{}'.format(self.cur_symbol, self.cur_sep,
                                              self.cur_text)
        self.symbol_label.set_text(self.cur_label_text)