예제 #1
0
    def create_home_player_buttons(self, container, layout, listeners):
        """ Create home and player buttons
        
        :param container: destination of the buttons
        :param layout: bounding box
        :param listeners: buttons listeners
        
        :return: tuple with home and player buttons
        """
        nav_layout = GridLayout(layout)
        nav_layout.set_pixel_constraints(1, 2, 1, 0)
        nav_layout.current_constraints = 0
        d = self.config[COLORS][COLOR_DARK_LIGHT]

        constr = nav_layout.get_next_constraints()
        home_button = self.create_button(KEY_HOME,
                                         KEY_HOME,
                                         constr,
                                         listeners[KEY_HOME],
                                         d,
                                         image_size_percent=60)
        container.add_component(home_button)

        constr = nav_layout.get_next_constraints()
        player_button = self.create_button(KEY_PLAYER,
                                           KEY_PLAY_PAUSE,
                                           constr,
                                           listeners[KEY_PLAYER],
                                           d,
                                           image_size_percent=60)
        container.add_component(player_button)

        return (home_button, player_button)
예제 #2
0
    def __init__(self, util, listeners, bgr=None, bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param listeners: menu listeners
        :param bgr: menu background
        :param bounding_box: bounding box
        """   
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "collection.navigator"
        self.content = self.bounding_box = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        layout = GridLayout(bounding_box)
        layout.set_pixel_constraints(1, 3, 1, 0)
        layout.current_constraints = 0

        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(KEY_HOME, KEY_HOME, constr, listeners[KEY_HOME], bgr, IMAGE_SIZE)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)

        constr = layout.get_next_constraints()
        self.back_button = self.factory.create_button(KEY_BACK, KEY_BACK, constr, listeners[KEY_BACK], bgr, IMAGE_SIZE)
        self.add_component(self.back_button)
        self.menu_buttons.append(self.back_button)
        
        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(KEY_PLAYER, KEY_PLAY_PAUSE, constr, listeners[KEY_PLAYER], bgr, IMAGE_SIZE)
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)
예제 #3
0
    def __init__(self, util, bounding_box, listeners, bgr, pages):
        """ Initializer
        
        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        :param bgr: menu background
        :param pages: number of episodes menu pages       
        """ 
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "podcasts.navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        arrow_layout = BorderLayout(bounding_box)
        arrow_layout.set_percent_constraints(0, 0, PERCENT_ARROW_WIDTH, PERCENT_ARROW_WIDTH)
        
        if pages > 1:
            constr = arrow_layout.LEFT
            self.left_button = self.factory.create_page_down_button(constr, "0", 40, 100)
            self.left_button.add_release_listener(listeners[GO_LEFT_PAGE])
            self.add_component(self.left_button)
            self.menu_buttons.append(self.left_button)
            
            constr = arrow_layout.RIGHT
            self.right_button = self.factory.create_page_up_button(constr, "0", 40, 100)
            self.right_button.add_release_listener(listeners[GO_RIGHT_PAGE])
            self.add_component(self.right_button)
            self.menu_buttons.append(self.right_button)
            layout = GridLayout(arrow_layout.CENTER)
        else:
            layout = GridLayout(bounding_box)
            
        layout.set_pixel_constraints(1, 4, 1, 0)        
        layout.current_constraints = 0
        image_size = 64 
        
        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(KEY_HOME, KEY_HOME, constr, listeners[KEY_HOME], bgr, image_size_percent=image_size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)
        
        constr = layout.get_next_constraints()
        self.back_button = self.factory.create_button(KEY_PODCASTS_MENU, KEY_PARENT, constr, listeners[PODCASTS], bgr, image_size_percent=image_size)
        self.add_component(self.back_button)
        self.menu_buttons.append(self.back_button)
        
        constr = layout.get_next_constraints()
        self.back_button = self.factory.create_button(KEY_BACK, KEY_BACK, constr, listeners[GO_BACK], bgr, image_size_percent=image_size)
        self.add_component(self.back_button)
        self.menu_buttons.append(self.back_button)
        
        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(KEY_PLAYER, KEY_PLAY_PAUSE, constr, listeners[KEY_PLAYER], bgr, image_size_percent=image_size)       
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)
예제 #4
0
    def set_tracks(self, tracks, page):
        """ Set tracks in menu
        
        :param tracks: list of tracks
        :param page: page number
        """
        if tracks == None:
            return
        self.tracks = tracks
        items = {}
        start_index = TRACKS_PER_PAGE * (page - 1)
        end_index = start_index + TRACKS_PER_PAGE

        layout = GridLayout(self.bb)
        layout.set_pixel_constraints(TRACK_ROWS, TRACK_COLUMNS, 1, 1)
        constr = layout.get_next_constraints()
        fixed_height = int((constr.h * LABEL_HEIGHT_PERCENT) / 100.0)

        for i, a in enumerate(self.tracks[start_index:end_index]):
            state = State()
            state.name = a["title"]
            state.l_name = state.name
            state.bgr = self.config[COLORS][COLOR_DARK]
            state.img_x = None
            state.img_y = None
            state.auto_update = True
            state.show_bgr = True
            state.show_img = False
            state.show_label = True
            state.comparator_item = state.name
            state.index = i
            state.fixed_height = fixed_height
            state.file_name = a["file_name"]
            items[state.name] = state
        self.set_items(items, 0, self.play_track, False)
예제 #5
0
class TimerNavigator(Container):
    """ Timer navigator menu """
    
    def __init__(self, util, bounding_box, listeners, bgr):
        """ Initializer
        
        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        :param bgr: menu background        
        """ 
        Container.__init__(self, util)
        self.config = util.config
        self.factory = Factory(util)
        self.name = "timer.navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []
        self.layout = GridLayout(bounding_box)            
        self.layout.set_pixel_constraints(1, 3, 1, 0)        
        self.layout.current_constraints = 0
        self.image_size = 64
        
        b = util.config[BACKGROUND][FOOTER_BGR_COLOR]
        self.home_button = self.add_button(KEY_HOME, KEY_HOME, listeners[KEY_HOME], b)
        self.sleep_now_button = self.add_button(SLEEP_NOW, KEY_MUTE, listeners[SLEEP_NOW], b)
        self.player_button = self.add_button(KEY_PLAYER, KEY_PLAY_PAUSE, listeners[KEY_PLAYER], b)
        
    def add_button(self, img_name, kbd_key, listener, b):
        """ Add button to the menu
        
        :param img_name: button image name
        :param kbd_key: keyboard key assigned to the button
        :param listener: button listener
        :param b: background color
        """
        constr = self.layout.get_next_constraints()
        button = self.factory.create_button(img_name, kbd_key, constr, listener, b, image_size_percent=self.image_size)
        self.add_component(button)
        self.menu_buttons.append(button)
        return button

    def set_parent_screen(self, scr):
        """ Add parent screen

        :param scr: parent screen
        """
        self.home_button.parent_screen = scr
        self.sleep_now_button.parent_screen = scr
        self.player_button.parent_screen = scr

    def add_observers(self, update_observer, redraw_observer):
        """ Add screen observers
        
        :param update_observer: observer for updating the screen
        :param redraw_observer: observer to redraw the whole screen
        """
        for b in self.menu_buttons:
            self.add_button_observers(b, update_observer, redraw_observer)       
예제 #6
0
class KeyboardNavigator(Container):
    """ Keyboard screen navigator menu """
    def __init__(self, util, bounding_box, listeners, show_visibility=True):
        """ Initializer

        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "keyboard.navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        if show_visibility:
            n = 5
        else:
            n = 4
        self.layout = GridLayout(bounding_box)
        self.layout.set_pixel_constraints(1, n, 1, 0)
        self.layout.current_constraints = 0
        self.bgr = util.config[COLORS][COLOR_DARK_LIGHT]

        self.add_button(KEY_HOME, KEY_HOME, listeners[KEY_HOME])
        self.add_button(KEY_BACK, KEY_BACK, listeners[KEY_BACK])
        self.add_button(KEY_DELETE, KEY_PARENT, listeners[KEY_DELETE])
        if n == 5:
            self.add_button(KEY_VIEW, KEY_SETUP, listeners[KEY_VIEW])
        self.add_button(KEY_PLAYER, KEY_PLAY_PAUSE, listeners[KEY_PLAYER])

    def add_button(self, img_name, key, listener):
        """ Add button

        :param img_name: button image name
        :param key: keyboard key
        :param listener: button listener
        """
        c = self.layout.get_next_constraints()
        b = self.factory.create_button(img_name,
                                       key,
                                       c,
                                       listener,
                                       self.bgr,
                                       image_size_percent=IMAGE_SIZE)
        self.add_component(b)
        self.menu_buttons.append(b)

    def add_observers(self, update_observer, redraw_observer):
        """ Add screen observers

        :param update_observer: observer for updating the screen
        :param redraw_observer: observer to redraw the whole screen
        """
        for b in self.menu_buttons:
            self.add_button_observers(b, update_observer, redraw_observer)
예제 #7
0
    def __init__(self, util, listeners, bgr=None, bounding_box=None):
        """ Initializer

        :param util: utility object
        :param listeners: menu listeners
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "saver.navigator"
        self.content = self.bounding_box = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        layout = GridLayout(bounding_box)

        layout.set_pixel_constraints(1, 3, 1, 0)
        layout.current_constraints = 0
        size = 64  # button image size in percent

        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(KEY_HOME, KEY_HOME,
                                                      constr,
                                                      listeners[KEY_HOME], bgr,
                                                      size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)

        constr = layout.get_next_constraints()
        self.start_saver_button = self.factory.create_button(
            KEY_START_SAVER, KEY_MENU, constr, listeners[KEY_START_SAVER], bgr,
            75)
        self.add_component(self.start_saver_button)
        self.menu_buttons.append(self.start_saver_button)

        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(
            KEY_PLAYER, KEY_PLAY_PAUSE, constr, listeners[KEY_PLAYER], bgr,
            size)
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)
예제 #8
0
    def __init__(self, util, bb, gap, digits, listener, timer_lock,
                 clock_change_callback, change_codes):
        """ Initializer
        
        :param util: utility object
        :param bb: menu bounding box
        :param gap: gap between hours and minutes
        :param digits: clock digits 0-9
        :param listener: the listener
        :param timer_lock: lock object
        :param clock_change_callback: callback function
        :param change_codes: change codes
        """
        self.util = util
        self.name = SLEEP + "_" + POWEROFF
        self.config = self.util.config
        self.factory = Factory(util)
        sleep_icon_size = 0.64
        poweroff_icon_size = 0.56
        Container.__init__(self, util, bb.CENTER)
        border_x = bb.RIGHT.x
        c = GridLayout(Rect(border_x + 1, bb.y + 1, bb.w - border_x, bb.h - 1))
        c.set_pixel_constraints(2, 1)
        self.bgr = (0, 0, 0, 0)

        self.sleep_selected = self.config[TIMER][SLEEP]
        self.poweroff_selected = self.config[TIMER][POWEROFF]

        self.clock = Clock(self.util, SLEEP, SLEEP_TIME, digits, bb,
                           timer_lock, clock_change_callback, change_codes)
        self.add_component(self.clock)

        s = c.get_next_constraints()
        self.sleep_button = self.add_button(SLEEP, s, kbd_keys[KEY_SETUP],
                                            self.sleep_selected,
                                            sleep_icon_size, listener)
        n = c.get_next_constraints()
        h = bb.h - s.height - 2
        r = Rect(n.x, n.y + 1, n.w, h)
        self.poweroff_button = self.add_button(POWEROFF, r, kbd_keys[KEY_END],
                                               self.poweroff_selected,
                                               poweroff_icon_size, listener)
        self.bounding_box = bb.CENTER
예제 #9
0
    def add_sliders(self, handle_slider_event):
        
        layout = GridLayout(self.eq_layout.CENTER)
        layout.set_pixel_constraints(1, self.bands, 0, 0)        
        layout.current_constraints = 0
        sliders = []

        for n in range(self.bands):        
            constr = layout.get_next_constraints()        
            s = self.factory.create_equalizer_slider(n, constr, "band", handle_slider_event, self.labels[n], self.bgr_color)
            s.slider.active = False
            s.content = None
            s.slider.content = None
            self.add_component(s)
            sliders.append(s)
        
        return sliders
예제 #10
0
 def get_filelist(self):
     """ Return CD tracks
     
     :return: page with CD tracks
     """
     rows = 5
     columns = 2
     
     layout = GridLayout(self.layout.CENTER)
     layout.set_pixel_constraints(rows, columns, 1, 1)
     constr = layout.get_next_constraints()        
     fixed_height = int((constr.h * 35)/100.0)
     
     tracks = self.cdutil.get_cd_tracks(rows, columns, fixed_height, self.current_cd_drive_name)
     if tracks == None: 
         tracks = []
     return Page(tracks, rows, columns)
예제 #11
0
    def __init__(self, util, connected_cd_drives, bounding_box, listeners):
        """ Initializer
        
        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []
        config = util.config

        arrow_layout = BorderLayout(bounding_box)
        arrow_layout.set_percent_constraints(0, 0, PERCENT_ARROW_WIDTH,
                                             PERCENT_ARROW_WIDTH)

        constr = arrow_layout.LEFT
        self.left_button = self.factory.create_page_down_button(
            constr, "0", 40, 100)
        self.left_button.add_release_listener(listeners[GO_LEFT_PAGE])
        self.add_component(self.left_button)
        self.menu_buttons.append(self.left_button)

        constr = arrow_layout.RIGHT
        self.right_button = self.factory.create_page_up_button(
            constr, "0", 40, 100)
        self.right_button.add_release_listener(listeners[GO_RIGHT_PAGE])
        self.add_component(self.right_button)
        self.menu_buttons.append(self.right_button)

        layout = GridLayout(arrow_layout.CENTER)
        p = config[AUDIO][PLAYER_NAME]
        show_drives = connected_cd_drives > 1 and (p == VLC_NAME
                                                   or p == MPD_NAME)

        if show_drives:
            layout.set_pixel_constraints(1, 5, 1, 0)
        else:
            layout.set_pixel_constraints(1, 4, 1, 0)
        layout.current_constraints = 0
        image_size = 56

        bgr = config[BACKGROUND][FOOTER_BGR_COLOR]
        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(
            KEY_HOME,
            KEY_HOME,
            constr,
            listeners[KEY_HOME],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)

        if show_drives:
            constr = layout.get_next_constraints()
            self.cd_drives_button = self.factory.create_button(
                KEY_CD_PLAYERS,
                KEY_ROOT,
                constr,
                listeners[KEY_CD_PLAYERS],
                bgr,
                image_size_percent=image_size)
            self.add_component(self.cd_drives_button)
            self.menu_buttons.append(self.cd_drives_button)

        constr = layout.get_next_constraints()
        self.refresh_button = self.factory.create_button(
            KEY_REFRESH,
            KEY_SETUP,
            constr,
            listeners[KEY_REFRESH],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.refresh_button)
        self.menu_buttons.append(self.refresh_button)

        constr = layout.get_next_constraints()
        self.eject_button = self.factory.create_button(
            KEY_EJECT,
            KEY_PARENT,
            constr,
            listeners[KEY_EJECT],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.eject_button)
        self.menu_buttons.append(self.eject_button)

        constr = layout.get_next_constraints()
        self.back_button = self.factory.create_button(
            KEY_BACK,
            KEY_BACK,
            constr,
            None,
            bgr,
            image_size_percent=image_size)
        self.back_button.add_release_listener(listeners[GO_BACK])
        self.back_button.add_release_listener(listeners[KEY_PLAYER])
        self.add_component(self.back_button)
        self.menu_buttons.append(self.back_button)
예제 #12
0
    def __init__(self, util, listeners, voice_assistant):
        """ Initializer

        :param util: utility object
        :param listeners: listeners
        :param voice_assistant: voice assistant
        """
        self.util = util
        self.config = util.config
        self.factory = Factory(util)
        self.check_internet_connectivity = listeners[KEY_CHECK_INTERNET]
        self.go_home = listeners[KEY_HOME]
        self.set_modes = listeners[KEY_SET_MODES]
        self.linux = self.config[LINUX_PLATFORM]

        self.wifi_util = WiFiUtil(util)
        self.bluetooth_util = self.util.get_bluetooth_util()

        self.bounding_box = util.screen_rect
        layout = BorderLayout(self.bounding_box)
        layout.set_percent_constraints(PERCENT_TOP_HEIGHT,
                                       PERCENT_BOTTOM_HEIGHT, 0, 0)

        rows = 7
        if self.linux and self.config[USAGE][USE_BLUETOOTH]:
            rows = 7
        else:
            rows = 6

        columns = 1
        d = [rows, columns]
        MenuScreen.__init__(self,
                            util,
                            listeners,
                            rows,
                            columns,
                            voice_assistant,
                            d,
                            None,
                            page_in_title=False,
                            show_loading=False)
        self.title = self.config[LABELS]["network"]
        self.set_title(1)

        center_layout = BorderLayout(self.menu_layout)
        center_layout.set_percent_constraints(0, 0, 47, 0)

        left_layout = center_layout.LEFT
        right_layout = center_layout.CENTER

        label_layout = GridLayout(left_layout)
        label_layout.set_pixel_constraints(rows, columns)
        label_layout.get_next_constraints()

        value_layout = GridLayout(right_layout)
        value_layout.set_pixel_constraints(rows, columns)
        value_layout.get_next_constraints()

        self.network_panel = Container(util, self.menu_layout)

        rect = pygame.Rect(self.menu_layout.x, self.menu_layout.y + 1,
                           self.menu_layout.w, self.menu_layout.h - 1)
        b = util.config[BACKGROUND][MENU_BGR_COLOR]
        bgr = Component(util, rect, 0, 0, self.menu_layout, bgr=b)
        bgr.name = "network.panel.bgr"
        self.network_panel.add_component(bgr)

        self.internet_label = self.add_label(label_layout, self.network_panel,
                                             1)
        self.ethernet_label = self.add_label(label_layout, self.network_panel,
                                             2)
        self.wifi_network_label = self.add_label(label_layout,
                                                 self.network_panel, 3)
        self.wifi_ip_label = self.add_label(label_layout, self.network_panel,
                                            4)
        if self.linux and self.config[USAGE][USE_BLUETOOTH]:
            self.bluetooth_label = self.add_label(label_layout,
                                                  self.network_panel, 5)

        self.internet = self.add_value(value_layout, self.network_panel, 1)
        self.ethernet_ip = self.add_value(value_layout, self.network_panel, 2)
        self.wifi_network = self.add_value(value_layout, self.network_panel, 3)
        self.wifi_ip = self.add_value(value_layout, self.network_panel, 4)
        if self.linux and self.config[USAGE][USE_BLUETOOTH]:
            self.bluetooth = self.add_value(value_layout, self.network_panel,
                                            5)

        self.add_component(self.network_panel)

        listeners[KEY_REFRESH] = self.set_current
        listeners[KEY_DISCONNECT] = self.disconnect_wifi
        listeners[KEY_BLUETOOTH_REMOVE] = self.remove_bluetooth_devices

        self.navigator = NetworkNavigator(self.util, self.layout.BOTTOM,
                                          listeners)
        self.navigator.components[0].set_selected(True)
        self.add_navigator(self.navigator)
        self.original_networks = None
        self.networks = None
        self.current_network = None
        self.current_wifi_network = None
        self.clicked = False
        Screen.link_borders(self, False)
예제 #13
0
    def __init__(self, util, listeners, bgr=None, bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param listeners: menu listeners
        :param bgr: menu background
        :param bounding_box: bounding box
        """   
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "home.navigator"
        self.content = self.bounding_box = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        layout = GridLayout(bounding_box)
        
        screensaver_available = util.is_screensaver_available()
        if screensaver_available:
            n = 5
        else:
            n = 4
            
        if util.config[HOME_MENU][EQUALIZER]:
            n += 1
        
        layout.set_pixel_constraints(1, n, 1, 0)        
        layout.current_constraints = 0
        size = 64 # button image size in percent
        
        constr = layout.get_next_constraints()
        self.back_button = self.factory.create_button(KEY_BACK, KEY_BACK, constr, listeners[KEY_BACK], bgr, size)
        self.add_component(self.back_button)
        self.menu_buttons.append(self.back_button)
        
        if screensaver_available:
            constr = layout.get_next_constraints()
            self.saver_button = self.factory.create_button(SCREENSAVER, KEY_SETUP, constr, listeners[SCREENSAVER], bgr, size)
            self.add_component(self.saver_button)
            self.menu_buttons.append(self.saver_button)
        
        constr = layout.get_next_constraints()
        self.language_button = self.factory.create_button(LANGUAGE, KEY_MENU, constr, listeners[LANGUAGE], bgr, size)
        self.add_component(self.language_button)
        self.menu_buttons.append(self.language_button)
        
        if util.config[HOME_MENU][EQUALIZER]:
            constr = layout.get_next_constraints()
            self.equalizer_button = self.factory.create_button(EQUALIZER, KEY_ROOT, constr, listeners[EQUALIZER], bgr, size)
            self.add_component(self.equalizer_button)
            self.menu_buttons.append(self.equalizer_button)
        
        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(KEY_PLAYER, KEY_PLAY_PAUSE, constr, listeners[KEY_PLAYER], bgr, size)
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)

        constr = layout.get_next_constraints()
        self.about_button = self.factory.create_button(KEY_ABOUT, KEY_HOME, constr, listeners[KEY_ABOUT], bgr, size)
        self.add_component(self.about_button)
        self.menu_buttons.append(self.about_button)
예제 #14
0
    def __init__(self, util, listener):
        """ Initializer
        
        :param util: utility object
        :Param listener: screen listener
        """
        self.name = KEY_INFO
        self.util = util
        self.config = util.config
        self.factory = Factory(util)
        self.listener = listener

        self.bg = self.util.get_background(self.name)
        self.bgr_type = self.bg[0]
        self.bgr = self.bg[1]
        self.bgr_key = self.bg[5]

        self.screen_w = self.config[SCREEN_INFO][WIDTH]
        self.screen_h = self.config[SCREEN_INFO][HEIGHT]
        self.lines = 14
        font_vertical_percent = 6
        self.bounding_box = util.screen_rect
        Container.__init__(self,
                           util,
                           self.bounding_box,
                           background=self.bg[1],
                           content=self.bg[2],
                           image_filename=self.bg[3])

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

        center_layout = BorderLayout(self.bounding_box)
        center_layout.set_percent_constraints(0, 0, 44, 0)

        left_layout = center_layout.LEFT
        right_layout = center_layout.CENTER

        label_layout = GridLayout(left_layout)
        label_layout.set_pixel_constraints(self.lines, 1)
        label_layout.get_next_constraints()
        bb1 = label_layout.get_next_constraints()

        value_layout = GridLayout(right_layout)
        value_layout.set_pixel_constraints(self.lines, 1)
        value_layout.get_next_constraints()
        bb2 = value_layout.get_next_constraints()

        title_bb = pygame.Rect(bb1.x, bb1.y, bb1.w + bb2.w, bb1.h)
        self.title = self.add_title(title_bb)

        label_layout.get_next_constraints()
        self.add_label(label_layout, 1, self.config[LABELS]["file.size"] + ":")
        self.add_label(label_layout, 2,
                       self.config[LABELS]["sample.rate"] + ":")
        self.add_label(label_layout, 3, self.config[LABELS]["channels"] + ":")
        self.add_label(label_layout, 4,
                       self.config[LABELS]["bits.per.sample"] + ":")
        self.add_label(label_layout, 5, self.config[LABELS]["bit.rate"] + ":")

        label_layout.get_next_constraints()
        self.add_label(label_layout, 6, self.config[LABELS][GENRE] + ":")
        self.add_label(label_layout, 7, self.config[LABELS][ARTIST] + ":")
        self.add_label(label_layout, 8, self.config[LABELS][ALBUM] + ":")
        self.add_label(label_layout, 9, self.config[LABELS][DATE] + ":")

        value_layout.get_next_constraints()
        self.filesize = self.add_value(value_layout, 1)
        self.sample_rate = self.add_value(value_layout, 2)
        self.channels = self.add_value(value_layout, 3)
        self.bits = self.add_value(value_layout, 4)
        self.bit_rate = self.add_value(value_layout, 5)

        value_layout.get_next_constraints()
        self.genre = self.add_value(value_layout, 6)
        self.artist = self.add_value(value_layout, 7)
        self.album = self.add_value(value_layout, 8)
        self.date = self.add_value(value_layout, 9)

        self.values = [
            self.filesize, self.sample_rate, self.channels, self.bits,
            self.bit_rate, self.genre, self.artist, self.album, self.date
        ]
예제 #15
0
    def __init__(self, util, bounding_box, listeners, pages):
        """ Initializer

        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        :param pages: number of menu pages
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "bt.navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        bgr = util.config[COLORS][COLOR_DARK_LIGHT]

        arrow_layout = BorderLayout(bounding_box)
        arrow_layout.set_percent_constraints(0, 0, PERCENT_ARROW_WIDTH,
                                             PERCENT_ARROW_WIDTH)

        if pages > 1:
            constr = arrow_layout.LEFT
            self.left_button = self.factory.create_page_down_button(
                constr, "0", 40, 100)
            self.left_button.add_release_listener(listeners[GO_LEFT_PAGE])
            self.add_component(self.left_button)
            self.menu_buttons.append(self.left_button)

            constr = arrow_layout.RIGHT
            self.right_button = self.factory.create_page_up_button(
                constr, "0", 40, 100)
            self.right_button.add_release_listener(listeners[GO_RIGHT_PAGE])
            self.add_component(self.right_button)
            self.menu_buttons.append(self.right_button)
            layout = GridLayout(arrow_layout.CENTER)
        else:
            layout = GridLayout(bounding_box)

        layout.set_pixel_constraints(1, 4, 1, 0)
        layout.current_constraints = 0
        image_size = 64

        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(
            KEY_HOME,
            KEY_HOME,
            constr,
            listeners[KEY_HOME],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)

        constr = layout.get_next_constraints()
        self.sort_strength = self.factory.create_button(
            KEY_REFRESH,
            KEY_SETUP,
            constr,
            listeners[KEY_REFRESH],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.sort_strength)
        self.menu_buttons.append(self.sort_strength)

        constr = layout.get_next_constraints()
        self.network_button = self.factory.create_button(
            KEY_NETWORK,
            KEY_BACK,
            constr,
            listeners[KEY_NETWORK],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.network_button)
        self.menu_buttons.append(self.network_button)

        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(
            KEY_PLAYER,
            KEY_PLAY_PAUSE,
            constr,
            listeners[KEY_PLAYER],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)
예제 #16
0
    def __init__(self, util, bounding_box, listeners, bgr):
        """ Initializer
        
        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        :param bgr: menu background        
        """ 
        Container.__init__(self, util, content="nav")
        self.factory = Factory(util)
        self.name = "navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        arrow_layout = BorderLayout(bounding_box)
        arrow_layout.set_percent_constraints(0, 0, PERCENT_ARROW_WIDTH, PERCENT_ARROW_WIDTH)
        
        constr = arrow_layout.LEFT
        self.left_button = self.factory.create_page_down_button(constr, "0", 40, 100)
        self.left_button.add_release_listener(listeners[GO_LEFT_PAGE])
        self.add_component(self.left_button)
        self.menu_buttons.append(self.left_button)
        
        constr = arrow_layout.RIGHT
        self.right_button = self.factory.create_page_up_button(constr, "0", 40, 100)
        self.right_button.add_release_listener(listeners[GO_RIGHT_PAGE])
        self.add_component(self.right_button)
        self.menu_buttons.append(self.right_button)
        
        layout = GridLayout(arrow_layout.CENTER)
        layout.set_pixel_constraints(1, 5, 1, 0)        
        layout.current_constraints = 0
        image_size = 64 
        
        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(KEY_HOME, KEY_HOME, constr, listeners[KEY_HOME], bgr, image_size_percent=image_size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)
        
        constr = layout.get_next_constraints()
        self.user_home_button = self.factory.create_button(KEY_USER_HOME, KEY_MENU, constr, listeners[GO_USER_HOME], bgr, image_size_percent=image_size)
        self.add_component(self.user_home_button)
        self.menu_buttons.append(self.user_home_button)
        
        constr = layout.get_next_constraints()
        self.root_button = self.factory.create_button(KEY_ROOT, KEY_ROOT, constr, listeners[GO_ROOT], bgr, image_size_percent=image_size)
        self.add_component(self.root_button)
        self.menu_buttons.append(self.root_button)

        constr = layout.get_next_constraints()
        self.parent_button = self.factory.create_button(KEY_PARENT, KEY_PARENT, constr, listeners[GO_TO_PARENT], bgr, image_size_percent=image_size)
        self.add_component(self.parent_button)
        self.menu_buttons.append(self.parent_button)

        constr = layout.get_next_constraints()
        self.back_button = self.factory.create_button(KEY_BACK, KEY_BACK, constr, None, bgr, image_size_percent=image_size)
        self.back_button.add_release_listener(listeners[GO_BACK])
        self.back_button.add_release_listener(listeners[KEY_PLAY_FILE])
        self.add_component(self.back_button)
        self.menu_buttons.append(self.back_button)
예제 #17
0
파일: menu.py 프로젝트: project-owner/Peppy
class Menu(Container):
    """ Base class for all menu components.     
    Extends Component class. 
    Consists of Button components 
    """    
    def __init__(self, util, bgr=None, bb=None, rows=3, cols=3, create_item_method=None):
        """ Initializer
        
        :param util: utility object
        :param bgr: menu background
        :param bb: bounding box
        :param rows: number of rows in menu
        :param cols: number of columns in menu
        :param create_item_method: factory method for menu item creation
        """        
        Container.__init__(self, util, bb, bgr)
        self.rows = rows
        self.cols = cols
        self.start_listeners = []
        self.move_listeners = []
        self.layout = GridLayout(bb)
        self.layout.set_pixel_constraints(self.rows, self.cols, 1, 1)        
        self.items = {}
        self.buttons = {}
        self.factory = Factory(util)
        self.create_item_method = create_item_method
        self.selected_index = None
        
    def set_items(self, it, page_index, listener, scale=True, order=None):
        """ Set menu items
        
        :param it: menu items
        :param page_index: menu page number
        :param listener: event listener
        :param scale: True - scale menu items, False - don't scale menu items
        :param order: map defining the order or menu items
        """
        self.layout.current_constraints = 0
        self.components = []
        self.items = it        
        self.buttons = dict()
        if not order:
            sorted_items = sorted(it.values(), key=attrgetter('index'))
        else:
            sorted_items = self.sort_items(it.items(), order)         
        
        for index, item in enumerate(sorted_items):
            i = getattr(item, "index", None)
            if not i:
                item.index = index
            constr = self.layout.get_next_constraints()
            button = self.create_item_method(item, constr, listener, scale)
            button.add_release_listener(self.item_selected)
            comp_name = ""
            if item.name:
                comp_name = item.name
            self.add_component(button)
            self.buttons[comp_name] = button

    def sort_items(self, d, order):
        """ Sort items according to the specified order
        
        :param d: items to sort
        :param order: order of menu items
        """
        sorted_items = [None] * len(d)
        for t in d:
            k = t[0]
            index = int(order[k.lower()]) - 1            
            sorted_items[index] = t[1]
        return sorted_items 

    def item_selected(self, state):
        """ Handle menu item selection
        
        :param state: button state
        """
        for button in self.buttons.values():
            b_comp = getattr(button.state, "comparator_item", None)
            s_comp = getattr(state, "comparator_item", None)
            if b_comp != None and s_comp != None and b_comp == s_comp:
                button.set_selected(True)
                self.selected_index = button.state.index                
            else:
                button.set_selected(False)
                
    def add_listener(self, listener):
        """ Add menu event listener
        
        :param listener: event listener
        """
        if listener not in self.start_listeners:
            self.start_listeners.append(listener)
            
    def notify_listeners(self, state):
        """ Notify all menu listeners
        
        :param state: button state
        """
        for listener in self.start_listeners:
            listener(state)
            
    def add_move_listener(self, listener):
        """ Add arrow button event listener
        
        :param listener: event listener
        """
        if listener not in self.move_listeners:
            self.move_listeners.append(listener)
            
    def notify_move_listeners(self):
        """ Notify arrow button event listeners
        
        :param state: button state
        """
        for listener in self.move_listeners:
            listener(None)
            
    def unselect(self):
        """ Unselect currently selected button
        
        :return: index of the button which was selected
        """
        for button in self.buttons.values():
            if button.selected:
                button.set_selected(False)
                button.clean_draw_update()
                return button.state.index
    
    def get_selected_index(self):
        """ Return the index of the button which was selected
        
        :return: index of the selected button
        """
        for button in self.buttons.values():
            if button.selected:
                return button.state.index
        return None
    
    def select_by_index(self, index):
        """ Select button by specified index
        
        :param index: button index
        """
        for button in self.buttons.values():
            if button.state.index == index:
                button.set_selected(True)
                button.clean_draw_update()
                self.selected_index = index
                self.notify_move_listeners()
                break
    
    def select_action(self):
        """ Notify listeners of the selected button """
        
        for button in self.buttons.values():
            if button.state.index == self.selected_index:
                button.notify_release_listeners(button.state)
                break
            
    def is_enabled(self, i):
        """ Check if the button is enabled. 
        Disabled buttons have enabled flag set to False. 
        Enabled buttons don't have this flag  
        
        :param index: button index
        :return: True - button enabled, False - button disabled
        """
        for button in self.buttons.values():
            enabled = getattr(button.state, "enabled", None)
            if button.state.index == i and enabled == None:
                return True
        return False
       
    def handle_event(self, event):
        """ Menu event handler
        
        :param event: menu event
        """
        if not self.visible: return
        
        if event.type == USER_EVENT_TYPE and event.sub_type == SUB_TYPE_KEYBOARD and event.action == pygame.KEYUP:
            key_events = [kbd_keys[KEY_LEFT], kbd_keys[KEY_RIGHT], kbd_keys[KEY_UP], kbd_keys[KEY_DOWN]]            
            if event.keyboard_key in key_events:
                i = self.get_selected_index()
                if i == None:
                    return
                col = int(i % self.cols)
                row = int(i / self.cols)
            
            if event.keyboard_key == kbd_keys[KEY_SELECT]:
                self.select_action()
                return
             
            if event.keyboard_key == kbd_keys[KEY_LEFT]:                              
                if col == 0:
                    i = i + self.cols - 1
                else:
                    i = i - 1                
            elif event.keyboard_key == kbd_keys[KEY_RIGHT]:
                if col == self.cols - 1:
                    i = i - self.cols + 1
                else:
                    i = i + 1
            elif event.keyboard_key == kbd_keys[KEY_UP]:
                if row == 0:
                    i = i + (self.rows - 1) * self.cols
                else:
                    i = i - self.cols
            elif event.keyboard_key == kbd_keys[KEY_DOWN]:
                if row == self.rows - 1:
                    i = int(i % self.cols)
                else:
                    i = i + self.cols
                
            if self.is_enabled(i):
                self.unselect()
                self.select_by_index(i)                  
        else:
            Container.handle_event(self, event) 

            
예제 #18
0
    def __init__(self, util, listeners, bgr=None, bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param listeners: menu listeners
        :param bgr: menu background
        :param bounding_box: bounding box
        """   
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "home.navigator"
        self.content = self.bounding_box = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        layout = GridLayout(bounding_box)
        n = 0
        screensaver_available = util.is_screensaver_available()

        if util.config[HOME_NAVIGATOR][HOME_BACK]:
            n += 1
        if screensaver_available and util.config[HOME_NAVIGATOR][HOME_SCREENSAVER]:
            n += 1
        if util.config[HOME_NAVIGATOR][HOME_LANGUAGE]:
            n += 1
        if util.config[HOME_NAVIGATOR][EQUALIZER]:
            n += 1
        if util.config[HOME_NAVIGATOR][TIMER]:
            n += 1
        if util.config[HOME_NAVIGATOR][NETWORK]:
            n += 1
        if util.config[HOME_NAVIGATOR][PLAYER]:
            n += 1
        if util.config[HOME_NAVIGATOR][ABOUT]:
            n += 1

        if n == 0:
            return

        layout.set_pixel_constraints(1, n, 1, 0)
        layout.current_constraints = 0
        size = 64 # button image size in percent

        b = util.config[BACKGROUND][FOOTER_BGR_COLOR]

        if util.config[HOME_NAVIGATOR][HOME_BACK]:
            constr = layout.get_next_constraints()
            self.back_button = self.factory.create_button(KEY_BACK, KEY_BACK, constr, listeners[KEY_BACK], b, size)
            self.add_component(self.back_button)
            self.menu_buttons.append(self.back_button)
        
        if screensaver_available and util.config[HOME_NAVIGATOR][HOME_SCREENSAVER]:
            constr = layout.get_next_constraints()
            self.saver_button = self.factory.create_button(SCREENSAVER, KEY_SETUP, constr, listeners[SCREENSAVER], b, size)
            self.add_component(self.saver_button)
            self.menu_buttons.append(self.saver_button)

        if util.config[HOME_NAVIGATOR][HOME_LANGUAGE]:
            constr = layout.get_next_constraints()
            self.language_button = self.factory.create_button(LANGUAGE, KEY_MENU, constr, listeners[LANGUAGE], b, size)
            self.add_component(self.language_button)
            self.menu_buttons.append(self.language_button)
        
        if util.config[HOME_NAVIGATOR][EQUALIZER]:
            constr = layout.get_next_constraints()
            self.equalizer_button = self.factory.create_button(EQUALIZER, KEY_ROOT, constr, listeners[EQUALIZER], b, size)
            self.add_component(self.equalizer_button)
            self.menu_buttons.append(self.equalizer_button)
            
        if util.config[HOME_NAVIGATOR][TIMER]:
            constr = layout.get_next_constraints()
            self.timer_button = self.factory.create_button(TIMER, KEY_AUDIO, constr, listeners[TIMER], b, size)
            self.add_component(self.timer_button)
            self.menu_buttons.append(self.timer_button)

        if util.config[HOME_NAVIGATOR][NETWORK]:
            constr = layout.get_next_constraints()
            self.network_button = self.factory.create_button(NETWORK, KEY_SUBTITLE, constr, listeners[NETWORK], b, size)
            self.add_component(self.network_button)
            self.menu_buttons.append(self.network_button)

        if util.config[HOME_NAVIGATOR][PLAYER]:
            constr = layout.get_next_constraints()
            self.player_button = self.factory.create_button(KEY_PLAYER, KEY_PLAY_PAUSE, constr, listeners[KEY_PLAYER], b, size)
            self.add_component(self.player_button)
            self.menu_buttons.append(self.player_button)

        if util.config[HOME_NAVIGATOR][ABOUT]:
            constr = layout.get_next_constraints()
            self.about_button = self.factory.create_button(KEY_ABOUT, KEY_HOME, constr, listeners[KEY_ABOUT], b, size)
            self.add_component(self.about_button)
            self.menu_buttons.append(self.about_button)
예제 #19
0
    def __init__(self,
                 items,
                 util,
                 bounding_box,
                 update_parent,
                 callback,
                 default_selection=None):
        """ Initializer

        :param items: list of item names
        :param util: utility object
        :param bounding_box: bounding box
        :param update_parent: redraw parent function
        :param callback: menu selection callback
        """
        Container.__init__(self, util, bounding_box, (0, 0, 0))
        self.util = util
        self.factory = Factory(util)
        self.config = util.config
        self.update_parent = update_parent
        self.callback = callback
        self.popup = True

        c = Component(self.util)
        w = self.config[SCREEN_INFO][WIDTH]
        h = self.config[SCREEN_INFO][HEIGHT]
        c.content = pygame.Rect(0, 0, w, h)
        c.content_x = 0
        c.content_y = 0
        c.bounding_box = c.content
        c.bgr = (0, 0, 0, 0)
        c.name = "popup.overlay.bgr"
        c.handle_event = self.handle_outside_event
        self.add_component(c)

        c = Component(self.util)
        c.content = pygame.Rect(bounding_box.x, bounding_box.y, bounding_box.w,
                                bounding_box.h - 1)
        c.content_x = 0
        c.content_y = 0
        c.bounding_box = c.content
        c.bgr = self.config[COLORS][COLOR_BRIGHT]
        c.name = "popup.bgr"
        self.add_component(c)

        self.cols = 1
        self.rows = len(items)

        m = self.create_popup_menu_button
        b = pygame.Rect(bounding_box.x, bounding_box.y, bounding_box.w,
                        bounding_box.h - 2)
        self.menu = Menu(util,
                         None,
                         b,
                         self.rows,
                         self.cols,
                         create_item_method=m)

        layout = GridLayout(self.menu.bb)
        layout.set_pixel_constraints(self.rows, self.cols, 1, 1)
        bounding_box = layout.get_next_constraints()
        self.modes = self.util.load_menu(items,
                                         NAME, [],
                                         V_ALIGN_TOP,
                                         bb=bounding_box,
                                         scale=IMAGE_SCALE)

        if not default_selection:
            selection = self.modes[items[0]]
        else:
            selection = self.modes[default_selection]

        self.menu.set_items(self.modes, 0, self.select_item, False)
        self.menu.visible = False
        self.menu.item_selected(selection)
        self.add_component(self.menu)

        self.redraw_observer = None
        self.clicked = False
        self.visible = False
예제 #20
0
파일: timer.py 프로젝트: thekismet/Peppy
    def __init__(self, util, listeners, voice_assistant, timer_lock, start_timer_thread):
        """ Initializer
        
        :param util: utility object
        :param listeners: screen navigator listeners
        :param voice_assistant: voice assistant
        :param timer_lock: lock object
        :param start_timer_thread: start timer thread function
        """
        self.util = util
        self.timer_lock = timer_lock
        self.start_timer_thread = start_timer_thread
        self.config = util.config
        self.screen_layout = BorderLayout(util.screen_rect)
        self.screen_layout.set_percent_constraints(PERCENT_TITLE, PERCENT_NAV_HEIGHT, 0, 0)        
        Screen.__init__(self, util, "", PERCENT_NAV_HEIGHT, voice_assistant, "timer_title", title_layout=self.screen_layout.TOP)                
        self.bounding_box = util.screen_rect
        label = self.config[LABELS][TIMER]
        self.screen_title.set_text(label)
        
        try:
            self.config[TIMER]
        except:
            self.config[TIMER] = {}
        
        c = GridLayout(self.screen_layout.CENTER)
        c.set_pixel_constraints(2, 1)
        layout = BorderLayout(c.get_next_constraints())
        layout.set_percent_constraints(0, 0, PERCENT_CLOCK, 100 - PERCENT_CLOCK)
        gap = layout.h * 0.1
        layout.LEFT.w -= gap * 3
        layout.LEFT.h -= gap
        digits = util.image_util.get_flipclock_digits(layout.LEFT)
        
        change_codes = [HOURS_INCREMENT_SLEEP, MINUTES_INCREMENT_SLEEP, HOURS_DECREMENT_SLEEP, MINUTES_DECREMENT_SLEEP]
        self.sleep_menu = SleepMenu(util, layout, gap, digits, self.handle_button, timer_lock, self.sleep_change_callback, change_codes)
        self.sleep_menu.clock.select_key(self.sleep_menu.clock.h_top)
        self.active_key_menu = self.sleep_menu
        self.add_component(self.sleep_menu)
        self.menu_index = HOURS_INCREMENT_SLEEP
        self.sleep_menu.clock.add_change_listener(self.handle_clock_change)
        
        layout = BorderLayout(c.get_next_constraints())
        layout.set_percent_constraints(0, 0, PERCENT_CLOCK, 100 - PERCENT_CLOCK)
        
        change_codes = [HOURS_INCREMENT_WAKE_UP, MINUTES_INCREMENT_WAKE_UP, HOURS_DECREMENT_WAKE_UP, MINUTES_DECREMENT_WAKE_UP]
        self.wake_up_menu = WakeUpMenu(util, layout, gap, digits, self.handle_button, timer_lock, self.wake_up_change_callback, change_codes)
        self.add_component(self.wake_up_menu)
        self.wake_up_menu.clock.add_change_listener(self.handle_clock_change)
        
        self.navigator = TimerNavigator(self.util, self.screen_layout.BOTTOM, listeners, self.config[COLORS][COLOR_DARK_LIGHT])
        self.add_component(self.navigator)
        
        self.menu_functions = {
            HOURS_INCREMENT_SLEEP: self.sleep_menu.clock.increment_hours,
            MINUTES_INCREMENT_SLEEP: self.sleep_menu.clock.increment_minutes,
            HOURS_DECREMENT_SLEEP: self.sleep_menu.clock.decrement_hours,
            MINUTES_DECREMENT_SLEEP: self.sleep_menu.clock.decrement_minutes,
            HOURS_INCREMENT_WAKE_UP: self.wake_up_menu.clock.increment_hours,
            MINUTES_INCREMENT_WAKE_UP: self.wake_up_menu.clock.increment_minutes,
            HOURS_DECREMENT_WAKE_UP: self.wake_up_menu.clock.decrement_hours,
            MINUTES_DECREMENT_WAKE_UP: self.wake_up_menu.clock.decrement_minutes
        }

        self.clean_draw_update()
예제 #21
0
    def __init__(self, util, bounding_box, name, items, arrow_items=None):
        """ Initializer
        
        :param util: utility object
        :param bounding_box: bounding box
        :param name: navigator name
        :param items: dictionary with button details
        :param arrow_items: dictionary with arrow buttons details
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = name
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.buttons = []

        if arrow_items:
            arrow_layout = BorderLayout(bounding_box)
            left_arrow = arrow_items[0]
            listeners = left_arrow[LISTENER]
            arrow_layout.set_percent_constraints(0, 0, PERCENT_ARROW_WIDTH,
                                                 PERCENT_ARROW_WIDTH)
            constr = arrow_layout.LEFT
            button = self.factory.create_page_down_button(constr, "0", 40, 100)
            button.add_release_listener(listeners[0])
            self.add_component(button)
            self.buttons.append(button)
            layout = GridLayout(arrow_layout.CENTER)
        else:
            layout = GridLayout(bounding_box)

        layout.set_pixel_constraints(1, len(items), 1, 0)
        layout.current_constraints = 0
        image_size = 64
        b = util.config[BACKGROUND][FOOTER_BGR_COLOR]

        for item in items:
            constr = layout.get_next_constraints()
            image_name = item[IMAGE_NAME]
            listeners = item[LISTENER]
            keybiard_key = item[KEYBOARD_KEY]
            source = item[SOURCE]

            if len(listeners) == 1:
                button = self.factory.create_button(
                    image_name,
                    keybiard_key,
                    constr,
                    listeners[0],
                    b,
                    image_size_percent=image_size,
                    source=source)
            else:
                button = self.factory.create_button(
                    image_name,
                    keybiard_key,
                    constr,
                    None,
                    b,
                    image_size_percent=image_size,
                    source=source)
                for listener in listeners:
                    button.add_release_listener(listener)

            self.add_component(button)
            self.buttons.append(button)

        if arrow_items:
            right_arrow = arrow_items[1]
            listeners = right_arrow[LISTENER]
            constr = arrow_layout.RIGHT
            button = self.factory.create_page_up_button(constr, "0", 40, 100)
            button.add_release_listener(listeners[0])
            self.add_component(button)
            self.buttons.append(button)
예제 #22
0
    def __init__(self, util, bounding_box, listeners, bgr, language_url=None):
        """ Initializer
        
        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        :param bgr: menu background
        :param language_url: language constant        
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "navigator"
        arrow_layout = BorderLayout(bounding_box)
        arrow_layout.set_percent_constraints(0, 0, PERCENT_ARROW_WIDTH,
                                             PERCENT_ARROW_WIDTH)
        self.menu_buttons = []

        constr = arrow_layout.LEFT
        self.left_button = self.factory.create_page_down_button(
            constr, "0", 34, 100)
        self.left_button.add_release_listener(listeners[GO_LEFT_PAGE])
        self.add_component(self.left_button)
        self.menu_buttons.append(self.left_button)

        constr = arrow_layout.RIGHT
        self.right_button = self.factory.create_page_up_button(
            constr, "0", 34, 100)
        self.right_button.add_release_listener(listeners[GO_RIGHT_PAGE])
        self.add_component(self.right_button)
        self.menu_buttons.append(self.right_button)

        layout = GridLayout(arrow_layout.CENTER)
        if language_url == "":  # English-USA
            buttons = 5
        elif language_url == None:  #Russian
            buttons = 6
        else:
            buttons = 4
        layout.set_pixel_constraints(1, buttons, 1, 0)
        layout.current_constraints = 0
        image_size = 56

        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(
            KEY_HOME,
            KEY_HOME,
            constr,
            listeners[KEY_HOME],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)

        if language_url == None:
            constr = layout.get_next_constraints()
            self.abc_button = self.factory.create_button(
                IMAGE_ABC,
                KEY_SETUP,
                constr,
                listeners[GO_USER_HOME],
                bgr,
                image_size_percent=image_size)
            self.add_component(self.abc_button)
            self.menu_buttons.append(self.abc_button)

        constr = layout.get_next_constraints()
        self.new_books_button = self.factory.create_button(
            IMAGE_NEW_BOOKS,
            KEY_MENU,
            constr,
            listeners[GO_ROOT],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.new_books_button)
        self.menu_buttons.append(self.new_books_button)

        if language_url == None or language_url == "":  # English-USA or Russian
            constr = layout.get_next_constraints()
            self.genre_button = self.factory.create_button(
                IMAGE_BOOK_GENRE,
                KEY_ROOT,
                constr,
                listeners[GO_TO_PARENT],
                bgr,
                image_size_percent=image_size)
            self.add_component(self.genre_button)
            self.menu_buttons.append(self.genre_button)

        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(
            IMAGE_PLAYER,
            KEY_PLAY_PAUSE,
            constr,
            listeners[GO_PLAYER],
            bgr,
            source=BOOK_NAVIGATOR,
            image_size_percent=image_size)
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)

        constr = layout.get_next_constraints()
        self.back_button = self.factory.create_button(
            KEY_BACK,
            KEY_BACK,
            constr,
            None,
            bgr,
            source=BOOK_NAVIGATOR_BACK,
            image_size_percent=image_size)
        self.back_button.add_release_listener(listeners[GO_BACK])
        try:
            self.back_button.add_release_listener(listeners[KEY_PLAY_FILE])
        except:
            pass
        self.add_component(self.back_button)
        self.menu_buttons.append(self.back_button)
예제 #23
0
    def __init__(self, util, bounding_box, listeners):
        """ Initializer

        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "keyboard.navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        layout = GridLayout(bounding_box)
        layout.set_pixel_constraints(1, 5, 1, 0)
        layout.current_constraints = 0
        image_size = 64
        bgr = util.config[COLORS][COLOR_DARK_LIGHT]

        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(
            KEY_HOME,
            KEY_HOME,
            constr,
            listeners[KEY_HOME],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)

        constr = layout.get_next_constraints()
        self.back = self.factory.create_button(KEY_BACK,
                                               KEY_BACK,
                                               constr,
                                               listeners[KEY_BACK],
                                               bgr,
                                               image_size_percent=image_size)
        self.add_component(self.back)
        self.menu_buttons.append(self.back)

        constr = layout.get_next_constraints()
        self.delete = self.factory.create_button(KEY_DELETE,
                                                 KEY_PARENT,
                                                 constr,
                                                 listeners[KEY_DELETE],
                                                 bgr,
                                                 image_size_percent=image_size)
        self.add_component(self.delete)
        self.menu_buttons.append(self.delete)

        constr = layout.get_next_constraints()
        self.delete = self.factory.create_button(KEY_VIEW,
                                                 KEY_SETUP,
                                                 constr,
                                                 listeners[KEY_VIEW],
                                                 bgr,
                                                 image_size_percent=image_size)
        self.add_component(self.delete)
        self.menu_buttons.append(self.delete)

        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(
            KEY_PLAYER,
            KEY_PLAY_PAUSE,
            constr,
            listeners[KEY_PLAYER],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)
예제 #24
0
    def __init__(self, util, listeners, voice_assistant):
        """ Initializer

        :param util: utility object
        :param listeners: listeners
        :param voice_assistant: voice assistant
        """
        self.util = util
        self.config = util.config
        self.factory = Factory(util)
        self.check_internet_connectivity = listeners[KEY_CHECK_INTERNET]
        self.go_home = listeners[KEY_HOME]
        self.set_modes = listeners[KEY_SET_MODES]

        self.wifi_util = WiFiUtil(util)
        self.bounding_box = util.screen_rect
        layout = BorderLayout(self.bounding_box)
        layout.set_percent_constraints(PERCENT_TOP_HEIGHT,
                                       PERCENT_BOTTOM_HEIGHT, 0, 0)

        d = [6, 1]
        MenuScreen.__init__(self,
                            util,
                            listeners,
                            6,
                            1,
                            voice_assistant,
                            d,
                            None,
                            page_in_title=False,
                            show_loading=False)
        self.title = self.config[LABELS]["network"]
        self.set_title(1)

        center_layout = BorderLayout(self.menu_layout)
        center_layout.set_percent_constraints(0, 0, 47, 0)

        left_layout = center_layout.LEFT
        right_layout = center_layout.CENTER

        label_layout = GridLayout(left_layout)
        label_layout.set_pixel_constraints(6, 1)
        label_layout.get_next_constraints()

        value_layout = GridLayout(right_layout)
        value_layout.set_pixel_constraints(6, 1)
        value_layout.get_next_constraints()

        self.network_panel = Container(util, self.menu_layout, (100, 0, 0))

        rect = pygame.Rect(self.menu_layout.x, self.menu_layout.y + 1,
                           self.menu_layout.w, self.menu_layout.h - 1)
        bgr = Component(util, rect, 0, 0, self.menu_layout, (0, 0, 0),
                        self.util.config[COLORS][COLOR_DARK])
        bgr.name = "network.panel.bgr"
        self.network_panel.add_component(bgr)

        self.internet_label = self.add_label(label_layout, self.network_panel,
                                             1)
        self.ethernet_label = self.add_label(label_layout, self.network_panel,
                                             2)
        self.wifi_network_label = self.add_label(label_layout,
                                                 self.network_panel, 3)
        self.wifi_ip_label = self.add_label(label_layout, self.network_panel,
                                            4)

        self.internet = self.add_value(value_layout, self.network_panel, 1)
        self.ethernet_ip = self.add_value(value_layout, self.network_panel, 2)
        self.wifi_network = self.add_value(value_layout, self.network_panel, 3)
        self.wifi_ip = self.add_value(value_layout, self.network_panel, 4)

        self.set_menu(self.network_panel)

        listeners[KEY_REFRESH] = self.set_current
        listeners[KEY_DISCONNECT] = self.disconnect_wifi

        self.navigator = NetworkNavigator(self.util, self.layout.BOTTOM,
                                          listeners)
        self.components.append(self.navigator)
        self.original_networks = None
        self.networks = None
        self.current_network = None
        self.current_wifi_network = None
        self.clicked = False
예제 #25
0
    def __init__(self,
                 util,
                 home_listener,
                 player_listener,
                 presets_listener,
                 bgr=None,
                 bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param listeners: menu listeners
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "equalizer.navigator"
        self.content = self.bounding_box = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        layout = GridLayout(bounding_box)
        layout.set_pixel_constraints(1, 8, 1, 0)
        layout.current_constraints = 0
        size = 64  # button image size in percent

        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(KEY_HOME, KEY_HOME,
                                                      constr, home_listener,
                                                      bgr, size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)

        constr = layout.get_next_constraints()
        self.classical_button = self.factory.create_button(
            CLASSICAL, KEY_1, constr, presets_listener, bgr, size)
        self.add_component(self.classical_button)
        self.menu_buttons.append(self.classical_button)

        constr = layout.get_next_constraints()
        self.jazz_button = self.factory.create_button(JAZZ, KEY_2, constr,
                                                      presets_listener, bgr,
                                                      size)
        self.add_component(self.jazz_button)
        self.menu_buttons.append(self.jazz_button)

        constr = layout.get_next_constraints()
        self.pop_button = self.factory.create_button(POP, KEY_3, constr,
                                                     presets_listener, bgr,
                                                     size)
        self.add_component(self.pop_button)
        self.menu_buttons.append(self.pop_button)

        constr = layout.get_next_constraints()
        self.rock_button = self.factory.create_button(ROCK, KEY_4, constr,
                                                      presets_listener, bgr,
                                                      size)
        self.add_component(self.rock_button)
        self.menu_buttons.append(self.rock_button)

        constr = layout.get_next_constraints()
        self.contemporary_button = self.factory.create_button(
            CONTEMPORARY, KEY_5, constr, presets_listener, bgr, size)
        self.add_component(self.contemporary_button)
        self.menu_buttons.append(self.contemporary_button)

        constr = layout.get_next_constraints()
        self.neutral_button = self.factory.create_button(
            FLAT, KEY_6, constr, presets_listener, bgr, size)
        self.add_component(self.neutral_button)
        self.menu_buttons.append(self.neutral_button)

        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(
            KEY_PLAYER, KEY_PLAY_PAUSE, constr, player_listener, bgr, size)
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)
예제 #26
0
    def __init__(self, util, bounding_box, listeners, bgr, pages):
        """ Initializer
        
        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        :param bgr: menu background        
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        arrow_layout = BorderLayout(bounding_box)
        arrow_layout.set_percent_constraints(0, 0, PERCENT_ARROW_WIDTH,
                                             PERCENT_ARROW_WIDTH)

        if pages > 1:
            constr = arrow_layout.LEFT
            self.left_button = self.factory.create_page_down_button(
                constr, "0", 40, 100)
            self.left_button.add_release_listener(listeners[GO_LEFT_PAGE])
            self.add_component(self.left_button)
            self.menu_buttons.append(self.left_button)

            constr = arrow_layout.RIGHT
            self.right_button = self.factory.create_page_up_button(
                constr, "0", 40, 100)
            self.right_button.add_release_listener(listeners[GO_RIGHT_PAGE])
            self.add_component(self.right_button)
            self.menu_buttons.append(self.right_button)

        if pages > 1:
            layout = GridLayout(arrow_layout.CENTER)
        else:
            layout = GridLayout(bounding_box)

        layout.set_pixel_constraints(1, 3, 1, 0)
        layout.current_constraints = 0
        image_size = 64
        b = util.config[BACKGROUND][FOOTER_BGR_COLOR]

        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(
            KEY_HOME,
            KEY_HOME,
            constr,
            listeners[KEY_HOME],
            b,
            image_size_percent=image_size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)

        constr = layout.get_next_constraints()
        self.favorites_button = self.factory.create_button(
            KEY_FAVORITES,
            KEY_SETUP,
            constr,
            listeners[KEY_FAVORITES],
            b,
            image_size_percent=image_size)
        self.add_component(self.favorites_button)
        self.menu_buttons.append(self.favorites_button)

        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(
            KEY_PLAYER,
            KEY_PLAY_PAUSE,
            constr,
            listeners[KEY_PLAYER],
            b,
            image_size_percent=image_size)
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)
예제 #27
0
파일: about.py 프로젝트: thekismet/Peppy
    def __init__(self, util):
        """ Initializer
        
        :param util: utility object
        """
        self.util = util
        self.config = util.config
        self.config_class = util.config_class
        factory = Factory(util)
        self.name = "about.screen"

        self.color_web_bgr = self.config[COLORS][COLOR_WEB_BGR]
        color_logo = self.config[COLORS][COLOR_CONTRAST]
        color_status = self.config[COLORS][COLOR_LOGO]
        opacity = self.config[BACKGROUND][MENU_BGR_OPACITY]
        c = (self.color_web_bgr[0], self.color_web_bgr[1],
             self.color_web_bgr[2], opacity)

        cont = util.screen_rect
        img_filename = None
        bg = self.util.get_background("about", c)

        self.bgr_type = bg[0]
        if bg[2]:
            self.bgr = bg[1]
            cont = bg[2]
        else:
            self.bgr = (bg[1][0], bg[1][1], bg[1][2])

        img_filename = bg[3]
        self.bgr_key = bg[5]

        Container.__init__(self,
                           util,
                           bounding_box=util.screen_rect,
                           background=self.color_web_bgr,
                           content=cont,
                           image_filename=img_filename)

        self.start_listeners = []

        self.installed_release = self.config[RELEASE]
        self.installed_edition = self.installed_release[EDITION_NAME]
        self.installed_year = self.installed_release[RELEASE_YEAR]
        self.installed_month = self.installed_release[RELEASE_MONTH]
        self.installed_day = self.installed_release[RELEASE_DAY]

        layout = BorderLayout(self.bounding_box)
        layout.set_percent_constraints(0, PERCENT_FOOTER_HEIGHT, 0, 0)
        font_size = int((layout.BOTTOM.h * PERCENT_FOOTER_FONT) / 100.0)

        button = factory.create_image_button("peppy",
                                             bounding_box=layout.CENTER,
                                             bgr=bg[1],
                                             image_size_percent=68,
                                             selected=False)
        if bg[2]:
            button.parent_screen = bg[2]
        else:
            button.parent_screen = layout.CENTER
        x = layout.CENTER.w / 2 - button.components[1].content.get_size()[0] / 2
        y = layout.CENTER.h / 2 - button.components[1].content.get_size()[1] / 2
        button.components[1].content_x = x
        button.components[1].content_y = y
        self.add_component(button)

        bottom_bgr = pygame.Rect(layout.BOTTOM.x, layout.BOTTOM.y - 1,
                                 layout.BOTTOM.w, layout.BOTTOM.h + 2)
        comp = Component(self.util, bottom_bgr, bb=bottom_bgr, bgr=bg[1])
        comp.name = "txt.bgr"
        self.add_component(comp)

        text_layout = pygame.Rect(
            layout.BOTTOM.x, layout.BOTTOM.y - int(
                (self.bounding_box.h * 5) / 100), layout.BOTTOM.w,
            layout.BOTTOM.h)

        if self.util.connected_to_internet and self.config[USAGE][
                USE_CHECK_FOR_UPDATES]:
            bottom_layout = GridLayout(text_layout)
            bottom_layout.set_pixel_constraints(2, 1)
            line_top = bottom_layout.get_next_constraints()
            line_bottom = bottom_layout.get_next_constraints()
        else:
            line_top = text_layout

        transparent = (0, 0, 0, 0)
        self.release = factory.create_output_text("installed",
                                                  line_top,
                                                  transparent,
                                                  color_logo,
                                                  font_size,
                                                  full_width=True,
                                                  valign=V_ALIGN_BOTTOM)
        self.release.parent_screen = bg[2]
        if bg[2]:
            self.release.parent_screen = bg[2]
        else:
            self.release.parent_screen = line_top
        self.add_component(self.release)

        if self.util.connected_to_internet and self.config[USAGE][
                USE_CHECK_FOR_UPDATES]:
            self.status = factory.create_output_text("status",
                                                     line_bottom,
                                                     transparent,
                                                     color_status,
                                                     font_size,
                                                     full_width=True,
                                                     valign=V_ALIGN_TOP)
            self.status.parent_screen = bg[2]
            self.add_component(self.status)
            self.new_release = self.get_new_release()
예제 #28
0
    def __init__(self, util, bounding_box, listeners):
        """ Initializer

        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "wifi.navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        bgr = util.config[COLORS][COLOR_DARK_LIGHT]

        layout = GridLayout(bounding_box)
        layout.set_pixel_constraints(1, 5, 1, 0)
        layout.current_constraints = 0
        image_size = 64

        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(
            KEY_HOME,
            KEY_HOME,
            constr,
            listeners[KEY_HOME],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)

        constr = layout.get_next_constraints()
        self.refresh_button = self.factory.create_button(
            KEY_REFRESH,
            KEY_SETUP,
            constr,
            listeners[KEY_REFRESH],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.refresh_button)
        self.menu_buttons.append(self.refresh_button)

        constr = layout.get_next_constraints()
        self.wifi_button = self.factory.create_button(
            WIFI,
            KEY_ROOT,
            constr,
            listeners[WIFI],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.wifi_button)
        self.menu_buttons.append(self.wifi_button)

        constr = layout.get_next_constraints()
        self.disconnect = self.factory.create_button(
            KEY_DISCONNECT,
            KEY_PARENT,
            constr,
            listeners[KEY_DISCONNECT],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.disconnect)
        self.menu_buttons.append(self.disconnect)

        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(
            KEY_PLAYER,
            KEY_PLAY_PAUSE,
            constr,
            listeners[KEY_PLAYER],
            bgr,
            image_size_percent=image_size)
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)
예제 #29
0
    def __init__(self, util):
        """ Initializer
        
        :param util: utility object
        """
        self.util = util
        self.config = util.config
        self.config_class = util.config_class
        self.color_web_bgr = self.config[COLORS][COLOR_WEB_BGR]
        color_logo = self.config[COLORS][COLOR_CONTRAST]
        color_status = self.config[COLORS][COLOR_LOGO]

        Container.__init__(self, util, background=self.color_web_bgr)
        self.bounding_box = util.screen_rect
        self.start_listeners = []
        factory = Factory(util)
        self.installed_release = self.config[RELEASE]
        self.installed_edition = self.installed_release[EDITION_NAME]
        self.installed_year = self.installed_release[RELEASE_YEAR]
        self.installed_month = self.installed_release[RELEASE_MONTH]
        self.installed_day = self.installed_release[RELEASE_DAY]

        layout = BorderLayout(self.bounding_box)
        layout.set_percent_constraints(0, PERCENT_FOOTER_HEIGHT, 0, 0)
        font_size = int((layout.BOTTOM.h * PERCENT_FOOTER_FONT) / 100.0)

        button = factory.create_image_button("peppy",
                                             bounding_box=layout.CENTER,
                                             bgr=self.color_web_bgr,
                                             image_size_percent=68,
                                             selected=False)
        x = layout.CENTER.w / 2 - button.components[1].content.get_size()[0] / 2
        y = layout.CENTER.h / 2 - button.components[1].content.get_size()[1] / 2
        button.components[1].content_x = x
        button.components[1].content_y = y
        self.add_component(button)

        layout.BOTTOM.y -= int((self.bounding_box.h * 5) / 100)
        layout.BOTTOM.h += 1

        if self.util.connected_to_internet and self.config[USAGE][
                USE_CHECK_FOR_UPDATES]:
            bottom_layout = GridLayout(layout.BOTTOM)
            bottom_layout.set_pixel_constraints(2, 1)
            line_top = bottom_layout.get_next_constraints()
            line_bottom = bottom_layout.get_next_constraints()
        else:
            line_top = layout.BOTTOM

        self.release = factory.create_output_text("installed",
                                                  line_top,
                                                  self.color_web_bgr,
                                                  color_logo,
                                                  font_size,
                                                  full_width=True,
                                                  valign=V_ALIGN_BOTTOM)
        self.add_component(self.release)

        if self.util.connected_to_internet and self.config[USAGE][
                USE_CHECK_FOR_UPDATES]:
            self.status = factory.create_output_text("status",
                                                     line_bottom,
                                                     self.color_web_bgr,
                                                     color_status,
                                                     font_size,
                                                     full_width=True,
                                                     valign=V_ALIGN_TOP)
            self.add_component(self.status)
            self.new_release = self.get_new_release()