Python urwid.RadioButton() Examples
The following are 9
code examples of urwid.RadioButton().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
urwid
, or try the search function
.
Example #1
Source File: main.py From wikicurses with MIT License | 6 votes |
def __init__(self): def selectButton(radio_button, new_state, parameter): if new_state: closeOverlay() self._select(parameter) super().__init__(urwid.SimpleFocusListWalker([])) buttons = [] for i, item in enumerate(self._items()): if isinstance(item, urwid.Widget): self.body.append(item) continue elif isinstance(item, tuple): name, selected, parameter = item else: parameter = name = item selected = False self.body.append(urwid.RadioButton(buttons, name, selected, selectButton, parameter)) if selected: self.set_focus(i)
Example #2
Source File: widgets.py From pycopia with Apache License 2.0 | 6 votes |
def __init__(self, model, metadata, value, legend=None): blist = [] glist = [] maxl = 0 for num, name in types.ValueType.get_choices(): maxl = max(maxl, len(name)) b = urwid.RadioButton(blist, name, False, user_data=num) b.value = num glist.append(AM(b, 'enumbuttn','buttnf')) # set the right value for b in blist: if b.value == value: b.state = True self.wid = urwid.GridFlow(glist, maxl+4, 1, 0, 'left') self.blist = blist self.__super.__init__(self._col_creator(metadata, self.wid, legend))
Example #3
Source File: widgets.py From pycopia with Apache License 2.0 | 6 votes |
def __init__(self, model, metadata, value, legend=None): blist = [] glist = [] maxl = 0 enumtype = getattr(types, metadata.coltype) if value is None: value = enumtype.get_default() for num, name in enumtype.get_choices(): maxl = max(maxl, len(name)) b = urwid.RadioButton(blist, name, False, user_data=num) b.value = num glist.append(AM(b, 'enumbuttn','buttnf')) # set the right value for b in blist: if b.value == value: b.state = True self.wid = urwid.GridFlow(glist, maxl+4, 1, 0, 'left') self.blist = blist self.__super.__init__(self._col_creator(metadata, self.wid, legend))
Example #4
Source File: networking.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 6 votes |
def __init__(self, parent): self.text = ( "{}\n\nDuring the host probes, the available " "networks have been autodetected. Networks that are common to all " "hosts appear on the left, and networks common to all OSD hosts " "are shown on the right.".format(self.title) ) self.public_grp = [] self.cluster_grp = [] public_networks = [] cluster_networks = [] self.public_buttons = urwid.Pile([urwid.RadioButton(self.public_grp, txt) for txt in public_networks]) self.cluster_buttons = urwid.Pile([urwid.RadioButton(self.cluster_grp, txt) for txt in cluster_networks]) self.next_btn = ui_button(callback=self.validate) UIBaseClass.__init__(self, parent)
Example #5
Source File: networking.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 6 votes |
def refresh(self): """ populate the UI elements from the gathered host data """ app = self.parent public_networks = self._get_public_networks() cluster_networks = self._get_cluster_networks() if not public_networks: app.show_message("Error: Hosts do not share a common subnet " "for the public network") return if not cluster_networks: cluster_networks = public_networks self.public_buttons = urwid.Pile([ urwid.RadioButton(self.public_grp, txt) for txt in public_networks]) self.cluster_buttons = urwid.Pile([ urwid.RadioButton(self.cluster_grp, txt) for txt in cluster_networks])
Example #6
Source File: ViewWidget.py From topydo with GNU General Public License v3.0 | 5 votes |
def __init__(self, p_todolist): self._todolist = p_todolist self.titleedit = urwid.Edit("Title: ", "") self.sortedit = urwid.Edit("Sort expression: ", "") self.groupedit = urwid.Edit("Group expression: ", "") self.filteredit = urwid.Edit("Filter expression: ", "") radiogroup = [] self.relevantradio = urwid.RadioButton(radiogroup, "Only show relevant todo items", True) self.allradio = urwid.RadioButton(radiogroup, "Show all todo items") self.pile = urwid.Pile([ self.filteredit, self.titleedit, self.sortedit, self.groupedit, self.relevantradio, self.allradio, urwid.Button("Save", lambda _: urwid.emit_signal(self, 'save')), urwid.Button("Cancel", lambda _: self.close()), ]) self.reset() super().__init__(self.pile) urwid.register_signal(ViewWidget, ['save', 'close'])
Example #7
Source File: ui_elements.py From s-tui with GNU General Public License v2.0 | 5 votes |
def radio_button(group, label, fn): """ Inheriting radio button of urwid """ w = urwid.RadioButton(group, label, False, on_state_change=fn) w = urwid.AttrWrap(w, 'button normal', 'button select') return w
Example #8
Source File: test_container.py From anyMesh-Python with MIT License | 5 votes |
def test_buttons(self): self.fwstest(urwid.Button(u"hello")) self.fwstest(urwid.RadioButton([], u"hello"))
Example #9
Source File: environment.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 4 votes |
def __init__(self, parent): software_src_list = ['RH CDN', 'Distro', 'Community'] osd_types = ['filestore', 'bluestore'] dmcrypt_settings = ['standard', 'encrypted'] cfg = parent.cfg self.sw_source_group = [] self.osd_type = [] self.dmcrypt_group = [] self.text = ( "Environment\n\nDefine the types of environment settings that " "will determine the way the cluster is installed and configured." ) self.deployment_user = FixedEdit("Deployment User : ", width=8, valid_chars=self.alphanum) self.deployment_user.edit_text = 'root' software_buttons = [urwid.RadioButton(self.sw_source_group, txt, state=False) for txt in software_src_list] software_buttons[software_src_list.index(cfg.defaults.sw_src)].state = True self.software_sources = urwid.GridFlow(software_buttons, 14, 4, 0, align='left') osd_buttons = [urwid.RadioButton(self.osd_type, txt, state=False) for txt in osd_types] osd_buttons[osd_types.index(cfg.defaults.osd_objectstore)].state=True self.osd_options = urwid.GridFlow(osd_buttons, 14, 4, 0, align='left') dmcrypt_buttons = [urwid.RadioButton(self.dmcrypt_group, txt, state=False) for txt in dmcrypt_settings] dmcrypt_buttons[dmcrypt_settings.index(cfg.defaults.dmcrypt)].state = True self.dmcrypt_options = urwid.GridFlow(dmcrypt_buttons, 14, 4, 0, align='left') self.next_btn = ui_button(callback=self.validate) UIBaseClass.__init__(self, parent)