我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用urwid.Filler()。
def __init__(self, initial_buttons): self.list_stack = [initial_buttons] self.all_styled_buttons = [urwid.AttrMap(b, None, 'reveal focus') for b in initial_buttons.items] self.list_walker = ChooseFromListWalker(self.all_styled_buttons, self) list_box = ChooseFromListBox(self.list_walker) column_array = convert_details_to_columns( initial_buttons.items[0].retrieve_important_details()) self.cols = urwid.Columns( [('weight', 1, column_array[0]), ('weight', 4, column_array[1])], ) self.detail_view = False self.base_title_text = self.list_stack[-1].items_title self.title = urwid.AttrMap(urwid.Text(self.base_title_text + " " + self.EMPTY_FILTER_TEXT), 'title') self.cols_title = urwid.AttrMap(urwid.Text(u'Attributes'), 'title') self.body = urwid.Pile([(2, urwid.Filler(self.title, valign='top')), list_box, ( 2, urwid.Filler(self.cols_title, valign='top')), self.cols]) self.before_detail = None self.filter_string = ""
def __init__(self, app, title, prompt, button, text, ring=None): self.app = app save_button = FixedButton(button) cancel_button = FixedButton('Cancel') urwid.connect_signal(save_button, 'click', lambda button:self._emit('save')) urwid.connect_signal(cancel_button, 'click', lambda button:self._emit('cancel')) button_widgets = [('pack', save_button), ('pack', cancel_button)] button_columns = urwid.Columns(button_widgets, dividechars=2) rows = [] self.entry = MyEdit(edit_text=text, multiline=True, ring=ring) rows.append(urwid.Text(prompt)) rows.append(self.entry) rows.append(urwid.Divider()) rows.append(button_columns) pile = urwid.Pile(rows) fill = urwid.Filler(pile, valign='top') super(TextEditDialog, self).__init__(urwid.LineBox(fill, title))
def __init__(self, title, topics): button_widgets = [] ok_button = mywid.FixedButton('OK') cancel_button = mywid.FixedButton('Cancel') urwid.connect_signal(ok_button, 'click', lambda button:self._emit('ok')) urwid.connect_signal(cancel_button, 'click', lambda button:self._emit('cancel')) button_widgets.append(('pack', ok_button)) button_widgets.append(('pack', cancel_button)) button_columns = urwid.Columns(button_widgets, dividechars=2) self.topic_buttons = [] self.topic_keys = {} rows = [] for key, name in topics: button = mywid.FixedRadioButton(self.topic_buttons, name) self.topic_keys[button] = key rows.append(button) rows.append(urwid.Divider()) rows.append(button_columns) pile = urwid.Pile(rows) fill = urwid.Filler(pile, valign='top') super(TopicSelectDialog, self).__init__(urwid.LineBox(fill, title))
def open_confirm_prompt(self, callback, title="", content="", yestxt="Yes", notxt="No", align="center"): def create_cb(bool): def res(*k, **a): callback(bool) self.close_pop_up() return res self.open_pop_up( urwid.Filler(urwid.Text(content, align=align)), header=urwid.Text( title, align='center'), footer=urwid.Columns([ (urwid.Button(yestxt, create_cb(True))), (urwid.Button(notxt, create_cb(False))), ]), height=6, width=50) self.pop_up.set_focus("footer") logger.debug("Confirm prompt text: " + str(content))
def item_chosen(button, choice): if SSID_DICT[choice]: button.set_label(u"[ ] " + button.get_label()[4:]) SSID_DICT[choice] = False else: button.set_label(u"[*] " + button.get_label()[4:]) SSID_DICT[choice] = True ##response = urwid.Text([u'You chose ', str(SSID_DICT[choice]), u'\n']) ##done = urwid.Button(u'Ok') ##urwid.connect_signal(done, 'click', exit_program) ##main.original_widget = urwid.Filler(urwid.Pile([response, ##urwid.AttrMap(done, None, focus_map='reversed')]))
def convert_details_to_columns(details): labels = [] data = [] for detail in details: if type(detail[0]) is list: labels.extend(detail[0]) else: labels.append(detail[0]) labels.append('\n') data.append(str(detail[1])) text2 = '\n'.join(data) if len(labels) == 0: labels = '' text2 = '' filler1 = urwid.Filler(urwid.Text(labels, 'left'), valign='top') filler2 = urwid.Filler(urwid.Text(text2, 'left'), valign='top') return [filler1, filler2]
def __init__(self, ui, query): self.ui = ui self.ui.set_header("Bibtex: " + query) docs = self.ui.db.search(query) if len(docs) == 0: self.ui.set_status('No documents found.') string = '' for doc in docs: string = string + doc.to_bibtex() + '\n' self.box = urwid.Filler(urwid.Text(string)) w = self.box self.__super.__init__(w)
def display(self, f): def handle_input(key): if key in ('q', 'Q'): raise urwid.ExitMainLoop() elif key in ('right', 'j', ' '): if self.slide_id < len(self.sd) - 1: self.slide_id += 1 elif key in ('left', 'k'): if self.slide_id > 0: self.slide_id -= 1 self.update_display() self.load_charset() self.sd = list(yaml.load_all(f)) self.slide_id = 0 self.update_display() txt = urwid.Text(u"Presenting...") fill = urwid.Filler(txt, 'bottom') urwid.MainLoop(fill, unhandled_input=handle_input).run()
def __init__(self, prompt_text=u"Input:", default_text=u""): close_button = urwid.Button("OK") prompt = urwid.Text(prompt_text) edit_field = CustomEdit(caption=u'', edit_text=default_text, multiline=False, align='left', wrap='space', allow_tab=False, edit_pos=None, layout=None, mask=None) prompt_wrap = urwid.AttrMap(prompt, 'header') close_button_wrap = urwid.AttrMap(close_button, 'buttn', 'buttnf') edit_field_wrap = urwid.AttrMap(edit_field, 'editcp') urwid.connect_signal(close_button, 'click', edit_field.on_finish) urwid.connect_signal(edit_field, 'done', self.on_close) pile = urwid.Pile([prompt_wrap, edit_field_wrap, urwid.Padding(close_button_wrap, 'center', 6)]) fill = urwid.Filler(urwid.Padding(pile, 'center', left=1, right=1)) self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))
def build_widgets(): input1 = urwid.Edit('What is your name? ') input2 = urwid.Edit('What is your quest? ') input3 = urwid.Edit('What is the capital of Assyria? ') inputs = [input1, input2, input3] def update_clock(widget_ref): widget = widget_ref() if not widget: # widget is dead; the main loop must've been destroyed return widget.set_text(datetime.now().isoformat()) # Schedule us to update the clock again in one second loop.call_later(1, update_clock, widget_ref) clock = urwid.Text('') update_clock(weakref.ref(clock)) return urwid.Filler(urwid.Pile([clock] + inputs), 'top')
def __init__(self, label=None, delegate=None): self.delegate = delegate pile = urwid.Pile([]) if isinstance(label, list): for item in label: element = urwid.Text(('bold-heading', item), align="center") pile.contents.append((element, pile.options())) else: if label is not None: label = urwid.Text(('bold-heading', label), align="center") pile.contents.append((label, pile.options())) filler = urwid.Filler(pile, 'middle') super(EmptyFrame, self).__init__(filler, "background")
def render(self, card): div = urwid.Divider() rdiv = urwid.AttrMap(div, 'header') header = urwid.Filler(urwid.Pile( [rdiv, rdiv, rdiv, rdiv, rdiv]), valign='top') h1_text = urwid.Text(('h1', self.name)) h2_text = urwid.Text(('h2', 'v' + self.version), align='right') hg_text = urwid.AttrMap(urwid.Padding(urwid.Columns( [h1_text, h2_text]), left=2, right=2, align='center'), 'header') body = urwid.Pile([hg_text, rdiv, card, div]) widget = urwid.Overlay(body, header, 'center', 76, 'top', 'pack', top=1) self.loop.widget.original_widget = widget
def main(): import argparse parser = argparse.ArgumentParser(description=__doc__) parser.parse_args() app = GameApp() loop = urwid.MainLoop( urwid.Filler(app.main_layout, valign='top'), PALETTE, unhandled_input=exit_on_q, ) loop.run()
def __init__(self): self.top_string = urwid.Text('') self.bottom_string = urwid.Text('') self.small_blinks = urwid.Filler(self.top_string, 'top') self.large_blinks = ('weight', 10, urwid.Filler(self.bottom_string, 'top')) self.default_widget = urwid.LineBox( urwid.Pile([ self.large_blinks ]), title='Websockets' )
def start_tui(args): txt = urwid.Text(u"Hello World") fill = urwid.Filler(txt, "top") loop =urwid.MainLoop(fill, unhandled_input=exit_on_q) loop.run()
def __init__(self, text, escape_method): self.escape_method = escape_method super(TestResultWindow, self).__init__(urwid.LineBox(urwid.Filler(urwid.Text(text))))
def __init__(self, text, escape_method): self.escape_method = escape_method super(TestResultWindow2, self).__init__(urwid.Filler(urwid.Text(text)))
def handle_input(key): if key in ('q', 'Q'): print 'exiting on q' raise urwid.ExitMainLoop() elif key in ('1'): main_loop.widget = urwid.LineBox(urwid.Filler(urwid.Text('The second top window', align='right')))
def __init__(self): close_button = urwid.Button("that's pretty cool") urwid.connect_signal(close_button, 'click', lambda button:self._emit("close")) pile = urwid.Pile([urwid.Text( "^^ I'm attached to the widget that opened me. " "Try resizing the window!\n"), close_button]) fill = urwid.Filler(pile) self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))
def __init__(self, pubpen): self.pubpen = pubpen program_name = urwid.Text(release.PROGRAM_NAME, align='center') copyright_name = urwid.Text('© {}, {}'.format(release.COPYRIGHT_YEAR, release.AUTHOR), align='center') license_name = urwid.Text(release.LICENSE, align='center') screen = urwid.Filler(urwid.Pile([program_name, copyright_name, license_name]), valign='middle') super().__init__(screen)
def __init__(self, pubpen): self.pubpen = pubpen self.save_button = urwid.Button('(S)ave') self.load_button = urwid.Button('(L)oad') self.quit_button = urwid.Button('(Q)uit') self.continue_button = urwid.Button('(ESC) Continue Game') self.buttons = urwid.SimpleFocusListWalker(( urwid.AttrMap(self.save_button, None, focus_map='reversed'), urwid.AttrMap(self.load_button, None, focus_map='reversed'), urwid.AttrMap(self.quit_button, None, focus_map='reversed'), urwid.AttrMap(self.continue_button, None, focus_map='reversed'), )) self.entrybox = urwid.ListBox(self.buttons) # Draw a box around the widget and constrain the widget's size linebox = urwid.LineBox(self.entrybox, tlcorner='\u2554', tline='\u2550', trcorner='\u2557', blcorner='\u255A', bline='\u2550', brcorner='\u255D', lline='\u2551', rline='\u2551') padding = urwid.Padding(linebox, align='center', width=len(self.continue_button.get_label()) + 6) filler = urwid.Filler(padding, valign='middle', height=len(self.buttons) + 2) outer_layout = LineBox(filler, lline=None, blcorner='?', tlcorner='?', trcorner='\u252c', brcorner='\u2524') super().__init__(outer_layout) urwid.connect_signal(self.save_button, 'click', self.save_game) urwid.connect_signal(self.load_button, 'click', self.load_game) urwid.connect_signal(self.quit_button, 'click', self.quit_client) urwid.connect_signal(self.continue_button, 'click', self.continue_game)
def __init__(self, pubpen): self.pubpen = pubpen username_label = urwid.Text('Username: ', align='right') password_label = urwid.Text('Password: ', align='right') self.username = urwid.Edit() self.password = urwid.Edit() login_button = urwid.Button('Login') decorated_login_button = urwid.AttrMap(login_button, None, focus_map='reversed') quit_button = urwid.Button('Quit') decorated_quit_button = urwid.AttrMap(quit_button, None, focus_map='reversed') buttons = urwid.Columns(( (len('Login') + 4, decorated_login_button), (len('Quit') + 4, decorated_quit_button), ), focus_column=1) labels = urwid.Pile([username_label, password_label]) self.fields = urwid.Pile([self.username, self.password, buttons], focus_item=0) entry_box = urwid.Columns([labels, self.fields]) self.status_message = urwid.Text(' ', align='center') entry_with_status = urwid.Pile([entry_box, self.status_message]) padded_entry_with_status = urwid.Padding(entry_with_status, align='center') self.display = urwid.Filler(padded_entry_with_status, valign='middle') decorate = urwid.LineBox(self.display) super().__init__(decorate) self.focusable_widgets = (w for w in itertools.cycle(( ((self.fields, 1),), ((self.fields, 2), (buttons, 0)), ((self.fields, 2), (buttons, 1)), ((self.fields, 0),) ))) urwid.connect_signal(login_button, 'click', self.attempt_login) urwid.connect_signal(quit_button, 'click', self.quit) self.pubpen.subscribe('user.login_success', self.handle_login_success) self.pubpen.subscribe('user.login_failure', self.handle_login_failure)
def __init__(self, pubpen): self.pubpen = pubpen blank = urwid.Text('This test page intentionally left blank') container = urwid.Filler(blank) outer_layout = LineBox(container, lline=None, blcorner='?', tlcorner='?', trcorner='\u252c', brcorner='\u2524') super().__init__(outer_layout) pass
def show_title_card(self): """Display a splash screen""" self.root_win.body = urwid.Filler(self.title_card, height=('relative', 100))
def show_main_window(self): """Display the main window""" self.root_win.body = urwid.Filler(self.main_window, height=('relative', 100))
def __init__(self, message): w = urwid.Filler(urwid.Text(message, align='center')) super(SystemMessage, self).__init__(urwid.LineBox(w, u'System Message'))
def __init__(self, app, title, current_key, values): self.app = app rows = [] self.key = None self.value = None for key, value in values(): button = SearchSelectInnerButton(key, value) urwid.connect_signal(button, 'click', lambda b:self.onSelected(b)) rows.append(button) pile = urwid.Pile(rows) fill = urwid.Filler(pile, valign='top') super(SearchSelectDialog, self).__init__(urwid.LineBox(fill, title))
def __init__(self, app, project_key): self.app = app save_button = mywid.FixedButton(u'Save') cancel_button = mywid.FixedButton(u'Cancel') urwid.connect_signal(save_button, 'click', lambda button:self._emit('save')) urwid.connect_signal(cancel_button, 'click', lambda button:self._emit('cancel')) rows = [] buttons = [('pack', save_button), ('pack', cancel_button)] buttons = urwid.Columns(buttons, dividechars=2) if project_key: with self.app.db.getSession() as session: project = session.getProject(project_key) project_name = project.name else: project_name = None self.project_button = ProjectButton(self.app, project_key, project_name) self.title_field = mywid.MyEdit(u'', edit_text=u'', ring=app.ring) self.description_field = mywid.MyEdit(u'', edit_text='', multiline=True, ring=app.ring) for (label, w) in [ (u'Title:', self.title_field), (u'Description:', self.description_field), (u'Project:', ('pack', self.project_button)), ]: row = urwid.Columns([(12, urwid.Text(label)), w]) rows.append(row) rows.append(urwid.Divider()) rows.append(buttons) pile = urwid.Pile(rows) fill = urwid.Filler(pile, valign='top') super(NewStoryDialog, self).__init__(urwid.LineBox(fill, 'New Story'))
def open_text_prompt(self, callback, title="", content=""): self.open_pop_up( urwid.Filler(TextEditWidget( callback, content=content)), header=urwid.Text( title, align='center'), height=6, width=50)
def swarm_chosen(button, choice): try: copters_chosen = [x+ " \n" for x in SSID_DICT.keys() if SSID_DICT[x] == True] response = urwid.Text([u'Swarmifying: \n', copters_chosen, u'\n']) done = urwid.Button(u'Ok') urwid.connect_signal(done, 'click', exit_program) main.original_widget = urwid.Filler(urwid.Pile([response, urwid.AttrMap(done, None, focus_map='reversed')])) except: pass
def __init__(self, ui, target=None): self.ui = ui self.target = target if self.target: tname = self.target.__class__.__name__ self.ui.set_header("Help: " + tname) else: self.ui.set_header("Help") pile = [] if self.target and hasattr(self.target, 'keys'): pile.append(urwid.Text('%s commands:' % (tname))) pile.append(urwid.Text('')) for key, cmd in sorted(self.target.keys.items()): pile.append(self.row('target', cmd, key)) pile.append(urwid.Text('')) pile.append(urwid.Text('')) pile.append(urwid.Text('Global commands:')) pile.append(urwid.Text('')) for key, cmd in sorted(self.ui.keys.items()): pile.append(self.row('ui', cmd, key)) w = urwid.Filler(urwid.Pile(pile)) self.__super.__init__(w)
def chosen_URL(button,choice): #######show url of chosen format #####modify so that it calls axel to dowload the given url ############### called when a particular stream is selected v_chosen = urwid.Text([u'Video Format :- ', str(choice), u'\n']) #v_URL = urwid.Text([u'Downloadable URL :- ', str(choice.url), u'\n']) done = urwid.Button(u'Copy URL to Clipboard') down = urwid.Button(u'Download using aria') ext = urwid.Button(u'Exit') urwid.connect_signal(done, 'click', Copy_exit,choice) urwid.connect_signal(ext, 'click', exit_program) urwid.connect_signal(down,'click',Down_aria,choice) main1.original_widget = urwid.Filler(urwid.Pile([v_chosen,urwid.AttrMap(down, None, focus_map='reversed'),urwid.AttrMap(done, None, focus_map='reversed'),urwid.AttrMap(ext, None, focus_map='reversed')])) ##############################Displaying Video formats definitions########################
def item_chosen(button, choice): response = urwid.Text([u'You chose ', choice, u'\n']) done = urwid.Button(u'Ok') urwid.connect_signal(done, 'click', exit_program) main.original_widget = urwid.Filler(urwid.Pile([response, urwid.AttrMap(done, None, focus_map='reversed')]))
def item_chosen(self, button): response = urwid.Text([u' You chose ', self.caption, u'\n']) done = MenuButton(u'Ok', exit_program) response_box = urwid.Filler(urwid.Pile([response, done])) top.open_box(urwid.AttrMap(response_box, 'options'))
def item_chosen(button): response = urwid.Text([u'You chose ', button.label, u'\n']) done = menu_button(u'Ok', exit_program) top.open_box(urwid.Filler(urwid.Pile([response, done])))
def __init__(self, text, height, width, body=None): width = int(width) if width <= 0: width = ('relative', 80) height = int(height) if height <= 0: height = ('relative', 80) self.body = body if body is None: # fill space with nothing body = urwid.Filler(urwid.Divider(),'top') self.frame = urwid.Frame( body, focus_part='footer') if text is not None: self.frame.header = urwid.Pile( [urwid.Text(text), urwid.Divider()] ) w = self.frame # pad area around listbox w = urwid.Padding(w, ('fixed left',2), ('fixed right',2)) w = urwid.Filler(w, ('fixed top',1), ('fixed bottom',1)) w = urwid.AttrWrap(w, 'body') # "shadow" effect w = urwid.Columns( [w,('fixed', 2, urwid.AttrWrap( urwid.Filler(urwid.Text(('border',' ')), "top") ,'shadow'))]) w = urwid.Frame( w, footer = urwid.AttrWrap(urwid.Text(('border',' ')),'shadow')) # outermost border area w = urwid.Padding(w, 'center', width ) w = urwid.Filler(w, 'middle', height ) w = urwid.AttrWrap( w, 'border' ) self.view = w
def test_box_column(self): c = urwid.Columns([urwid.Filler(urwid.Edit()),urwid.Text('')], box_columns=[0]) c.keypress((10,), 'x') c.get_cursor_coords((10,)) c.move_cursor_to_coords((10,), 0, 0) c.mouse_event((10,), 'foo', 1, 0, 0, True) c.get_pref_col((10,))
def test_filler(self): self.wstest(urwid.Filler(urwid.Text("hello")))
def ftest(self, desc, valign, height, maxrow, top, bottom, min_height=None): f = urwid.Filler(None, valign, height, min_height) t, b = f.filler_values((20,maxrow), False) assert (t,b)==(top,bottom), "%s expected %s but got %s"%( desc, (top,bottom), (t,b))
def fetest(self, desc, valign, height): self.assertRaises(urwid.FillerError, lambda: urwid.Filler(None, valign, height))
def test_repr(self): repr(urwid.Filler(urwid.Text(u'hai')))
def __init__(self): title = urwid.AttrWrap(urwid.Text('Help'), 'body') body = urwid.Text(HelpView.__doc__) pile = urwid.Pile([title, body]) filler = urwid.Filler(pile) urwid.Frame.__init__(self, filler)
def select_project(project_list, path_callback): max_width = len(max(project_list, key=len)) f = ProjectSelector(project_list, 'normal', 'highlighted', 'selected') def refresh_list(key=''): if key: if key in ('delete', 'backspace'): f.remove_key() else: if key in 'abcdefghijklmnopqrstuvwxyz- .0123456789': f.add_key(key) s = f.render() txt.set_text(s) def exit_on_q(key): if key.__class__ is not str: return if key in ('Q',): raise urwid.ExitMainLoop() if key == 'up': f.up() if key == 'down': f.down() if key == 'enter': path_callback(f.select()) raise urwid.ExitMainLoop() key = key.lower() refresh_list(key) palette = [ ('normal', 'light gray', ''), ('selected', 'yellow, bold', ''), ('highlighted', 'black, bold', 'yellow'), ('quit button', 'light red, bold', ''), ('enter button', 'light green, bold', '') ] txt = urwid.Text('', align='left') fill = urwid.Filler(txt) pad = urwid.Padding(fill, align='center', width=max_width+4) box = urwid.LineBox(pad, title="Projects") footer = urwid.Text(['Start typing to search. Use arrow keys to navigate. Press (', ('enter button', 'Enter'), ') to select project. ', 'Press (', ('quit button', 'Q'), ') to exit.']) frame = urwid.Frame(body=box, footer=footer) loop = urwid.MainLoop(frame, palette, unhandled_input=exit_on_q) refresh_list() loop.run()
def __init__(self, discord_client): self.discord = discord_client self.tabs = {} self.w_tabs = TabSelector(self) self.frame = urwid.Frame( urwid.Filler( urwid.Text( "????????????????????????????????????\n" "????????????????????????????????????\n" "????????????????????????????????????\n" " v0.2.4\n" " \n" " \n" " < Logging in... Hang tight! > \n" " --------------------------- \n" " \ ^__^ \n" " \ (oo)\_______ \n" " (__)\ )\/\ \n" " ||----w | \n" " || || \n" " \n" " \n" " \n", align=urwid.CENTER)), header=self.w_tabs) HasModal.__init__(self, self.frame) self.urwid_loop = urwid.MainLoop( self.w_placeholder, palette=MainUI.palette, unhandled_input=lambda key: self._keypress(None, key), event_loop=urwid.AsyncioEventLoop(loop=self.discord.loop), pop_ups=True) def refresh(_loop, _data): _loop.draw_screen() _loop.set_alarm_in(2, refresh) self.urwid_loop.set_alarm_in(0.2, refresh) self.urwid_loop.start()
def summon(): """summons the classic bsod""" sys_info = " {} {} ".format(platform.system(), platform.release()) error2 = "{:02x}".format(random.randint(0, 17)).upper() error4 = "{:04x}".format(random.randint(0, 4095)).upper() error8 = "{:08x}".format(random.randint(0, 68719476736)).upper() message = """ An error has occurred. To continue: Press Enter to return to {}, or Press CTRL+ALT+DEL to restart your computer. If you do this, you will lose any unsaved information in all open applications. Error: {} : {} : {} """.format(platform.system(), error2, error4, error8) end = "Press any key to continue " bg_map = urwid.AttrMap(urwid.SolidFill(' '), 'bg') body = urwid.Filler( urwid.AttrMap( urwid.Text(message, align='left'), 'text')) body_text = urwid.Overlay( body, bg_map, 'center', 63, 'middle', 10, 63, 10) continue_ln = urwid.AttrMap( urwid.Edit(end, align='center'), 'text') title_txt = urwid.AttrMap( urwid.Text(sys_info, align='center'), 'title') fill_scrn = urwid.Overlay( urwid.Filler(title_txt), bg_map, 'center', len(sys_info), 'middle', 1, len(sys_info), 1) text_stack = urwid.Filler(urwid.Pile([(1, fill_scrn), (10, body_text), ('pack', continue_ln)])) bg_fill = urwid.AttrMap(text_stack, 'bg') loop = urwid.MainLoop(bg_fill, PALETTE, input_filter=exitscreen) loop.screen.set_terminal_properties(colors=256) loop.run()
def setup_view(self): fonts = urwid.get_all_fonts() # setup mode radio buttons self.font_buttons = [] group = [] utf8 = urwid.get_encoding_mode() == "utf8" for name, fontcls in fonts: font = fontcls() if font.utf8_required and not utf8: rb = self.create_disabled_radio_button(name) else: rb = self.create_radio_button(group, name, font, self.set_font_event) if fontcls == urwid.Thin6x6Font: chosen_font_rb = rb exit_font = font self.font_buttons.append( rb ) # Create BigText self.bigtext = urwid.BigText("", None) bt = SwitchingPadding(self.bigtext, 'left', None) bt = urwid.AttrWrap(bt, 'bigtext') bt = urwid.Filler(bt, 'bottom', None, 7) bt = urwid.BoxAdapter(bt, 7) # Create chars_avail cah = urwid.Text("Characters Available:") self.chars_avail = urwid.Text("", wrap='any') ca = urwid.AttrWrap(self.chars_avail, 'chars') chosen_font_rb.set_state(True) # causes set_font_event call # Create Edit widget edit = self.create_edit("", "Urwid "+urwid.__version__, self.edit_change_event) # ListBox chars = urwid.Pile([cah, ca]) fonts = urwid.Pile([urwid.Text("Fonts:")] + self.font_buttons, focus_item=1) col = urwid.Columns([('fixed',16,chars), fonts], 3, focus_column=1) bt = urwid.Pile([bt, edit], focus_item=1) l = [bt, urwid.Divider(), col] w = urwid.ListBox(urwid.SimpleListWalker(l)) # Frame w = urwid.AttrWrap(w, 'body') hdr = urwid.Text("Urwid BigText example program - F8 exits.") hdr = urwid.AttrWrap(hdr, 'header') w = urwid.Frame(header=hdr, body=w) # Exit message exit = urwid.BigText(('exit'," Quit? "), exit_font) exit = urwid.Overlay(exit, w, 'center', None, 'middle', None) return w, exit