示例#1
0
 def __init__(self, util, name, bgr, slider_color, img_knob, img_knob_on, key_incr, key_decr, key_knob, bb):
     """ Initializer
     
     :param util: utility object
     :param name: slider name
     :param bgr: slider background color
     :param slider_color: slider center line color
     :param img_knob: knob image
     :param img_knob_on: knob image in on state
     :param key_incr: keyboard key associated with slider increment action
     :param key_decr: keyboard key associated with slider decrement action
     :param key_knob: keyboard key associated with single click on knob
     :param bb: slider bounding box
     """
     Container.__init__(self, util, background=bgr, bounding_box=bb)
     self.util = util
     self.config = util.config
     
     self.lock = RLock()
     self.CURRENT_TIME_LAYER = 3
     self.TOTAL_TIME_LAYER = 2
     # don't increase the following number too much as it affects UV Meter screen-saver performance
     self.LOOP_CYCLES_PER_SECOND = 5 
     self.CYCLE_TIME = 1 / self.LOOP_CYCLES_PER_SECOND
     
     self.active = True    
     comp = Component(self.util, bb)
     comp.name = name + "bgr"
     comp.bgr = bgr
     self.add_component(comp)
     
     layout = BorderLayout(bb)
     layout.set_percent_constraints(0.0, 0.0, 20.0, 20.0)
     
     self.current_time_name = name + "current"
     self.total_time_name = name + "total"
     self.current_time_layout = layout.LEFT
     self.total_time_layout = layout.RIGHT
     
     self.slider = Slider(util, name + "slider", bgr, slider_color, img_knob, img_knob_on, None, key_incr, key_decr, key_knob, layout.CENTER, False)
     self.slider.add_slide_listener(self.slider_action_handler)
     self.total_track_time = 0   
     self.seek_time = 0        
     self.add_component(self.slider)
     
     c = Component(self.util, None) # init total time layer
     self.add_component(c)
     c = Component(self.util, None) # init current time layer
     self.add_component(c)
          
     self.seek_listeners = []
     self.start_timer_listeners = []
     self.stop_timer_listeners = []
     self.update_seek_listeners = True
     self.use_web = self.config[USAGE][USE_WEB]
     
     self.stop_timer()
     thread = Thread(target = self.start_loop)
     thread.start()
示例#2
0
 def init_container(self):
     """ Initialize container """
     
     c = Component(self.util)
     self.add_component(c)
     for r in range(self.size):
         c = Component(self.util)
         self.add_component(c)
         c = Component(self.util)
         self.add_component(c)        
示例#3
0
    def draw_tile_header(self, x, y, w, h, fcast):
        """ Draw tile header
        
        :param x: tile x coordinate
        :param y: tile y coordinate
        :param w: tile width
        :param h: tile height
        :param fcast: one day forecast
        """
        height = (h / 100) * TILE_HEADER_HEIGHT
        comp = Component(self.util)
        comp.name = "tile.header." + str(x) + "." + str(y)
        comp.content_x = x
        comp.content_y = y
        rect = pygame.Rect(x, y, w, height)
        comp.content = rect
        comp.fgr = self.semi_transparent_color
        comp.bgr = self.semi_transparent_color
        comp.bounding_box = rect
        self.add_component(comp)

        text_color = self.util.weather_config[COLOR_BRIGHT]
        font_size = int((height / 100) * DAY_HEIGHT)

        if fcast[DAY] == UNKNOWN:
            d = UNKNOWN
        else:
            d = self.weather_config[fcast[DAY].lower()]

        c = self.util.get_text_component(d, text_color, font_size)
        c.name = "th." + str(x) + "." + str(y)
        c.content_x = x + (w - c.content.get_size()[0]) / 2
        c.content_y = y + font_size / 8
        self.add_component(c)
