コード例 #1
0
    def create_station_button(self, s, bb, action=None):
        """ Create station button

        :param s: button state
        :param bb: bounding box
        :param action: event listener

        :return: station logo button
        """
        state = State()
        state.icon_base = s.icon_base
        state.index_in_page = s.index_in_page
        state.index = s.index
        state.genre = s.genre
        state.scaled = getattr(s, "scaled", False)
        state.icon_base_scaled = s.icon_base_scaled
        state.name = "station_menu." + s.name
        state.l_name = s.l_name
        state.url = s.url
        state.keyboard_key = kbd_keys[KEY_SELECT]
        state.bounding_box = bb
        state.img_x = bb.x
        state.img_y = bb.y
        state.auto_update = False
        state.show_bgr = True
        state.show_img = True
        state.image_align_v = V_ALIGN_BOTTOM
        button = Button(self.util, state)
        button.add_release_listener(action)
        return button
コード例 #2
0
    def create_latin_abc_menu_button(self, s, constr, action, scale,
                                     font_size):
        """ Create Latin ABC Menu button

        :param s: button state
        :param constr: scaling constraints
        :param action: button event listener
        :param show_img: True - show image, False - don't show image
        :param show_label: True - show label, False - don't show 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 = False
        s.show_label = True
        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.bgr = self.config[BACKGROUND][MENU_BGR_COLOR]
        s.fixed_height = font_size

        button = Button(self.util, s)
        button.add_release_listener(action)

        return button
コード例 #3
0
 def create_image_button(self, name, action=None, keyboard_key=None, lirc_code=None, bounding_box=None, 
                         bgr=(0, 0, 0), x_margin_percent=None, resizable=True, image_size_percent=100, source=None, selected=True):
     """ Create image button
      
     :param name: button name
     :param action: action listener
     :param keyboard_key: keyboard key assigned to the button
     :param lirc_code: LIRC code assigned to the button
     :param bounding_box: button bounding box
     :param bgr: button background color
     :param x_margin_percent: X margin for the button
     :param resizable: flag defining if button can be resized, True - resizable, False - non-resizable
     """
     state = State()
     state.name = name
     state.bounding_box = bounding_box
     state.bgr = bgr
     state.keyboard_key = keyboard_key
     state.lirc_code = lirc_code
     state.img_x = None
     state.img_y = None
     state.auto_update = True
     state.show_bgr = True
     state.show_img = True
     state.image_align_v = V_ALIGN_CENTER
     state.x_margin_percent = x_margin_percent
     state.resizable = resizable
     state.source = source
     state.image_size_percent = image_size_percent / 100.0
     self.set_state_icons(state, selected)
     button = Button(self.util, state)
     if action:
         button.add_release_listener(action)
     return button
コード例 #4
0
    def create_file_button(self, bb, action=None):
        """ Create default audio file button
        
        :param bb: bounding box
        :param action: button event listener
        
        :return: default audio file button
        """
        state = State()

        state.icon_base = self.image_util.get_audio_file_icon("", bb)
        state.scaled = False
        state.name = "cd"
        state.keyboard_key = kbd_keys[KEY_SELECT]
        state.bounding_box = bb
        state.img_x = bb.x
        state.img_y = bb.y
        state.auto_update = False
        state.show_bgr = False
        state.show_img = True
        state.image_align_v = V_ALIGN_CENTER
        state.source = FILE_BUTTON
        button = Button(self.util, state)
        button.add_release_listener(action)
        return button
コード例 #5
0
    def create_collection_menu_button(self, s, constr, action, scale, font_size):
        """ Create Collection menu button

        :param s: button state
        :param constr: scaling constraints
        :param action: button event listener
        :param scale: True - scale images, False - don't scale images

        :return: wifi 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 = False
        s.show_label = True
        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.bgr = self.config[BACKGROUND][MENU_BGR_COLOR]
        s.label_text_height = 40
        s.v_align = V_ALIGN_CENTER
        s.h_align = H_ALIGN_LEFT
        s.h_offset = (constr.w / 100) * 15
        s.padding = 3
        s.wrap_labels = self.config[WRAP_LABELS]
        s.fixed_height = font_size

        button = Button(self.util, s)
        
        button.add_release_listener(action)
        return button
