Esempio n. 1
0
    def create_menu_button(self, s, constr, action, scale, label_area_percent=30, label_text_height=44, show_img=True, show_label=True, bgr=None, source=None, font_size=None, ignore_bgr_opacity=False):
        """ Create Menu button
        
        :param s: button state
        :param constr: scaling constraints
        :param action: button event listener
        :param scale: True - scale image and label, False - don't scale image and label
        
        :return: menu button
        """          
        s.bounding_box = constr
        s.img_x = None
        s.img_y = None
        s.auto_update = True
        s.show_bgr = True
        s.show_img = show_img and getattr(s, "show_img", True)
        s.show_label = show_label

        if getattr(s, "file_type", None) == FILE_AUDIO and getattr(s, "has_embedded_image", None):
            s.show_label = not self.config[HIDE_FOLDER_NAME]

        if getattr(s, "file_type", None) != None and self.config[HIDE_FOLDER_NAME]:
            s.show_selection = True

        s.image_location = getattr(s, "image_location", TOP)
        s.label_location = getattr(s, "label_location", BOTTOM)
        s.label_area_percent = label_area_percent

        if s.show_img and s.label_area_percent:
            s.image_area_percent = 100 - s.label_area_percent

        s.label_text_height = label_text_height
        s.v_align = getattr(s, "v_align", V_ALIGN_CENTER)
        s.text_color_normal = self.config[COLORS][COLOR_BRIGHT]
        s.text_color_selected = self.config[COLORS][COLOR_CONTRAST]
        s.text_color_disabled = self.config[COLORS][COLOR_MEDIUM]
        s.text_color_current = s.text_color_normal
        s.fixed_height = font_size
        s.scale = scale
        s.source = source 

        if bgr:
            s.bgr = bgr
        else:
            if ignore_bgr_opacity:
                s.bgr = self.config[COLORS][COLOR_DARK]
            else:
                s.bgr = self.config[BACKGROUND][MENU_BGR_COLOR]

        button = Button(self.util, s)
        button.add_release_listener(action)
        if not getattr(s, "enabled", True):
            button.set_enabled(False)
        elif getattr(s, "icon_base", False) and not getattr(s, "scaled", False):
            button.components[1].content = s.icon_base
        button.scaled = scale        
        return button
Esempio n. 2
0
 def create_menu_button(self,
                        s,
                        constr,
                        action,
                        scale,
                        label_area_percent=30,
                        label_text_height=44,
                        show_img=True,
                        show_label=True,
                        bgr=None,
                        source=None,
                        font_size=None):
     """ Create Menu button
     
     :param s: button state
     :param constr: scaling constraints
     :param action: button event listener
     :param scale: True - scale image and label, False - don't scale image and label
     
     :return: menu button
     """
     s.bounding_box = constr
     s.img_x = None
     s.img_y = None
     s.auto_update = True
     s.show_bgr = True
     s.show_img = show_img and getattr(s, "show_img", True)
     s.show_label = show_label
     s.image_location = CENTER
     s.label_location = BOTTOM
     s.label_area_percent = label_area_percent
     s.label_text_height = label_text_height
     s.text_color_normal = self.config[COLORS][COLOR_BRIGHT]
     s.text_color_selected = self.config[COLORS][COLOR_CONTRAST]
     s.text_color_disabled = self.config[COLORS][COLOR_MEDIUM]
     s.text_color_current = s.text_color_normal
     if font_size:
         s.fixed_height = int(font_size * 0.8)
     s.scale = scale
     s.source = source
     if bgr:
         s.bgr = bgr
     else:
         s.bgr = self.config[COLORS][COLOR_DARK]
     button = Button(self.util, s)
     button.add_release_listener(action)
     if not getattr(s, "enabled", True):
         button.set_enabled(False)
     elif getattr(s, "icon_base",
                  False) and not getattr(s, "scaled", False):
         button.components[1].content = s.icon_base
     button.scaled = scale
     return button