示例#4
0
    def get_star_component(self, button):
        """ Prepare star icon component for marking
        
        :param button: button to mark
        
        :return: star component
        """
        button_image_comp = button.components[1]
        button_image_x = button_image_comp.content_x
        button_image_y = button_image_comp.content_y
        button_image_size = button_image_comp.content.get_size()
        button_image_w = button_image_size[0]

        c = Component(self.util)
        bb = Rect(0, 0, self.config[SCREEN_INFO][WIDTH],
                  self.config[SCREEN_INFO][HEIGHT])
        r = 1 / 25
        c.content = self.image_util.load_multi_color_svg_icon(
            IMAGE_STAR, bb, r)
        c.bgr = c.fgr = (0, 0, 255)
        c.name = button.state.l_name + ".fav"
        img_w = c.content[1].get_size()[0]
        c.content_x = button_image_x + button_image_w - img_w - 2
        c.content_y = button_image_y + 2

        return c
示例#5
0
    def __init__(self, util):
        """ Initializer
        
        :param util: contains configuration object
        """
        Container.__init__(self, util, util.screen_rect, (0, 0, 0))
        self.config = util.config
        plugin_folder = type(self).__name__.lower()
        Screensaver.__init__(self, plugin_folder)
        self.bounding_box = util.screen_rect
        self.name = CLOCK

        military_time_format = self.plugin_config_file.getboolean(
            PLUGIN_CONFIGURATION, MILITARY_TIME_FORMAT)
        if military_time_format:
            self.TIME_FORMAT = "%H:%M"
        else:
            self.TIME_FORMAT = "%I:%M"

        self.animated = self.plugin_config_file.getboolean(
            PLUGIN_CONFIGURATION, ANIMATED)
        if self.animated:
            font_vertical_percent = 20
        else:
            font_vertical_percent = 50

        font_size = int((font_vertical_percent * self.bounding_box.h) / 100)
        self.f = util.get_font(font_size)

        self.component = Component(util)
        self.component.name = GENERATED_IMAGE + self.name
        self.component.image_filename = self.component.name
        self.add_component(self.component)
示例#6
0
    def add_description(self, state, desc, title_y, title_h, bb, font_size):
        """ Add podcast description
        
        :param state: button state
        :param desc: description text
        :param title_y: y coordinate
        :param title_h: text height
        :param bb: bounding box
        :param font_size:
        """
        desc_font_size = int(font_size * 0.7)
        font = self.util.get_font(desc_font_size)
        if self.config[SCREEN_INFO][WIDTH] <= 320:
            line_length = 56
        elif self.config[SCREEN_INFO][WIDTH] > 320 and self.config[
                SCREEN_INFO][WIDTH] <= 480:
            line_length = 58
        else:
            line_length = 64
        lines = textwrap.wrap(desc, line_length)

        for n, line in enumerate(lines[0:5]):
            label = font.render(line, 1, state.text_color_normal)
            c = Component(self.util, label)
            c.name = "desc." + str(title_y) + str(n)
            c.text = line
            c.text_size = desc_font_size
            c.text_color_normal = state.text_color_normal
            c.text_color_selected = state.text_color_selected
            c.text_color_disabled = state.text_color_disabled
            c.text_color_current = c.text_color_normal
            c.content_x = bb.x
            c.content_y = title_y + title_h + (n * desc_font_size)
            self.components.append(c)
示例#7
0
    def __init__(self, util):
        """ Initializer
        
        :param util: utility object
        """
        self.util = util
        self.config = util.config
        self.screen_w = self.config[SCREEN_INFO][WIDTH]
        self.screen_h = self.config[SCREEN_INFO][HEIGHT]
        self.lines = 12
        line_length = 52
        font_vertical_percent = 5
        self.name = LYRICS

        self.lyrics_util = LyricsUtil(util.k2, self.lines, line_length)
        self.lyrics_not_found_label = self.config[LABELS][LYRICS_NOT_FOUND]

        plugin_folder = type(self).__name__.lower()
        Screensaver.__init__(self, plugin_folder)
        self.bounding_box = util.screen_rect
        Container.__init__(self, util, self.bounding_box, (0, 0, 0))

        font_size = int((font_vertical_percent * self.bounding_box.h) / 100)
        self.f = util.get_font(font_size)
        self.lyrics_not_found = True

        c = Component(util, bgr=(0, 0, 0))
        c.name = "base"
        self.set_not_found(c)
        self.add_component(c)
        self.current_page = 1
        self.current_song = ""
