From f06aabb4d4a50d3a8ab7c07bef8390f72b091293 Mon Sep 17 00:00:00 2001 From: Werner Llácer Date: Mon, 28 Feb 2022 15:02:39 +0100 Subject: enhacements to the menu infraestructure (#978) * Correct definition of btrfs standard layout * Solve issue #936 * make ask_for_a_timezone as synonym to ask_timezone * Some refining in GeneralMenu secret is now a general function * Revert "Some refining in GeneralMenu" This reverts commit e6e131cb19795e0ddc169e897ae4df57a1c7f9fb. * Activate load of preset values in GeneralMenu Changed all select_functions definitions to the need of passing the preset value Corrected problems at ask_to_configure_network, and management of preset values added * minor glitches in menu processing, plus flake8 complains * Changes to ask_to_configure_network following @svartkanin code * select_language adapted to preset value. changes to the infraestructure to solve bugs * functions adapted for preset values * select_mirror_regions * select_locale_lang * select_locale_enc * ask_for_swap * Updated to preset values * ask_for_bootloader Won't use it * set_root_password() * Updated to preset values * ask_for_audio_selection * select_kernel * ask_for_a_timezone * Updated to use preset values * select_ntp * ask_ntp * ask_for_swap flake8 complains * Adapted to preset values * ask_additional_packages_to_install (from svartkanin) * ask_to_configure_network (adapted from svartkanin version) * Updated to preset values * ask_hostname * select_additional_repositories * bug in nic conversion _select_harddrives adapted to preset_menu --- archinstall/lib/menu/menu.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'archinstall/lib/menu/menu.py') diff --git a/archinstall/lib/menu/menu.py b/archinstall/lib/menu/menu.py index ee4b87e3..962dcc4d 100644 --- a/archinstall/lib/menu/menu.py +++ b/archinstall/lib/menu/menu.py @@ -84,8 +84,6 @@ class Menu(TerminalMenu): self.skip = skip self.default_option = default_option self.multi = multi - self.preselection(preset_values,cursor_index) - menu_title = f'\n{title}\n\n' if skip: @@ -97,6 +95,7 @@ class Menu(TerminalMenu): default = f'{default_option} (default)' self.menu_options = [default] + [o for o in self.menu_options if default_option != o] + self.preselection(preset_values,cursor_index) cursor = "> " main_menu_cursor_style = ("fg_cyan", "bold") main_menu_style = ("bg_blue", "fg_gray") @@ -154,22 +153,28 @@ class Menu(TerminalMenu): def preselection(self,preset_values :list = [],cursor_index :int = None): def from_preset_to_cursor(): if preset_values: - if isinstance(preset_values,str): - self.cursor_index = self.menu_options.index(preset_values) - else: # should return an error, but this is smoother - self.cursor_index = self.menu_options.index(preset_values[0]) + # if the value is not extant return 0 as cursor index + try: + if isinstance(preset_values,str): + self.cursor_index = self.menu_options.index(self.preset_values) + else: # should return an error, but this is smoother + self.cursor_index = self.menu_options.index(self.preset_values[0]) + except ValueError: + self.cursor_index = 0 - self.preset_values = preset_values self.cursor_index = cursor_index - if preset_values and cursor_index is None: - from_preset_to_cursor() - if preset_values and not self.multi: # Not supported by the infraestructure + if not preset_values: self.preset_values = None - from_preset_to_cursor() + return - if self.default_option and self.multi: + self.preset_values = preset_values + if self.default_option: if isinstance(preset_values,str) and self.default_option == preset_values: self.preset_values = f"{preset_values} (default)" elif isinstance(preset_values,(list,tuple)) and self.default_option in preset_values: idx = preset_values.index(self.default_option) self.preset_values[idx] = f"{preset_values[idx]} (default)" + if cursor_index is None or not self.multi: + from_preset_to_cursor() + if not self.multi: # Not supported by the infraestructure + self.preset_values = None -- cgit v1.2.3-70-g09d2