From ae05b66a473cbe26fecc25d0e3d073c3eba03455 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Mon, 9 Jan 2017 16:11:32 +1300 Subject: [PATCH] rewrite Selector to work like an HTML in an HTML form). + """ + + def __init__(self, opts, index=0): + self._options = opts + self._button = SelectableIcon("", 0) + self.index = index + super().__init__(self._button) + + def keypress(self, size, key): + if self._command_map[key] != ACTIVATE: + return key + self.open_pop_up() + + @property + def index(self): + return self._index + + @index.setter + def index(self, val): + self._button.set_text(self._options[val]) + self._index = val @property def value(self): - for item in self.group: - log.debug(item) - if item.get_state(): - return item.label - return "Unknown option" + return self._options[self._index] + + def create_pop_up(self): + return _PopUpSelectDialog(self, self.index) + + def get_pop_up_parameters(self): + width = max(map(len, self._options)) + 7 # longest option + line on left, "(?) ", space, line on right + return {'left':-5, 'top':-self.index-1, 'overlay_width':width, 'overlay_height':len(self._options) + 2} class YesNo(Selector): diff --git a/subiquitycore/ui/views/network_bond_interfaces.py b/subiquitycore/ui/views/network_bond_interfaces.py index 42c32848..d72d0359 100644 --- a/subiquitycore/ui/views/network_bond_interfaces.py +++ b/subiquitycore/ui/views/network_bond_interfaces.py @@ -74,7 +74,7 @@ class NetworkBondInterfacesView(BaseView): [ ("weight", 0.2, Text("Bonding Mode", align="right")), ("weight", 0.3, - Color.string_input(Pile(self.bond_mode.group), + Color.string_input(self.bond_mode, focus_map="string_input focus")) ], dividechars=4