示例#8
0
    def add_label(self, state, bb):
        """ Add button label
        
        :param state: button state
        :param bb: bounding box
        """
        if not self.show_label:
            self.add_component(None)
            return

        fixed_height = getattr(state, "fixed_height", None)
        if fixed_height:
            font_size = fixed_height
        else:
            font_size = int((bb.h * state.label_text_height) / 100.0)

        if font_size > self.config[MAXIMUM_FONT_SIZE]:
            font_size = self.config[MAXIMUM_FONT_SIZE]

        font = self.util.get_font(font_size)
        text = self.truncate_long_labels(state.l_name, bb, font)
        state.l_name = text
        size = font.size(text)
        label = font.render(text, 1, state.text_color_normal)
        c = Component(self.util, label)
        c.name = state.name + ".label"
        c.text = text
        c.text_size = font_size
        c.text_color_normal = state.text_color_normal
        c.text_color_selected = state.text_color_selected
        c.text_color_disabled = state.text_color_disabled
        c.text_color_current = c.text_color_normal

        h_align = getattr(state, H_ALIGN, None)
        if h_align != None:
            if h_align == H_ALIGN_LEFT:
                c.content_x = bb.x
        else:
            c.content_x = bb.x + (bb.width - size[0]) / 2

        v_align = getattr(state, V_ALIGN, None)
        if v_align and v_align == V_ALIGN_TOP:
            v_offset = getattr(state, V_OFFSET, 0)
            if v_offset != 0:
                v_offset = int((bb.height / 100) * v_offset)
                c.content_y = bb.y + v_offset
            else:
                c.content_y = bb.y
        else:
            c.content_y = bb.y + (bb.height - size[1]) / 2 + 1

        if len(self.components) == 2:
            self.components.append(c)
        else:
            self.components[2] = c

        desc = getattr(state, "description", None)
        if desc != None:
            self.add_description(state, desc, c.content_y, size[1], bb,
                                 font_size)
示例#9
0
    def add_key(self, x, y, name, key):
        """ Add the key indicating current focus position
        
        :param x: x coordinate
        :param y: y coordinate
        :param name: component name
        :param key: key image
        """
        size = key[1].get_size()
        w = size[0]
        h = size[1]

        cont = Container(self.util)
        cont.bgr = cont.fgr = (0, 0, 0, 0)
        cont.name = name + ".cont"
        c = Component(self.util)
        c.name = name
        c.content = key[1]
        c.bgr = c.fgr = (0, 0, 0, 0)
        c.content_x = x - w / 2
        c.content_y = y
        c.image_filename = key[0]
        c.bounding_box = pygame.Rect(0, 0, w, h)
        cont.bounding_box = pygame.Rect(c.content_x, c.content_y, w, h)

        cont.add_component(c)
        self.add_component(cont)
        return cont
示例#10
0
    def create_one_line_label(self, state, bb, font, font_size, text, padding):
        state.l_name = text
        size = font.size(text)

        if getattr(self, "selected", False):
            color = state.text_color_selected
        else:
            color = state.text_color_normal

        label = font.render(text, 1, color)
        c = Component(self.util, label)
        c.name = state.name + ".label"
        c.text = text
        c.text_size = font_size
        c.text_color_normal = state.text_color_normal
        c.text_color_selected = state.text_color_selected
        c.text_color_disabled = state.text_color_disabled
        c.text_color_current = color
        c.content_x = self.get_label_x(state, bb, size, padding)
        c.content_y = self.get_label_y(state, bb, size)

        if len(self.components) == 2:
            self.components.append(c)
        else:
            self.components[2] = c
