index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | archinstall/lib/menu/menu.py | 29 |
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 |