def __init__(self, title, enum_type, starting_value, policy=RadioPolicy.VERTICAL): self.selected_value = starting_value self.enum_type = enum_type self.radio_group = [] for choice in enum_type: RadioButton(self.radio_group, label=choice.name.capitalize(), state=choice is starting_value) rows = [[Text(("header", title))]] if policy is RadioPolicy.VERTICAL: for radio in self.radio_group: rows.append([radio]) else: col = [] for radio in self.radio_group: col.append(radio) rows.append(col) super().__init__(rows) self._w = LineBox(self._w)
def _add_options(self): cols = [] for item in self.opts: if self.default is first_true: state = 'first True' else: state = item == self.default cols.append((8, RadioButton(self.group, item, state=state))) return Columns(cols)
def _insert_charm_selections(self): first_index = 0 bgroup = [] for i, charm_class in enumerate(self.charms): charm = charm_class if charm.name() and not first_index: first_index = i r = RadioButton(bgroup, charm.name()) r.text_label = charm.name() self.boxes.append(r) # Add input widget for specifying NumUnits self.count_editor = IntEdit("Number of units to add: ", 1) self.boxes.append(self.count_editor) wrapped_boxes = self._wrap_focus(self.boxes) items = ListBox(SimpleListWalker(wrapped_boxes)) items.set_focus(first_index) return (len(self.boxes), BoxAdapter(items, len(self.boxes)))
def set_results(self, results): self.phones_text.set_text([('key', 'F4'), ' Results (%s)' % len(results)]) self.items[:] = [] group = [] for ref in results: item = RadioButton(group, ref, state=False) connect_signal(item, 'change', self.on_select_phone, ref) item = AttrWrap(item, 'no', 'selection') self.items.append(item)
def __init__(self, underlying, juju_state, destroy, command_runner=None): import cloudinstall.charms charm_modules = [import_module('cloudinstall.charms.' + mname) for (_, mname, _) in pkgutil.iter_modules(cloudinstall.charms.__path__)] charm_classes = [m.__charm_class__ for m in charm_modules if m.__charm_class__.allow_multi_units] self.cr = command_runner self.underlying = underlying self.destroy = destroy self.boxes = [] self.bgroup = [] first_index = 0 for i, charm_class in enumerate(charm_classes): charm = charm_class(juju_state=juju_state) if charm.name() and not first_index: first_index = i r = RadioButton(self.bgroup, charm.name()) r.text_label = charm.name() self.boxes.append(r) self.count_editor = IntEdit("Number of units to add: ", 1) self.boxes.append(self.count_editor) wrapped_boxes = _wrap_focus(self.boxes) bs = [Button("Ok", self.yes), Button("Cancel", self.no)] wrapped_buttons = _wrap_focus(bs) self.buttons = Columns(wrapped_buttons) self.items = ListBox(wrapped_boxes) self.items.set_focus(first_index) ba = BoxAdapter(self.items, height=len(wrapped_boxes)) self.lb = ListBox([ba, Text(""), self.buttons]) self.w = LineBox(self.lb, title="Add unit") self.w = AttrMap(self.w, "dialog") Overlay.__init__(self, self.w, self.underlying, 'center', 45, 'middle', len(wrapped_boxes) + 4)
def _add_options(self): rows = [] for item in self.opts: rows.append((RadioButton(self.group, item))) return Pile(rows)
def add_radio(self, item, desc, group=[]): self.radio_items[item] = (RadioButton(group, item), desc)
def _add_options(self): cols = [] for item in self.opts: cols.append((8, RadioButton(self.group, item))) return cols
def _add_options(self): for item in self.opts: RadioButton(self.group, item)
def add_radio(self, item, group=[]): """ Adds radio selections """ self.input_items[item] = RadioButton(group, item)
def add_radio(self, item, group=[]): self.radio_items[item] = RadioButton(group, item)
def add_radio(self, item, group=[]): """ Adds radio selections """ r = RadioButton(group, item) r.text_label = item self.input_items[item] = r