示例#11
0
文件: slideshow.py 项目: danpgh/Peppy
    def __init__(self, util):
        """ Initializer
        
        :param util: contains configuration object
        """
        Container.__init__(self, util, util.screen_rect, (0, 0, 0))
        plugin_folder = type(self).__name__.lower()
        Screensaver.__init__(self, plugin_folder)
        self.util = util
        self.config = util.config
        self.bounding_box = util.screen_rect
        self.default_folder = os.path.join(PACKAGE_SCREENSAVER, plugin_folder,
                                           DEFAULT_SLIDES_FOLDER)
        self.name = SLIDESHOW

        config_slides_folder = self.plugin_config_file.get(
            PLUGIN_CONFIGURATION, CONFIG_SLIDES_FOLDER)
        if config_slides_folder:
            self.current_folder = config_slides_folder
        else:
            self.current_folder = self.default_folder

        self.random = self.plugin_config_file.get(PLUGIN_CONFIGURATION,
                                                  RANDOM_ORDER)

        self.slides = []
        self.component = Component(util)
        self.component.name = self.name
        self.add_component(self.component)
示例#12
0
 def set_track_time(self, name, time, bb, layer_num):
     """ Set track time
     
     :param name: button state
     :param time: track time
     :param bb: bounding box
     :param layer_num: layer number
     """
     font_size = int((bb.h * 45)/100.0)
     font = self.util.get_font(font_size)
     size = font.size(time)
     label = font.render(time, 1, self.config[COLORS][COLOR_BRIGHT])
     c = Component(self.util, label)
     c.bgr = (255, 0, 0)
     c.name = name
     c.text = time
     c.text_size = font_size
     c.text_color_current = self.config[COLORS][COLOR_BRIGHT]
     c.content_x = bb.x + (bb.width - size[0])/2
     c.content_y = bb.y + (bb.height - size[1])/2 
     self.components[layer_num] = c
     
     if self.visible:    
         self.draw()
         self.update()
示例#13
0
    def add_image(self, state, bb):
        """ Add image
        
        :param state: button state
        :param bb: bounding box
        """
        if not state.show_img or getattr(state, "icon_base", None) == None:
            self.add_component(None)
            return
        c = Component(self.util)
        c.name = state.name + ".image"
        scaled = getattr(state, "scaled", False)
        enabled = getattr(state, "enabled", True)

        if not enabled:
            c.content = state.icon_disabled[1]
            c.image_filename = state.icon_disabled[0]
        else:
            if scaled:
                c.content = state.icon_base_scaled
            else:
                c.content = state.icon_base[1]
            c.image_filename = state.icon_base[0]

        w = c.content.get_size()[0]
        h = c.content.get_size()[1]
        c.content_x = bb.x + (bb.width - w) / 2
        c.content_y = bb.y + (bb.height - h) / 2

        self.add_component(c)
示例#14
0
    def __init__(self, util, digits, digit, bb, increment_listener,
                 decrement_listener, name):
        """ Initializer
        
        :param util: utility object
        :param digits: clock digits 0-9
        :param digit: the digit
        :param bb: digit bounding box
        :param increment_listener: increment listener
        :param decrement_listener: decrement listener
        :param name: component name
        """
        self.util = util
        self.config = self.util.config
        EventContainer.__init__(self, util, bb)
        self.digits = digits
        self.digit = digit
        image = self.digits[self.digit][1]

        c = Component(self.util)
        c.name = name
        c.image_filename = self.digits[self.digit][0]
        c.content = image
        c.content_x = bb.x
        c.content_y = bb.y

        self.add_component(c)

        top = Rect(bb.x, bb.y, bb.w, bb.h / 2)
        self.add_area_listener((top, increment_listener))
        bottom = Rect(bb.x, bb.y + (bb.h / 2) + 1, bb.w, bb.h / 2)
        self.add_area_listener((bottom, decrement_listener))
示例#15
0
 def add_label(self,
               index,
               label,
               x,
               y,
               text,
               text_size,
               label_type,
               text_width=None):
     """ Add text label to the component list
     
     :param index: label index
     :param label: rendered text
     :param x: X coordinate for new label
     :param y: Y coordinate for new label
     :param text: the text
     :param text_size: text size
     :param label_type: label type (STATIC or ANIMATED)
     :param text_width: the width of the rendered text
     """
     comp = Component(self.util, label)
     comp.label_type = label_type
     comp.name = self.name + ".text." + str(index)
     comp.content_x = x
     comp.content_y = y
     comp.text = text
     comp.text_size = text_size
     comp.fgr = self.fgr
     if text_width:
         comp.text_width = text_width
     self.components.append(comp)