コード例 #6
0
ファイル: factory.py プロジェクト: project-owner/Peppy
 def create_image_button(self, name, action=None, keyboard_key=None, lirc_code=None, bounding_box=None, bgr=(0, 0, 0), x_margin_percent=None, resizable=True):
     """ Create image button
     
     :param name: button name
     :param action: action listener
     :param keyboard_key: keyboard key assigned to the button
     :param lirc_code: LIRC code assigned to the button
     :param bounding_box: button bounding box
     :param bgr: button background color
     :param x_margin_percent: X margin for the button
     :param resizable: flag defining if button can be resized, True - resizable, False - non-resizable
     """
     state = State()
     state.name = name
     state.bounding_box = bounding_box
     state.bgr = bgr
     state.keyboard_key = keyboard_key
     state.lirc_code = lirc_code
     state.img_x = None
     state.img_y = None
     state.auto_update = True
     state.show_bgr = True
     state.show_img = True
     state.image_align_v = V_ALIGN_CENTER
     state.x_margin_percent = x_margin_percent
     state.resizable = resizable
     self.set_state_icons(state)
     button = Button(self.util, state)
     if action:
         button.add_release_listener(action)
     return button
コード例 #7
0
ファイル: factory.py プロジェクト: whenthelight/Peppy
 def create_book_author_menu_button(self,
                                    s,
                                    constr,
                                    action,
                                    show_img=True,
                                    show_label=True):
     """ Create Author Menu button
     
     :param s: button state
     :param constr: bounding box
     :param action: button event listener
     :param show_img: True - show image, False - don't show image
     :param show_label: True - show label, False - don't show label
     
     :return: genre 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
     s.show_label = show_label
     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.label_text_height = 35
     button = Button(self.util, s)
     button.bgr = self.config[COLORS][COLOR_DARK]
     button.add_release_listener(action)
     return button
コード例 #8
0
ファイル: factory.py プロジェクト: project-owner/Peppy
 def create_station_button(self, s, bb, action=None):
     """ Create station button
     
     :param s: button state
     :param bb: bounding box
     :param action: event listener
     
     :return: station logo button
     """
     state = State()
     state.icon_base = s.icon_base
     state.index_in_page = s.index_in_page
     state.index = s.index
     state.scaled = getattr(s, "scaled", False)
     state.icon_base_scaled = s.icon_base_scaled
     state.name = "station_menu." + s.name
     state.l_name = s.l_name
     state.url = s.url
     state.keyboard_key = kbd_keys[KEY_SELECT]
     state.bounding_box = bb
     state.img_x = bb.x
     state.img_y = bb.y
     state.auto_update = False
     state.show_bgr = True
     state.show_img = True
     state.image_align_v = V_ALIGN_BOTTOM
     button = Button(self.util, state)
     button.add_release_listener(action)
     return button        
コード例 #9
0
ファイル: factory.py プロジェクト: project-owner/Peppy
 def create_menu_button(self, s, constr, action, scale, label_area_percent, label_text_height, show_img=True):
     """ Create Menu button
     
     :param s: button state
     :param constr: scaling constraints
     :param action: button event listener
     :param scale: True - scale images, False - don't scale images
     
     :return: menu button
     """          
     if scale:
         self.set_state_scaled_icons(s, constr)
     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
     s.show_label = True
     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
     button = Button(self.util, s)
     button.bgr = self.config[COLORS][COLOR_DARK]
     button.add_release_listener(action)         
     if getattr(s, "icon_base", False):
         button.components[1].content = s.icon_base
     button.scaled = scale        
     return button
コード例 #10
0
    def create_collection_track_menu_button(self,
                                            s,
                                            constr,
                                            action,
                                            show_img=True,
                                            show_label=True):
        """ Create Collection Track Menu button

        :param s: button state
        :param constr: scaling constraints
        :param action: button event listener
        :param show_img: True - show button image, False - not
        :param show_label: True - show button label, False - not

        :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
        s.show_label = show_label
        s.source = TRACK_MENU
        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.wrap_labels = self.config[WRAP_LABELS]

        button = Button(self.util, s)
        button.bgr = self.config[COLORS][COLOR_DARK]
        button.add_release_listener(action)

        return button
コード例 #11
0
ファイル: factory.py プロジェクト: alexander-jung/Peppy
    def create_track_menu_button(self, s, constr, action, show_img=True, show_label=True):
        """ Create Menu button
        
        :param s: button state
        :param constr: scaling constraints
        :param action: button event listener
        :param scale: True - scale images, False - don't scale images
        
        :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
        s.show_label = show_label
        s.source = TRACK_MENU
        if s.name in ABC_RU:
            s.text_color_normal = self.config[COLORS][COLOR_BRIGHT]
        else:
            s.text_color_normal = (255, 255, 255)
        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
        
        button = Button(self.util, s)
        button.bgr = self.config[COLORS][COLOR_DARK]
        button.add_release_listener(action)

        return button
コード例 #12
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
コード例 #13
0
ファイル: factory.py プロジェクト: whenthelight/Peppy
 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