def __init__(self, default=None, choices=None, optional=False): if choices is None: choices = [] self.choices = choices self.optional = optional self.default = default self.radios = [] if self.optional: # Make the 'none of the above' widget urwid.RadioButton(self.radios, NONE) state = lambda s: (self.default and s == default) or "first True" for c in choices: urwid.RadioButton(self.radios, c, state(c)) max_length = max(len(c) for c in choices) if max_length < 16: cell_width = max_length + 4 else: cell_width = 20 radio_grid = urwid.GridFlow(self.radios, cell_width, 1, 1, 'left') urwid.WidgetWrap.__init__(self, radio_grid)
def __init__(self): self.options = [] unsure = urwid.RadioButton(self.options, u"Unsure") yes = urwid.RadioButton(self.options, u"Yes") no = urwid.RadioButton(self.options, u"No") display_widget = urwid.GridFlow([unsure, yes, no], 15, 3, 1, 'left') urwid.WidgetWrap.__init__(self, display_widget)
def screenUI(self): self.checkbox = urwid.CheckBox(u'有混合模式的checkbox', 'mixed', True) self.text1 = urwid.Text('status checkbox1') self.checkbox2 = urwid.CheckBox(u'没有混合模式的checkbox', False, False) self.text2 = urwid.Text('status checkbox2') self.content_list = [ self.checkbox, self.checkbox2, self.text1, self.text2 ] urwid.connect_signal(self.checkbox, 'change', self.change_checkbox, 1) urwid.connect_signal(self.checkbox2, 'change', self.change_checkbox, 2) blank_list = [blank, blank, blank] self.content_list.extend(blank_list) self.rgroup = [] self.radiobutton1 = urwid.RadioButton( self.rgroup, u"radiobutton1", False, ) self.text3 = urwid.Text('status radiobutton1') self.radiobutton2 = urwid.RadioButton(self.rgroup, u"rasiobutton2", True) self.text4 = urwid.Text('status radiobutton2') urwid.connect_signal(self.radiobutton1, 'change', self.change_radiobutton, 1) urwid.connect_signal(self.radiobutton2, 'change', self.change_radiobutton, 2) self.content_list.extend( [self.radiobutton1, self.radiobutton2, self.text3, self.text4]) return urwid.ListBox(urwid.SimpleListWalker(self.content_list))
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'])
def __init__(self, question): self.id = question['id'] self._value = question['value'] self._value_type = question['value_type'] if self._value_type == 'bool': self.options = [] yes = urwid.RadioButton(self.options, "Yes", state=False, on_state_change=self._set_bool_value) no = urwid.RadioButton(self.options, "No", state=False, on_state_change=self._set_bool_value) if question['value'] is not None: if question['value'] is True: yes.set_state(True) else: no.set_state(True) self.display_widget = urwid.Columns([ urwid.Padding(urwid.Text(question['name']), left=2), urwid.GridFlow([yes, no], 7, 3, 1, align='left') ], dividechars=5) urwid.WidgetWrap.__init__(self, self.display_widget) elif self._value_type == 'natural': self._edit_widget = ManifestNaturalEdit(u"", self._value) self.display_widget = urwid.Columns([ urwid.Padding(urwid.Text(question['name']), left=2), (8, urwid.Padding(urwid.Text("["), left=7)), self._edit_widget, (1, urwid.Text("]")) ]) urwid.WidgetWrap.__init__(self, self.display_widget)
def __init__(self): self.body = None self.header = urwid.Text(('title', u" HFOS Modules "), align='center') self.headermap = urwid.AttrMap(self.header, 'streak') self.footer = urwid.Text( ('banner', u" Select plugins to install! "), align='center') self.footermap = urwid.AttrWrap(self.footer, 'streak') self.allbutton = urwid.Button(u"Select All", self.on_all_button) self.nonebutton = urwid.Button(u"Select None", self.on_none_button) self.okbutton = urwid.Button(u"Ok", self.on_ok_button) self.exitbutton = urwid.Button(u"Cancel", self.on_cancel_button) self.radiogroup = [] self.developrbutton = urwid.RadioButton(self.radiogroup, 'Develop') self.installrbutton = urwid.RadioButton(self.radiogroup, 'Install') self.modepile = urwid.Pile( [self.developrbutton, self.installrbutton]) self.buttons = [ blank, self.allbutton, self.nonebutton, blank, self.modepile, blank, self.okbutton, self.exitbutton ] self.wraps = [] for button in self.buttons: self.wraps.append( urwid.AttrWrap(button, 'button normal', 'button select')) self.buttonlb = urwid.ListBox(urwid.SimpleListWalker(self.wraps)) self.selector = PluginSelector() self.pluginwrap = urwid.AttrWrap(self.selector, 'list normal', 'list select') self.contentframe = urwid.Pile([self.pluginwrap, self.buttonlb]) self.padding = urwid.Padding(self.contentframe, align='center', width=('relative', 50)) self.filler = urwid.Filler(self.padding, height=('relative', 50)) urwid.Frame.__init__(self, body=self.filler, header=self.headermap, footer=self.footermap) self.loop = urwid.MainLoop(self, palette, unhandled_input=exit_on_q) self.loop.run()
def __init__(self, controller, title, question, dest_dir, on_ok, on_cancel=None): self.controller = controller self.on_ok = on_ok label = urwid.Text(question, layout=TildeLayout) self.edit = urwid.Edit(edit_text=dest_dir.replace('%', '%%'), wrap='clip') w = urwid.AttrMap(self.edit, 'input', 'input') w = urwid.SimpleFocusListWalker([ label, w, ]) w = urwid.ListBox(w) w = urwid.LineBox(urwid.Padding(w, left=1, right=1), title, title_attr='dialog_title', bline='') top = urwid.Padding(w, left=1, right=1) label = urwid.Text('On conflict:') bgroup = [] self.btn_overwrite = urwid.RadioButton(bgroup, 'Overwrite') attr_btn_overwrite = urwid.AttrMap(self.btn_overwrite, 'dialog', 'dialog_focus') self.btn_skip = urwid.RadioButton(bgroup, 'Skip') attr_btn_skip = urwid.AttrMap(self.btn_skip, 'dialog', 'dialog_focus') self.btn_rename_existing = urwid.RadioButton(bgroup, 'Rename Existing') attr_btn_rename_existing = urwid.AttrMap(self.btn_rename_existing, 'dialog', 'dialog_focus') self.btn_rename_copy = urwid.RadioButton(bgroup, 'Rename Copy') attr_btn_rename_copy = urwid.AttrMap(self.btn_rename_copy, 'dialog', 'dialog_focus') self.btn_rename_existing.set_state(True) w = urwid.SimpleFocusListWalker([ label, attr_btn_overwrite, attr_btn_skip, attr_btn_rename_existing, attr_btn_rename_copy, ]) w = urwid.BoxAdapter(urwid.ListBox(w), 5) w = urwid.Columns([urwid.Filler(urwid.Divider(' ')), (19, urwid.Filler(w)), urwid.Filler(urwid.Divider(' '))]) self.divider = urwid.LineBox(urwid.Padding(w, left=1, right=1), tlcorner='├', trcorner='┤', bline='') middle = urwid.Padding(self.divider, left=1, right=1) self.btn_ok = urwid.Button('OK', self.on_click_ok) attr_btn_ok = urwid.AttrMap(self.btn_ok, 'dialog', 'dialog_focus') self.btn_cancel = urwid.Button('Cancel', on_cancel) attr_btn_cancel = urwid.AttrMap(self.btn_cancel, 'dialog', 'dialog_focus') w = urwid.Columns([urwid.Divider(' '), (6, attr_btn_ok), (1, urwid.Text(' ')), (10, attr_btn_cancel), urwid.Divider(' ')]) w = urwid.LineBox(urwid.Filler(w), tlcorner='├', trcorner='┤') bottom = urwid.Padding(w, left=1, right=1) self.pile = urwid.Pile([ (1, urwid.Filler(urwid.Text(' '))), (3, top), (6, middle), (3, bottom), (1, urwid.Filler(urwid.Text(' '))), ]) w = urwid.AttrMap(self.pile, 'dialog') super().__init__(w)
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)
def refresh(self): self.seconds = common.StyledEdit("secs:", edit_width=3, edit_style=('edit', None), align='right', edit_pos=2) self.minutes = common.StyledEdit("mins:", edit_width=3, edit_style=('edit', None), align='right', edit_pos=2) self.random_time = common.StyledEdit("Maximum seconds randomly added:", text_width=35, edit_style=('edit', None), align='right', edit_pos=2) self.automatically_ignore_broadcasts = None radio_buttons_group = [] self.radio_buttons = [ urwid.RadioButton(radio_buttons_group, "Yes", on_state_change=self.radiobuttons_change), urwid.RadioButton(radio_buttons_group, "No", on_state_change=self.radiobuttons_change) ] left_contents = [ urwid.AttrWrap(urwid.Text("Settings", 'center'), 'header'), urwid.Divider(), urwid.Divider(), urwid.Columns([ ('fixed', 36, urwid.Text("Time between checks:")), ('fixed', 11, self.minutes), ('fixed', 9, self.seconds), ]), self.random_time, urwid.Columns([('fixed', 36, urwid.Text("Automatically ignore broadcasts: ")), urwid.GridFlow(self.radio_buttons, 9, 3, 1, 'left')]), ] self.cols = urwid.Columns([ ('weight', 3, urwid.ListBox(urwid.SimpleFocusListWalker(left_contents))), common.ExpandedVerticalSeparator( urwid.ListBox( urwid.SimpleFocusListWalker([ urwid.Button("Save", on_press=self.on_save), ]))), ]) super().__init__(self.cols) asyncio. async (self.fill_stats())
def run_menu(choices): body = [ urwid.Text('nmapWrapper < by Bek @ HackEd >'), urwid.Divider() ] body.append(urwid.AttrMap(urwid.Text(''), None, None)) start = urwid.Button('Start') urwid.connect_signal(start, 'click', item_chosen, 'Start') body.append(urwid.AttrMap(start, None, focus_map='reversed')) body.append(urwid.AttrMap(urwid.Text(''), None, None)) for c in choices: button = urwid.Button(c) urwid.connect_signal(button, 'click', item_chosen, c) body.append(urwid.AttrMap(button, None, focus_map='reversed')) body.append(urwid.AttrMap(urwid.Text(''), None, None)) for o in option_labels: check = urwid.CheckBox(o, False) urwid.connect_signal(check, 'change', options_change, o) o_id = option_labels.index(o) if option_opts[o_id] in self.settings['opts']['option']: check.set_state(True) body.append(urwid.AttrMap(check, None, focus_map='reversed')) body.append(urwid.AttrMap(urwid.Text(''), None, None)) techniqs = [] for t in techniq_labels: radio = urwid.RadioButton(techniqs, t) t_id = techniq_opts.index(self.settings['opts']['techniqs']) if t == techniq_labels[t_id]: radio.set_state(True) urwid.connect_signal(radio, 'change', techniqs_change, t) body.append(urwid.AttrMap(radio, None, None)) body.append(urwid.AttrMap(urwid.Text(''), None, None)) speeds = [] for s in speed_labels: radio = urwid.RadioButton(speeds, s) urwid.connect_signal(radio, 'change', speed_change, s) s_id = speed_opts.index(self.settings['opts']['speed']) if s == speed_labels[s_id]: radio.set_state(True) body.append(urwid.AttrMap(radio, None, None)) body.append(urwid.AttrMap(urwid.Text(''), None, None)) body.append(urwid.AttrMap(urwid.Text(''), None, None)) body.append( urwid.AttrMap(urwid.Text('Type "Q" to quit'), None, None)) return urwid.ListBox(urwid.SimpleFocusListWalker(body))
def build(self, labelOptions, group): """ Creates the subwidgets of the components and stiches them together for the final render. Parameters ---------- labelOptions : array An array that contains the text values to display for each button group : str An identifier to uniquely identify a group of radio buttons Returns ------- None Raises ------ None """ self.buttons = [] for txt in labelOptions: r = urwid.RadioButton(group, txt, False) urwid.connect_signal(r, 'change', self.on_radio_change, self.attribute) urwid.connect_signal(r, 'change', self.modelRefreshFunction, self.attribute) ra = urwid.AttrWrap(r, 'button normal', 'button select') self.buttons.append(ra) self.refresh() return self.buttons
def get_userlist(n, group=[]): user_rbs = [] for i in range(n): rb = uw.RadioButton(group, label=f'User {i}') user_rbs.append(rb) return user_rbs
def _make_file_radio( self, sf: storage.StoredFile, group, selected: bool, select_handler ) -> urwid.RadioButton: label = f"{sf.name} ({sf.format_size()})" radio = urwid.RadioButton(group, label, selected) urwid.connect_signal(radio, "change", select_handler, sf.name) return urwid.AttrMap(radio, "li normal", "li focus")
def setup_listbox(self): """The main listbox""" self.disht_group = [] radio_dish_types = ur.GridFlow( [ur.AttrMap( ur.RadioButton(self.disht_group, txt), 'buttn', 'buttnf') for txt in DISH_TYPES], 15, 0, 2, 'left' ) for item in self.disht_group: if item.get_label() == self.recipe.dish_type: item.set_state(True) self.general_info = self._get_general_info() self.general_info = ur.Padding( ur.Pile(self.general_info), align='left', left=2 ) headings_general_and_dish_types = ur.GridFlow( [HEADINGS['general_info'], HEADINGS['dish_types'], HEADINGS['notes'], ], 53, 0, 2, 'left' ) headings_ingred_and_method = ur.GridFlow( [HEADINGS['ingredients'], HEADINGS['method'], ], 79, 0, 2, 'left' ) self.ingred_block = IngredientsContainer( ingredients = self.recipe.get_ingredients() ) self.method_block = EntryBlock( self.recipe.steps ) self.notes_block = EntryBlock( self.recipe.notes ) general_and_dish = ur.GridFlow( [self.general_info, radio_dish_types, self.notes_block], 53, 0, 2, 'left' ) ingred_and_method = ur.GridFlow( [self.ingred_block, self.method_block], 79, 0, 2, 'left' ) self.listbox_content = [ BLANK, headings_general_and_dish_types, BLANK, general_and_dish, BLANK, headings_ingred_and_method, BLANK, ingred_and_method ] list_box = ur.ListBox(ur.SimpleListWalker(self.listbox_content)) return list_box
def define_dialog(self): # align=center, only for fixed size dialog self.options = [] applyButtonTitle = "Save and restart" padding = " " * ((self.width - 6 - len(applyButtonTitle)) // 2) applyButton = urwid.Button(padding + applyButtonTitle + padding) urwid.connect_signal(applyButton, 'click', lambda button: self.apply()) window = [] radioButtonInstances = [] for i in range(len(self.themes)): radioButtonName = self.themes[i] selected = False if self.themes[i].lower() == self.preference["theme"].lower(): selected = True radioButtonInstance = urwid.AttrMap( urwid.RadioButton(self.options, radioButtonName, selected), 'radiobutton') radioButtonInstances.append(radioButtonInstance) radioButtons = urwid.GridFlow(radioButtonInstances, self.width - 2, 3, 1, 'left') window.extend([ urwid.AttrMap(urwid.Text("Themes\n"), 'dialog.content'), urwid.AttrMap(radioButtons, 'dialog.content'), urwid.AttrMap(urwid.Text("\n"), 'dialog.content'), urwid.AttrMap(applyButton, 'button') ]) self.widget = urwid.AttrMap( UWLineBox(urwid.AttrMap(urwid.Filler(urwid.Pile(window)), 'dialog'), title=self.title), 'dialog')
def __init__(self, change_scene): self.name = IRON_CURTAIN self.pile = urwid.Pile([]) bx = urwid.Filler(self.pile, valign='top') self.base = urwid.LineBox(bx) self.enable = urwid.CheckBox('Enable', True) self.mute = urwid.CheckBox('Mute') self.freeze = urwid.CheckBox('Freeze') self.reset = urwid.Button('Reset') self.div = urwid.Divider("-") self.kbd_test = urwid.Text('') self.dev_group = urwid.Text(self.name, align='center') self.effects = urwid.Pile([]) for w in [ self.dev_group, self.kbd_test, self.enable, self.mute, self.freeze, self.reset, self.div, self.effects ]: self.pile.contents.append((w, self.pile.options())) def radio_change(btn, new_state, scene_num): if new_state == True: change_scene(scene_num) scene_group = [] for i, scene in enumerate(IRON_CURTAIN_SCENES): btn = urwid.RadioButton(scene_group, scene, on_state_change=radio_change, state=i == 0, user_data=i) self.pile.contents.append((btn, self.pile.options()))
def refresh_speed_ui(self, r): data = next(iter(r.values())) fields = ( "speedNumber", "speedString", "remainNumber", "remainString", "amountNumber", "amountString", ) fmt = "[{}] {} {} ({} {}, {} {})" content = [] group = [] for step in data["steps"]: if step["code"] == data["offerCode"]: callback = None else: callback = self.SpeedChanger(step["code"]) desc = str.format("{} {} ({} {}, {} {})", *map(lambda k: bs(step[k]).text, fields)) state = step["code"] == data["offerCode"] content.append( urwid.RadioButton(group, desc, state=state, on_state_change=callback)) content.append(urwid.Button("Refresh", on_press=self.login_clicked)) self.common_container.original_widget = urwid.Pile(content)
def window(self): div = urwid.Divider() div_bar = urwid.Divider('-') self.info = urwid.Text(u'') self.edit = urwid.Edit(u'(1) Diary name: ') self.radio_group = [] self.yes = urwid.RadioButton(self.radio_group, u'Yes', state=False, on_state_change=self.on_radio_change) self.no = urwid.RadioButton(self.radio_group, u'No', state=True) listbox_content = [ urwid.Text( u'In order to use the diary you should specify a few parameters,' ), div, self.edit, div, urwid.Text(u'(2) Do you want to use a key? (For extra security)'), div, urwid.Columns([ urwid.Padding(urwid.GridFlow([self.yes, self.no], 10, 3, 1, 'left'), left=4, right=3, min_width=10), self.info ]), div, urwid.Columns([ urwid.Padding(urwid.Button(('button', u'Confirm & to diary'), self.on_confirm_continue), align='center', width=('relative', 90)), urwid.Padding(urwid.Button(('button', u'Confirm & Quit'), self.on_confirm_quit), align='center', width=('relative', 90)), urwid.Padding(urwid.Button(('button', u'Quit'), self.on_quit), align='center', width=('relative', 90)) ]) ] listbox = urwid.ListBox(urwid.SimpleFocusListWalker(listbox_content)) view = urwid.AttrMap(listbox, 'body') view = urwid.LineBox(view, title='Setup Menu') return view
def screenUI(self): self.text0 = urwid.Text(u'GridFlow 是一个由多个cell组成的流组件,其中每个组件都是流组件,宽度相同') self.text1 = urwid.Text(u"对于该组件的cell序列,grid会先横向排列,当一行占满时才会使用第二行") self.text2 = urwid.Text(u'你可以拖动鼠标变化控制台大小查看显示效果') self.text3 = urwid.Text(u'状态信息看这里') button_list = [] for i in range(0, 10): button = MyButton(u"button %s" % i, self.callback_button) button_list.append(button) self.button_listbox = urwid.ListBox( urwid.SimpleListWalker(button_list)) self.button_listbox = urwid.AttrWrap(self.button_listbox, 'header') self.button_listbox_flo = urwid.BoxAdapter(self.button_listbox, 10) edit_list = [] for i in range(0, 10): edit = urwid.Edit((u'edit%s' % i).ljust(12)) urwid.connect_signal(edit, 'change', self.callback_edit, i) edit_list.append(edit) self.edit_listbox = urwid.ListBox(urwid.SimpleListWalker(edit_list)) self.edit_listbox = urwid.AttrWrap(self.edit_listbox, 'editbx', 'editfc') self.edit_listbox_flo = urwid.BoxAdapter(self.edit_listbox, 10) text_list = [] for i in range(0, 10): text = urwid.Text(u'text %s' % i) text_list.append(text) text_listbox = urwid.ListBox(urwid.SimpleListWalker(text_list)) text_listbox = urwid.AttrWrap(text_listbox, 'padding') text_listbox_flo = urwid.BoxAdapter(text_listbox, 10) radiobutton_list = [] self.rgroup = [] for i in range(0, 10): radiobutton = urwid.RadioButton(self.rgroup, u'radiobutton %s' % i, False, self.callback_radiobutton, i) radiobutton_list.append(radiobutton) self.radiobutton_listbox = urwid.ListBox( urwid.SimpleListWalker(radiobutton_list)) self.radiobutton_listbox_flo = urwid.BoxAdapter( self.radiobutton_listbox, 10) self.move_button = MyButton(u"点击将焦点设置到第一个组件的起始位置", self.callback_movebutton) grid_list = [ self.button_listbox_flo, text_listbox_flo, self.edit_listbox_flo, self.radiobutton_listbox_flo ] self.gridflow = urwid.GridFlow(grid_list, 50, 2, 3, 'center') listbox_content = [ self.text0, self.text1, self.text2, blank, self.gridflow, self.text3, self.move_button ] return urwid.ListBox(urwid.SimpleListWalker(listbox_content))
def __init__(self, group, label, state='first True', on_state_change=None, user_data=None, sensitive=True, attrs=('body', 'editnfc'), focus_attr='body'): #caption = ('editcp', caption + ':') button = urwid.RadioButton(group, label, state, on_state_change, user_data) # pylint: disable-msg=E1101 self.__super.__init__(button, sensitive, attrs, focus_attr)
def radio_button(self, g, index, viewIndex, l, fn): w = urwid.RadioButton(g, str(self.optionsList[index][viewIndex][l]), l == self.optionsSelectedList[index][viewIndex], on_state_change = fn, user_data = (index, viewIndex, l)) w = urwid.AttrWrap(w, 'button normal', 'button select') return w
def __init__(self, filters, label, check=None): self.chec = check widget = urwid.RadioButton(filters, label) urwid.connect_signal(widget, "change", self.on_change) super().__init__(urwid.AttrWrap(widget, "default", "focus"))
def create_radio_button(self, g, name, obj, fn, disabled=False): w = urwid.RadioButton(g, name, False, on_state_change=fn) w.obj = obj if disabled: w = urwid.AttrWrap(w, 'button normal', 'button disabled') else: w = urwid.AttrWrap(w, 'button normal', 'button select') return w
def __init__(self, loop, initial_filter, set_filter_callback, attach=True): self.filter = initial_filter self.set_filter_callback = set_filter_callback # filter_button = generic_widgets.ToolbarButton("Filter") filter_button = generic_widgets.HighlightableListRow( urwid.Text("[Filter]")) urwid.connect_signal(filter_button, 'click', self.filter_callback) urwid.connect_signal(filter_button, 'doubleclick', self.filter_callback) # cancel_button = generic_widgets.ToolbarButton("Cancel") cancel_button = generic_widgets.HighlightableListRow( urwid.Text("[Cancel]")) urwid.connect_signal(cancel_button, 'click', self.detach) urwid.connect_signal(cancel_button, 'doubleclick', self.detach) filter_group = [] self.radios = { "show all": urwid.RadioButton(filter_group, "Show all"), "hide relative": urwid.RadioButton(filter_group, "Hide submissions") } self.days_ago_entry = urwid.IntEdit(default=7) # TODO: load from current settings widget = urwid.Pile(( self.radios["show all"], self.radios["hide relative"], urwid.Columns(( ('pack', urwid.Text(" more than ")), (3, self.days_ago_entry), ('pack', urwid.Text("days old")), )), # TODO: # urwid.RadioButton(filter_group, "Show submissions from"), # urwid.Columns(( # ('pack', urwid.Text(' ')), # ('pack', generic_widgets.FormatEdit("##_##_####", "MM/DD/YYYY")), # ('pack', urwid.Text(' to ')), # # ('pack', generic_widgets.DateEdit()) # )), urwid.Columns((filter_button, cancel_button)))) self.set_defaults() super().__init__(loop, widget, attach, 40)
def __init__(self): """ Initializes the TUI's various widgets """ self.upper_body = [] self.upper_middle_body = [] self.middle_body = [] self.lower_middle_body = [] self.lower_body = [] self.loop = None self.top = None self.list_walker = None self.downloading = False self.searching = False self.downloader = None self.search_results = [] self.search_results_checks = [] self.download_queue = [] self.download_queue_checks = [] self.gpl_notice = urwid.Text( "XDCC Downloader V " + version + "\n" "Copyright (C) 2016-2017 Hermann Krumrey\n\n" "This program comes with ABSOLUTELY NO WARRANTY.\n" "This is free software, and you are welcome to redistribute it\n" "under certain conditions.") self.message_edit = urwid.Edit(caption="XDCC Message: ", edit_text="") self.server_edit = urwid.Edit(caption="Server: ", edit_text="irc.rizon.net") self.add_pack_button = urwid.Button("Add Pack") self.search_engine_label = urwid.Text("Search Engines") self.search_engine_options = [] for search_engine in ["All"] + \ PackSearcher.get_available_pack_searchers(): urwid.RadioButton(self.search_engine_options, search_engine) self.search_term_edit = urwid.Edit(caption="Search Term: ", edit_text="") self.search_button = urwid.Button("Search") self.search_results_label = urwid.Text("Search Results:") self.add_search_result_button = urwid.Button("Add Selected Packs") self.download_queue_label = urwid.Text("Download_Queue") self.remove_pack_button = urwid.Button("Remove Selected Packs") self.destination_edit = urwid.Edit(caption="Destination Directory: ", edit_text=os.getcwd()) self.download_button = urwid.Button("Download") self.single_progress_bar = urwid.ProgressBar("Progress", "Total") self.total_progress_bar = urwid.ProgressBar("Progress", "Total") self.connect_widgets() self.lay_out()
def create_radio_buttons(self, labels): """ Create dialog radio buttons """ self.radio_button_group = [] for label in labels: urwid.RadioButton(self.radio_button_group, label) return self.radio_button_group
def __init__(self): rbuttons = [] self.rbobjects = [] self.button = urwid.Button("Load Queue", on_press=self.load_queue) ql = tcfg.t.get_queue_list() for q in ql: self.rbobjects.append((12, urwid.RadioButton(rbuttons, q['name']))) self.load_queue() w = self._build_widget() urwid.WidgetWrap.__init__(self, w)
def __init__(self, parent, model: SnippetsModel): self._model = model sort_column, sort_order = model.sort_column logger.debug('%s, %s', sort_column, sort_order) column_group, column_choices = [], [] for value, label in self.column_choices.items(): selected = sort_column == value btn = urwid.RadioButton( column_group, label, state=selected, on_state_change=self._on_column_choice_changed, user_data=value) column_choices.append(btn) column_list = urwid.ListBox(urwid.SimpleListWalker(column_choices)) order_group, order_choices = [], [] for value, label in self.order_choices.items(): selected = sort_order == value btn = urwid.RadioButton( order_group, label, state=selected, on_state_change=self._on_order_choice_changed, user_data=value) order_choices.append(btn) order_list = urwid.ListBox(urwid.SimpleListWalker(order_choices)) page_size = urwid.IntEdit('Page size: ', model.page_size) urwid.connect_signal(page_size, 'postchange', self._on_page_size_changed) body = urwid.Pile([ column_list, ('pack', HorizontalDivider()), order_list, ('pack', HorizontalDivider()), ('pack', page_size), ]) super().__init__(parent, body)
def user_add(self, dialog_w): ulist_w = self.ulist_w.base_widget username = dialog_w.base_widget.edit_text if username: user_rb = uw.RadioButton(self.user_group, dialog_w.base_widget.edit_text) user_rb.set_state(True) ulist_w.body.insert(0, user_rb) ulist_w.focus_position = 0 self.close_dialog()
def _init_list_selector(self): self.list_selector = [] for _list in self.lists: urwid.RadioButton( self.list_selector, _list.name, state=_list == self.current_list, on_state_change=self._change_current_list, user_data=_list, )