A couple of corrections for the user interface (#1017)

* Preview size is now an argument for GeneralMenu
Parameter missing in call to save_config

* Update selection_menu.py

Co-authored-by: Anton Hvornum <anton.feeds+github@gmail.com>
This commit is contained in:
Werner Llácer 2022-03-01 12:36:58 +01:00 committed by GitHub
parent 86d991f442
commit 47a9fba94b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -179,7 +179,7 @@ class Selector:
self.set_enabled(True) self.set_enabled(True)
class GeneralMenu: class GeneralMenu:
def __init__(self, data_store :dict = None, auto_cursor=False): def __init__(self, data_store :dict = None, auto_cursor=False, preview_size :float = 0.2):
""" """
Create a new selection menu. Create a new selection menu.
@ -189,6 +189,9 @@ class GeneralMenu:
:param auto_cursor: Boolean which determines if the cursor stays on the first item (false) or steps each invocation of a selection entry (true) :param auto_cursor: Boolean which determines if the cursor stays on the first item (false) or steps each invocation of a selection entry (true)
:type auto_cursor: bool :type auto_cursor: bool
:param preview_size. Size in fractions of screen size of the preview window
;type preview_size: float (range 0..1)
""" """
self._translation = Translation.load_nationalization() self._translation = Translation.load_nationalization()
self.is_context_mgr = False self.is_context_mgr = False
@ -196,6 +199,7 @@ class GeneralMenu:
self.auto_cursor = auto_cursor self.auto_cursor = auto_cursor
self._menu_options = {} self._menu_options = {}
self._setup_selection_menu_options() self._setup_selection_menu_options()
self.preview_size = preview_size
def __enter__(self, *args :Any, **kwargs :Any) -> GeneralMenu: def __enter__(self, *args :Any, **kwargs :Any) -> GeneralMenu:
self.is_context_mgr = True self.is_context_mgr = True
@ -292,7 +296,7 @@ class GeneralMenu:
sort=False, sort=False,
cursor_index=cursor_pos, cursor_index=cursor_pos,
preview_command=self._preview_display, preview_command=self._preview_display,
preview_size=0.5 preview_size=self.preview_size
).run() ).run()
if selection and self.auto_cursor: if selection and self.auto_cursor:
@ -551,7 +555,7 @@ class GlobalMenu(GeneralMenu):
self._menu_options['save_config'] = \ self._menu_options['save_config'] = \
Selector( Selector(
_('Save configuration'), _('Save configuration'),
lambda: save_config(self._data_store), lambda preset: save_config(self._data_store),
enabled=True, enabled=True,
no_store=True) no_store=True)
self._menu_options['install'] = \ self._menu_options['install'] = \
@ -688,4 +692,4 @@ class GlobalMenu(GeneralMenu):
def _users_resynch(self): def _users_resynch(self):
self.synch('!superusers') self.synch('!superusers')
self.synch('!users') self.synch('!users')
return False return False