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.listeners = listeners self.factory = Factory(util) self.go_home = listeners[KEY_HOME] self.go_keyboard = listeners[KEY_KEYBOARD_KEY] self.keyboard_callback = listeners[KEY_CALLBACK] self.wifi_selection_listeners = [] 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 = [MENU_ROWS_WIFI, MENU_COLUMNS_WIFI] MenuScreen.__init__(self, util, listeners, MENU_ROWS_WIFI, MENU_COLUMNS_WIFI, voice_assistant, d, self.turn_page, page_in_title=False, show_loading=False) self.title = self.config[LABELS]["select.wifi"] self.set_title(1) m = self.factory.create_wifi_menu_button self.wifi_menu = MultiPageMenu(util, self.next_page, self.previous_page, self.set_title, self.reset_title, self.go_to_page, m, MENU_ROWS_WIFI, MENU_COLUMNS_WIFI, None, (0, 0, 0), self.menu_layout, align=ALIGN_MIDDLE) self.set_menu(self.wifi_menu) listeners[KEY_REFRESH] = self.set_current listeners[KEY_SORT] = self.sort_abc self.navigator = WiFiNavigator(self.util, self.layout.BOTTOM, listeners, PAGE_SIZE_WIFI + 1) self.components.append(self.navigator) self.original_networks = None self.networks = None self.sort_direction = False self.current_network = None
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)
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