示例#16
0
    def add_label(self, state, bb):
        """ Add button label
        
        :param state: button state
        :param bb: bounding box
        """
        if not self.show_label:
            self.add_component(None)
            return
        font_size = int(state.label_text_height)
        font = self.util.get_font(font_size)

        label = state.l_name

        text = self.truncate_long_labels(label, bb, font)
        size = font.size(text)
        rendered_label = font.render(text, 1, self.text_color_normal)
        c = Component(self.util, rendered_label)
        c.name = label + ".label"
        c.text = text
        c.text_size = font_size
        c.text_color_normal = self.text_color_normal
        c.text_color_selected = self.text_color_selected
        c.text_color_disabled = self.text_color_disabled
        c.text_color_current = c.text_color_normal
        c.content_x = bb.x + (bb.width - size[0]) / 2
        c.content_y = bb.y + (bb.height - size[1]) / 2 + self.padding * 1.5
        self.components.append(c)
示例#17
0
    def add_bgr(self):
        """ Add background rectangle """

        comp = Component(self.util, self.bounding_box)
        comp.name = self.name + ".bgr"
        comp.bgr = self.bgr
        self.add_component(comp)
示例#18
0
    def __init__(self, util):
        """ Initializer
        
        :param util: contains config object
        """
        self.name = LOGO
        plugin_folder = type(self).__name__.lower()
        Screensaver.__init__(self, self.name, util, plugin_folder)
        Container.__init__(self,
                           util,
                           bounding_box=util.screen_rect,
                           background=self.bg[1],
                           content=self.bg[2],
                           image_filename=self.bg[3])

        self.config = util.config
        self.image_util = util.image_util
        self.util = util
        vertical_size_percent = self.plugin_config_file.getint(
            PLUGIN_CONFIGURATION, VERTICAL_SIZE_PERCENT)
        self.logo_size = int(
            (vertical_size_percent * self.bounding_box.h) / 100)
        self.r = pygame.Rect(0, 0, self.logo_size, self.logo_size)

        self.component = Component(util)
        self.component.name = GENERATED_IMAGE + self.name
        self.component.image_filename = self.component.name
        self.add_component(self.component)
示例#19
0
    def prepare_label(self):
        """ Prepare label component representing this output text. Used for web. """

        text = self.text
        if text is None:
            return

        if self.obfuscate_flag:
            text = "".join(["\u2022"] * len(self.text))

        if self.font == None:
            return

        size = self.font.size(text)
        label = self.font.render(text, 1, self.fgr)
        comp = Component(self.util, label)
        comp.name = self.name + ".text"
        comp.content_x = self.bounding_box.x + self.get_x(size)
        comp.content_y = self.bounding_box.y + self.get_y(size)
        comp.text = text
        comp.text_size = self.default_font_size
        comp.fgr = self.fgr

        if len(self.components) == 1:
            self.add_component(comp)
        else:
            self.components[1] = comp
示例#20
0
    def add_page(self, page_num, page):
        """ Add lyrics page to the container
        
        :param page_num: lyrics page number
        :param page: lyrics page 
        """
        cont = Container(self.util, self.bounding_box, (0, 0, 0))
        max_line_length = self.get_max_line_length(page)
        s = self.f.size("W")
        page_height = self.lines * s[1]
        offset_y = (self.screen_h - page_height) / 2
        offset_x = (self.screen_w - max_line_length) / 2

        for n, line in enumerate(page):
            c = Component(self.util, bgr=(0, 0, 0))
            str_size = self.f.size(line)
            if page_num == 0 and n == 0:
                color = self.config[COLORS][COLOR_BRIGHT]
            else:
                color = self.config[COLORS][COLOR_CONTRAST]
            img = self.f.render(line, 1, color)
            name = GENERATED_IMAGE + str(n)
            c.content = (name, img)
            c.name = name
            c.image_filename = name
            c.content_y = offset_y + (str_size[1] * n)
            c.content_x = offset_x
            cont.add_component(c)
        self.add_component(cont)
示例#21
0
    def __init__(self, util, handle_slider_event, bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param handle_slider_event: slider event handler
        :param listeners: menu listeners
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.labels = [
            "31", "63", "125", "250", "500", "1k", "2k", "4k", "8k", "16k"
        ]

        self.util = util
        Container.__init__(self, util)
        name = "equalizermenu"
        self.factory = Factory(util)

        self.bounding_box = bounding_box
        self.bounding_box.y += 1
        self.bounding_box.h -= 1
        self.bgr_color = util.config[BACKGROUND][MENU_BGR_COLOR]

        self.eq_layout = BorderLayout(self.bounding_box)
        self.eq_layout.set_percent_constraints(0, 0, 5, 5)

        self.bands = 10
        self.sliders = self.add_sliders(handle_slider_event)
        self.current_slider = -1

        self.left_filler = Component(util, self.eq_layout.LEFT)
        self.left_filler.name = name + ".bgr.left"
        self.left_filler.bgr = self.bgr_color
        self.add_component(self.left_filler)

        self.right_filler = Component(util, self.eq_layout.RIGHT)
        self.right_filler.name = name + ".bgr.right"
        self.right_filler.bgr = self.bgr_color
        self.add_component(self.right_filler)

        self.SLOW_INCREMENT = 1
        self.FAST_INCREMENT = self.sliders[0].slider.knob_height / 2

        self.mouse_events = [
            pygame.MOUSEBUTTONUP, pygame.MOUSEBUTTONDOWN, pygame.MOUSEMOTION
        ]
示例#22
0
    def create_two_lines_label(self, state, bb, font, font_size, text,
                               text_with_ellipses, padding):
        length = len(text_with_ellipses) - 3
        first_line = text[0:length]
        if first_line:
            first_line = first_line.strip()
        second_line = self.truncate_long_labels(text[length:], bb, font)
        if second_line:
            second_line = second_line.strip()

        size = font.size(first_line)
        label = font.render(first_line, 1, state.text_color_normal)
        c = Component(self.util, label)
        c.name = first_line + ".label"
        c.text = first_line
        c.text_size = font_size
        c.text_color_normal = state.text_color_normal
        c.text_color_selected = state.text_color_selected
        c.text_color_disabled = state.text_color_disabled
        c.text_color_current = c.text_color_normal
        c.content_x = self.get_label_x(state, bb, size, padding)
        padding = (bb.h / 100) * 5
        c.content_y = bb.y + padding
        if len(self.components) == 2:
            self.components.append(c)
        else:
            self.components[2] = c
        x = c.content_x

        f_size = font_size - int((font_size / 100) * 20)
        f = self.util.get_font(f_size)
        s = font.size(second_line)
        label = f.render(second_line, 1, state.text_color_disabled)
        c = Component(self.util, label)
        c.name = second_line + ".label"
        c.text = second_line
        c.text_size = f_size
        c.text_color_normal = state.text_color_disabled
        c.text_color_selected = state.text_color_selected
        c.text_color_disabled = state.text_color_disabled
        c.text_color_current = c.text_color_disabled
        c.content_x = x
        c.content_y = padding * 2 + bb.y + s[1] - s[1] / 3
        self.components.append(c)
示例#23
0
 def get_shadow(self):
     """ Return the button shadow component
     
     :return: shadow component
     """
     c = Component(self.util, self.shadow[1])
     c.name = "station_menu.shadow"
     c.image_filename = self.shadow[0]
     c.content_x = self.bounding_box.x
     c.content_y = self.bounding_box.y
     return c
示例#24
0
    def create_keyboard(self, keyboard_type, span, transition_map):
        """ Create keyboard

        :param keyboard_type: type
        :param span: span
        :param transition_map: transition map
        """
        layout = self.get_layout(span)
        buttons = []
        keys = None
        self.current_keyboard_type = keyboard_type

        try:
            buttons = self.keyboards[keyboard_type]
            self.components = buttons
            return
        except:
            pass

        if keyboard_type == KEYBOARD_abc:
            keys = KEYBOARD_1
        elif keyboard_type == KEYBOARD_ABC:
            keys = KEYBOARD_2
        elif keyboard_type == KEYBOARD_123:
            keys = KEYBOARD_3
        elif keyboard_type == KEYBOARD_symbol:
            keys = KEYBOARD_4

        for i, k in enumerate(keys):
            if not k:
                c = Component(self.util, layout[i], bgr=self.config[BACKGROUND][MENU_BGR_COLOR])
                c.parent_screen = self.screen
                c.name = "gap" + str(i)
                buttons.append(c)
                continue
            s = State()
            s.index = i
            s.name = k
            s.l_name = k
            s.comparator_item = s.index
            s.bgr = self.config[COLORS][COLOR_DARK]
            s.show_bgr = True
            s.bounding_box = layout[i]
            s.key_map = transition_map[i]
            button = self.factory.create_menu_button(s, layout[i], self.press_key, False, 50, 100, False, True)
            buttons.append(button)
        buttons[0].set_selected(True)
        self.keyboards[keyboard_type] = buttons
        self.components = buttons

        if keyboard_type != KEYBOARD_abc:
            self.set_observers()

        self.buttons = {i : item for i, item in enumerate(buttons)}
示例#25
0
    def add_bgr(self):
        """ Add background rectangle """

        if not self.full_width:
            self.bounding_box.x += 1
            self.bounding_box.y += 1
            self.bounding_box.w -= 2
            self.bounding_box.h -= 1
        comp = Component(self.util, self.bounding_box)
        comp.name = self.name + ".bgr"
        comp.bgr = self.bgr
        self.add_component(comp)
示例#26
0
 def draw_background(self, x, y, w, h):
     """ Draw background defined by input parameters
     
     :param x: x coordinate
     :param y: y coordinate
     :param w: width
     :param h: height
     """
     c = Component(self.util)
     c.name = "today.bgr"
     c.content = pygame.Rect(x, y, w, h)
     c.content_x = x
     c.content_y = y
     c.bounding_box = c.content
     c.bgr = self.semi_transparent_color
     self.add_component(c)
示例#27
0
 def get_text_component(self, text, fgr, font_height):
     """ Create text component using supplied parameters
     
     :param text: text
     :param fgr: text color
     :param font_height: font height
     
     :return: text component
     """
     self.font = self.get_font(font_height)
     label = self.font.render(text, 1, fgr)
     comp = Component(self, label)
     comp.text = text
     comp.text_size = font_height
     comp.fgr = fgr
     return comp
示例#28
0
    def draw_weather(self):
        """ Draw weather forecast  """

        Container.__init__(self, self.util, self.rect, BLACK)

        c = Component(self.util)
        c.name = "forecast.bgr"
        c.content = self.initial_image
        c.content_x = 0
        c.content_y = 0
        c.bounding_box = self.rect
        self.add_component(c)

        widths = self.get_widths()
        heights = self.get_heights()

        self.draw_tiles(widths, heights)
示例#29
0
 def draw_separator(self, x, y, w, h):
     """ Draw tile separator
     
     :param x: tile x coordinate
     :param y: tile y coordinate
     :param w: tile width
     :param h: tile height
     """
     height = (h / 100) * TILE_HEADER_HEIGHT
     comp = Component(self.util)
     comp.name = "sep." + str(x) + "." + str(y)
     rect = pygame.Rect(x + w, y + height, 1, h - height + 2)
     comp.content = rect
     comp.fgr = self.util.weather_config[COLOR_DARK_LIGHT]
     comp.bgr = self.util.weather_config[COLOR_DARK_LIGHT]
     comp.bounding_box = rect
     self.add_component(comp)
示例#30
0
    def add_selection(self, state, bb):
        if not self.selected:
            return

        border = 2
        c = Component(self.util, t=border)
        c.name = state.name + ".selection"
        x = state.bounding_box.x + border / 2
        y = state.bounding_box.y + border / 2
        w = state.bounding_box.w - border
        h = state.bounding_box.h - border
        c.content = pygame.Rect(x, y, w, h)
        c.bgr = state.text_color_selected
        c.fgr = (0, 0, 0, 0)

        c.content_x = state.bounding_box.x
        c.content_y = state.bounding_box.y
        self.add_component(c)