Python urwid 模块,Divider() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用urwid.Divider()

项目:usolitaire    作者:eliasdorneles    | 项目源码 | 文件源码
def __init__(self):
        self.game = Game()
        self._statusbar = urwid.Text(u'Ready')
        self.current_selection = Selection(None, None)
        self._tableau_columns = urwid.Columns([EmptyCardWidget() for _ in range(7)])
        self._top_columns = urwid.Columns([
            EmptyCardWidget(),
            EmptyCardWidget(),
            SpacerWidget(),
            EmptyCardWidget(),
            EmptyCardWidget(),
            EmptyCardWidget(),
            EmptyCardWidget(),
        ])
        self._update_stock_and_waste()
        self._update_foundations()
        self._update_tableaus()

        self.main_layout = urwid.Pile([
            self._top_columns,
            urwid.Divider(),
            self._tableau_columns,
            urwid.Divider(),
            self._statusbar,
        ])
项目:sshchan    作者:einchan    | 项目源码 | 文件源码
def __init__(self, config, board):
        """Initialize the most needed components."""
        self.config = config
        self.board = board

        self.header = None
        self.footer = None
        # Some sugar.
        self.div = ur.Divider()
        # Used in list_boards().
        self.boards_count = 0

        self.loop = Loop(None, self.unhandled)
        # Calculate min_width and left/right margins for Padding widgets.
        self.width = self.loop.dimensions[0] // 2
        self.margin = int((self.loop.dimensions[0] - self.width) * 0.60)
        # Flag for checking if board list is currently being displayed.
        self.list_visible = False
        # This flag needs to be here to fix a bug where Enter doesn't work
        # after hitting 'h' twice.
        self.help_flag = False
        # Another flag, this one is for board list display - it should only
        # be printed in the main menu/MOTD screen, nowhere else.
        self.motd_flag = False
项目:pytest-ui    作者:martinsmid    | 项目源码 | 文件源码
def init_main_screen(self):
        self.w_filter_edit = urwid.Edit('Filter ')
        aw_filter_edit = urwid.AttrMap(self.w_filter_edit, 'edit', 'edit_focus')
        self.w_status_line = urwid.AttrMap(StatusLine(self.store.get_test_stats), 'statusline', '')
        urwid.connect_signal(self.w_filter_edit, 'change', self.on_filter_change)
        self.init_test_listbox()
        self.w_main = urwid.Padding(
            urwid.Pile([
                ('pack', urwid.Text(u'Python Urwid Test Runner', align='center')),
                ('pack', urwid.Divider()),
                ('pack', aw_filter_edit),
                ('pack', urwid.Divider()),
                self.w_test_listbox,
                ('pack', urwid.Divider()),
                ('pack', self.w_status_line),
            ]),
            left=2, right=2
        )
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def __init__(self, pubpen):
        self.pubpen = pubpen

        self.exchange_entry = urwid.Text('(C)ommodity Exchange')
        self.port_entry = urwid.Text('(P)ort District')
        self.financial_entry = urwid.Text('(F)inancial')
        self.travel_entry = urwid.Text('(T)ravel')
        self.game_menu_entry = urwid.Text('(M)enu')

        self.menu_entries = urwid.Columns((
            ('weight', 1, urwid.Divider(' ')),
            (len('(C)ommodity Exchange') + 4, self.exchange_entry),
            (len('(P)ort District') + 4, self.port_entry),
            (len('(F)inancial') + 4, self.financial_entry),
            (len('(T)ravel') + 4, self.travel_entry),
            (len('(M)enu') + 4, self.game_menu_entry),
            ('weight', 1, urwid.Divider(' ')),
            ), dividechars=1)

        super().__init__(self.menu_entries)
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def __init__(self, pubpen, spacer=u'u2500'):
        self.pubpen = pubpen

        self.who = urwid.Text(u'\u2524 Name: \u251C')
        self.where = urwid.Text(u'\u2524 Location: \u251C')

        self.left = urwid.Columns([self.who])
        self.right = urwid.Columns([self.where])
        super().__init__((('pack', self.who),
                          ('weight', 1, urwid.Divider(spacer)),
                          ('pack', self.where),
                         ))

        # Connect to backend events
        self.pubpen.subscribe('user.info', self.handle_user_info)
        self.pubpen.subscribe('user.login_success', self.handle_login)
        self.pubpen.subscribe('ship.moved', self.handle_ship_moved)

    #
    # Widget methods
    #
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, title, message, entry_prompt=None,
                 entry_text='', buttons=[], ring=None):
        button_widgets = []
        for button in buttons:
            button_widgets.append(('pack', button))
        button_columns = urwid.Columns(button_widgets, dividechars=2)
        rows = []
        rows.append(urwid.Text(message))
        if entry_prompt:
            self.entry = MyEdit(entry_prompt, edit_text=entry_text, ring=ring)
            rows.append(self.entry)
        else:
            self.entry = None
        rows.append(urwid.Divider())
        rows.append(button_columns)
        listbox = urwid.ListBox(rows)
        super(ButtonDialog, self).__init__(urwid.LineBox(listbox, title))
项目:boartty    作者:openstack    | 项目源码 | 文件源码
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))
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app):
        super(BoardListView, self).__init__(urwid.Pile([]))
        self.log = logging.getLogger('boartty.view.board_list')
        self.searchInit()
        self.app = app
        self.active = True
        self.subscribed = False #True
        self.board_rows = {}
        self.listbox = urwid.ListBox(urwid.SimpleFocusListWalker([]))
        self.header = BoardListHeader()
        self.refresh()
        self._w.contents.append((app.header, ('pack', 1)))
        self._w.contents.append((urwid.Divider(),('pack', 1)))
        self._w.contents.append((urwid.AttrWrap(self.header, 'table-header'), ('pack', 1)))
        self._w.contents.append((self.listbox, ('weight', 1)))
        self._w.set_focus(3)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
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))
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app):
        super(ProjectListView, self).__init__(urwid.Pile([]))
        self.log = logging.getLogger('boartty.view.project_list')
        self.searchInit()
        self.app = app
        self.active = True
        self.subscribed = True
        self.project_rows = {}
        self.topic_rows = {}
        self.open_topics = set()
        self.listbox = urwid.ListBox(urwid.SimpleFocusListWalker([]))
        self.header = ProjectListHeader()
        self.refresh()
        self._w.contents.append((app.header, ('pack', 1)))
        self._w.contents.append((urwid.Divider(),('pack', 1)))
        self._w.contents.append((urwid.AttrWrap(self.header, 'table-header'), ('pack', 1)))
        self._w.contents.append((self.listbox, ('weight', 1)))
        self._w.set_focus(3)
项目:memsql-top    作者:memsql    | 项目源码 | 文件源码
def __init__(self, num_cores, max_mem):
        self.cpu_utilbar = urwid.ProgressBar('resource_bar_empty',
                                             'resource_bar', done=num_cores)
        self.mem_utilbar = urwid.ProgressBar('resource_bar_empty',
                                             'resource_bar', done=max_mem)

        super(ResourceMonitor, self).__init__(urwid.Pile([
            urwid.Columns([
                urwid.Text("CPU Util", align="right"),
                self.cpu_utilbar,
                urwid.Divider(),
                urwid.Text("Memory Capacity", align="right"),
                self.mem_utilbar
            ]),
#            urwid.Columns([
#                urwid.Text("CPU Sched Latency"),
#                urwid.ProgressBar('resource_bar_empty', 'resource_bar'),
#                urwid.Divider(),
#                urwid.Text("Memory Paging"),
#                urwid.ProgressBar('resource_bar_empty', 'resource_bar'),
#            ])
        ]))
项目:swarm    作者:3drobotics    | 项目源码 | 文件源码
def menu(title, SSID):
    body = [urwid.Text(title), urwid.Divider()]
    options = []
    for c in SSID:
        button = urwid.Button("[ ] " + c)
        options.append(button)
        #if SSID_DICT[c] == True:
        #    button.set_label(u"DH")
        urwid.connect_signal(button, 'click', item_chosen, c)
        body.append(urwid.AttrMap(button, None, focus_map='reversed'))

    swarmify_button = urwid.Button("Swarmify")
    options.append(swarmify_button)
    urwid.connect_signal(swarmify_button, 'click', swarm_chosen, c)
    body.append(urwid.AttrMap(swarmify_button, None, focus_map='reversed'))

    return urwid.ListBox(urwid.SimpleFocusListWalker(body))
项目:YtbDwn    作者:praneet95    | 项目源码 | 文件源码
def menuAV(title, avail_stream_both):   ###menu displaying formats with both audio and video ######### 2nd loop
        body = [urwid.Text(title), urwid.Divider()]

        for c in avail_stream_both:
            button = urwid.Button(str(c) + " ----->" + str(c.resolution) + "----->" + str((float(c.get_filesize())/1024)/1024))
            urwid.connect_signal(button, 'click', chosen_URL, c)
            body.append(urwid.AttrMap(button, None, focus_map='reversed'))
        button = urwid.Button("Only Video/Audio Formats")
        urwid.connect_signal(button, 'click', menuVAOnly)
        body.append(urwid.AttrMap(button, None, focus_map='reversed'))

        button = urwid.Button("EXIT")
        urwid.connect_signal(button, 'click', exit_program)
        body.append(urwid.AttrMap(button, None, focus_map='reversed'))

        return urwid.ListBox(urwid.SimpleFocusListWalker(body))

    ##########################################################################333
项目:YtbDwn    作者:praneet95    | 项目源码 | 文件源码
def menuVAOnlyMenu(title, avail_stream_VideoO,avail_stream_audioO): ###menu displaying formats with only audio or video ## must handle cases with audio and video alone ## for 3rd loop
        body = [urwid.Text(title), urwid.Divider()]

        for x in avail_stream_VideoO:
            button = urwid.Button(str(x).split('@',1)[0]  + "---->" +x.resolution  + "----->" + str((float(x.get_filesize())/1024)/1024))
            urwid.connect_signal(button, 'click', chosen_URL, x)
            body.append(urwid.AttrMap(button, None, focus_map='reversed'))
        for x1 in avail_stream_audioO:
            button = urwid.Button(str(x1))
            urwid.connect_signal(button, 'click', chosen_URL, x1)
            body.append(urwid.AttrMap(button, None, focus_map='reversed'))

        button = urwid.Button("EXIT")
        urwid.connect_signal(button, 'click', exit_program)
        body.append(urwid.AttrMap(button, None, focus_map='reversed'))

        return urwid.ListBox(urwid.SimpleFocusListWalker(body))

    #################3333##################################################
项目:terminal-leetcode    作者:chishui    | 项目源码 | 文件源码
def make_failed_view(self):
        blank = urwid.Divider()
        status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body')
        status = urwid.AttrWrap(urwid.Text('Wrong Answer'), 'hometag')
        columns = urwid.Columns([(17, status_header), (20, status)])
        result_header = urwid.Text('--- Run Code Result: ---', align='center')
        passed_header = urwid.Text('Passed test cases:')
        s = self.result['compare_result']
        passed = urwid.Text('%d/%d' % (s.count('1'), len(s)))
        your_input_header = urwid.Text('Your input:')
        your_input = urwid.Text(self.result['input'])
        your_answer_header = urwid.Text('Your answer:')
        your_answer = urwid.Text(self.result['code_output'])
        expected_answer_header = urwid.Text('Expected answer:')
        expected_answer = urwid.Text(self.result['expected_output'])
        list_items = [
                result_header,
                blank, columns,
                blank, passed_header, passed,
                blank, your_input_header, your_input,
                blank, your_answer_header, your_answer,
                blank, expected_answer_header, expected_answer
        ]
        self._append_stdout_if_non_empty(list_items)
        return urwid.Padding(urwid.ListBox(urwid.SimpleListWalker(list_items)), left=2, right=2)
项目:terminal-leetcode    作者:chishui    | 项目源码 | 文件源码
def make_compile_error_view(self):
        blank = urwid.Divider()
        status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body')
        status = urwid.AttrWrap(urwid.Text('Compile Error'), 'hometag')
        columns = urwid.Columns([(17, status_header), (20, status)])
        column_wrap = urwid.WidgetWrap(columns)
        result_header = urwid.Text('--- Run Code Result: ---', align='center')
        your_input_header = urwid.Text('Your input:')
        your_input = urwid.Text('')
        your_answer_header = urwid.Text('Your answer:')
        your_answer = urwid.Text(self.result['compile_error'])
        expected_answer_header = urwid.Text('Expected answer:')
        expected_answer = urwid.Text('Unkown Error')
        list_items = [
                result_header,
                blank, column_wrap,
                blank, your_input_header, your_input,
                blank, your_answer_header, your_answer,
                blank, expected_answer_header, expected_answer
        ]
        self._append_stdout_if_non_empty(list_items)
        return urwid.Padding(urwid.ListBox(urwid.SimpleListWalker(list_items)), left=2, right=2)
项目:terminal-leetcode    作者:chishui    | 项目源码 | 文件源码
def make_unified_error_view(self, error_title):
        blank = urwid.Divider()
        status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body')
        status = urwid.AttrWrap(urwid.Text(error_title), 'hometag')
        columns = urwid.Columns([(17, status_header), (30, status)])
        column_wrap = urwid.WidgetWrap(columns)
        if 'last_testcase' in self.result:
            result_header = urwid.Text('--- Run Code Result: ---', align='center')
            your_input_header = urwid.Text('Last executed input:')
            your_input = urwid.Text(self.result['last_testcase'])
            list_items = [
                result_header,
                blank, column_wrap,
                blank, your_input_header, your_input,
            ]
        else:
            list_items = [
                result_header,
                blank, column_wrap,
            ]
        self._append_stdout_if_non_empty(list_items)
        return urwid.Padding(urwid.ListBox(urwid.SimpleListWalker(list_items)), left=2, right=2)
项目:mongoaudit    作者:Exploit-install    | 项目源码 | 文件源码
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
项目:shirleytoolate    作者:trobanga    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):

        self.start = urwid.Edit('Start: ')
        self.end = urwid.Edit('End: ')

        self.server = kwargs["server"]
        self.calendar = kwargs["calendar"]

        del(kwargs['server'])
        del(kwargs["calendar"])

        print (self.server, self.calendar)


        div = urwid.Divider()
        self.msg = urwid.Edit(caption="Event message: ", edit_text='', multiline=True)
        button_save = urwid.Button('save')
        urwid.connect_signal(button_save, 'click', self.on_save)
        self.pile = urwid.Pile([self.start,
                                self.end,
                                div,
                                self.msg,
                                div,
                                button_save])

        super(EventWidget, self).__init__(self.pile, *args, **kwargs)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app):
        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)

        self.project_button = ProjectButton(self.app)
        self.status_button = StatusButton(self.app)
        self.assignee_button = AssigneeButton(self.app)
        self.title_field = mywid.MyEdit(u'', edit_text=u'', ring=app.ring)

        for (label, w) in [
                (u'Project:', ('pack', self.project_button)),
                (u'Title:', self.title_field),
                (u'Status:', ('pack', self.status_button)),
                (u'Assignee:', ('pack', self.assignee_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(NewTaskDialog, self).__init__(urwid.LineBox(fill, 'New Task'))
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app, query, query_desc=None, project_key=None,
                 active=False, sort_by=None, reverse=None):
        super(StoryListView, self).__init__(urwid.Pile([]))
        self.log = logging.getLogger('boartty.view.story_list')
        self.searchInit()
        self.app = app
        self.query = query
        self.query_desc = query_desc or query
        self.active = active
        self.story_rows = {}
        self.enabled_columns = set()
        for colinfo in COLUMNS:
            if (colinfo.name in self.required_columns or
                colinfo.name not in self.optional_columns):
                self.enabled_columns.add(colinfo.name)
        self.disabled_columns = set()
        self.listbox = urwid.ListBox(urwid.SimpleFocusListWalker([]))
        self.project_key = project_key
        if 'Project' not in self.required_columns and project_key is not None:
            self.enabled_columns.discard('Project')
            self.disabled_columns.add('Project')
        #storyboard: creator
        if 'Owner' not in self.required_columns and 'owner:' in query:
            # This could be or'd with something else, but probably
            # not.
            self.enabled_columns.discard('Owner')
            self.disabled_columns.add('Owner')
        self.sort_by = sort_by or app.config.story_list_options['sort-by']
        if reverse is not None:
            self.reverse = reverse
        else:
            self.reverse = app.config.story_list_options['reverse']
        self.header = StoryListHeader(self.enabled_columns)
        self.refresh()
        self._w.contents.append((app.header, ('pack', 1)))
        self._w.contents.append((urwid.Divider(), ('pack', 1)))
        self._w.contents.append((urwid.AttrWrap(self.header, 'table-header'), ('pack', 1)))
        self._w.contents.append((self.listbox, ('weight', 1)))
        self._w.set_focus(3)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app, board_key):
        super(BoardView, self).__init__(urwid.Pile([]))
        self.log = logging.getLogger('boartty.view.board')
        self.searchInit()
        self.app = app
        self.board_key = board_key
        self.worklist_keys = set()

        self.title_label = urwid.Text(u'', wrap='clip')
        self.description_label = urwid.Text(u'')
        board_info = []
        board_info_map={'story-data': 'focused-story-data'}
        for l, v in [("Title", self.title_label),
                     ("Description", self.description_label),
                     ]:
            row = urwid.Columns([(12, urwid.Text(('story-header', l), wrap='clip')), v])
            board_info.append(row)
        board_info = urwid.Pile(board_info)

        self.listbox = urwid.ListBox(urwid.SimpleFocusListWalker([]))
        self._w.contents.append((self.app.header, ('pack', 1)))
        self._w.contents.append((urwid.Divider(), ('pack', 1)))
        self._w.contents.append((self.listbox, ('weight', 1)))
        self._w.set_focus(2)

        self.listbox.body.append(board_info)
        self.listbox.body.append(urwid.Divider())
        self.listbox_board_start = len(self.listbox.body)

        lane_columns = urwid.Columns([], dividechars=1)
        self.listbox.body.append(lane_columns)

        self.lane_manager = mywid.ListUpdateManager(lane_columns)

        self.refresh()
        self.listbox.set_focus(1)
项目:socli    作者:gautamkrishnar    | 项目源码 | 文件源码
def makeFrame(self, data):
        """
        Returns a new frame that is formatted correctly with respect to the window's dimensions.
        :param data: tuple of (answers, question_title, question_desc, question_stats, question_url)
        :return: a new urwid.Frame object
        """
        answers, question_title, question_desc, question_stats, question_url = data
        self.data = data
        self.question_desc = question_desc
        self.url = question_url
        self.answer_text = AnswerText(answers)
        self.screenHeight, screenWidth = subprocess.check_output(['stty', 'size']).split()
        self.question_text = urwid.BoxAdapter(QuestionDescription(question_desc), int(max(1, (int(self.screenHeight) - 9) / 2)))
        answer_frame = urwid.Frame(
            header= urwid.Pile( [
                header_for_display,
                QuestionTitle(question_title),
                self.question_text,
                QuestionStats(question_stats),
                urwid.Divider('-')
            ]),
            body=self.answer_text,
            footer= urwid.Pile([
                QuestionURL(question_url),
                UnicodeText(u'\u2191: previous answer, \u2193: next answer, o: open in browser, \u2190: back')
            ])
        )
        return answer_frame
项目:mongoaudit    作者:stampery    | 项目源码 | 文件源码
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
项目:stig    作者:rndusr    | 项目源码 | 文件源码
def __init__(self, srvapi, tid, title=None):
        self._title = title
        self._torrent = {}

        sections = []
        self._sections = {}
        for section_cls in _sections:
            section = section_cls()
            sections.append(section)
            self._sections[section.title] = section

        def add_title(title, section):
            header = urwid.Columns([('pack', urwid.Text('??? %s ?' % title)),
                                    urwid.Divider('?')])
            return urwid.Pile([('pack', header), section])

        grid = urwid.GridFlow([], cell_width=1, h_sep=3, v_sep=1, align='left')
        for section in sections:
            opts = grid.options('given', section.width)
            section_wrapped = add_title(section.title, section)
            grid.contents.append((section_wrapped, opts))

        grid_sb = urwid.AttrMap(
            ScrollBar(urwid.AttrMap(Scrollable(grid), 'torrentsummary')),
            'scrollbar'
        )
        super().__init__(grid_sb)

        # Register new request in request pool
        keys = set(('name',)).union(key for w in sections for key in w.needed_keys)
        self._poller = srvapi.create_poller(srvapi.torrent.torrents, (tid,), keys=keys)
        self._poller.on_response(self._handle_response)
项目:douban-movie    作者:chishui    | 项目源码 | 文件源码
def __init__(self, movie):
        self.data = movie
        item = [
            ('pack', urwid.AttrWrap(urwid.Text(movie.title), 'body', 'focus')),
            (5, urwid.AttrWrap(urwid.Text(' ' + str(movie.year)), 'gray', 'focus')),
        ]
        w = urwid.Columns(item)
        blank = urwid.Divider()
        p = urwid.Pile([w, urwid.AttrWrap(urwid.Text(movie.sub_title), 'gray', 'focus'), blank])
        urwid.WidgetWrap.__init__(self, p)
项目:memsql-top    作者:memsql    | 项目源码 | 文件源码
def __init__(self, message):
        listbox = urwid.ListBox(urwid.SimpleListWalker([
            urwid.Text(line) for line in message.split("\n")
        ]))
        footer = urwid.Pile([
            urwid.Divider(),
            urwid.Text("<close>")
        ])
        self.box = urwid.LineBox(urwid.Frame(listbox, footer=footer))
        super(PopUpDialog, self).__init__(urwid.AttrMap(self.box, 'popup'))
项目:bbj    作者:desvox    | 项目源码 | 文件源码
def deletion_dialog(self, button, message):
        """
        Prompts the user to confirm deletion of an item.
        This can delete either a thread or a post.
        """
        op = message["post_id"] == 0
        buttons = [
            urwid.Text(("bold", "Delete this %s?" % ("whole thread" if op else "post"))),
            urwid.Divider(),
            cute_button(("10" , ">> Yes"), lambda _: [
                network.message_delete(message["thread_id"], message["post_id"]),
                self.remove_overlays(),
                self.index() if op else self.refresh()
            ]),
            cute_button(("30", "<< No"), self.remove_overlays)
        ]

        # TODO: create a central routine for creating popups. this is getting really ridiculous
        popup = OptionsMenu(
            urwid.ListBox(urwid.SimpleFocusListWalker(buttons)),
            **frame_theme())

        self.loop.widget = urwid.Overlay(
            popup, self.loop.widget,
            align=("relative", 50),
            valign=("relative", 50),
            width=30, height=6)
项目:bbj    作者:desvox    | 项目源码 | 文件源码
def make_thread_body(self, thread):
        """
        Returns the pile widget that comprises a thread in the index.
        """
        button = cute_button(">>", self.thread_load, thread["thread_id"])
        title = urwid.Text(thread["title"])
        user = self.usermap[thread["author"]]
        dateline = [
            ("default", "by "),
            (str(user["color"]), "~%s " % user["user_name"]),
            ("dim", "@ %s" % self.timestring(thread["created"]))
        ]

        infoline = "%d replies; active %s" % (
            thread["reply_count"],
            self.timestring(thread["last_mod"], "delta"))

        last_author = self.usermap[thread["last_author"]]
        pile = [
            urwid.Columns([(3, urwid.AttrMap(button, "button", "hover")), title]),
            urwid.Text(dateline),
            urwid.Text(("dim", infoline)),
            urwid.Text([
                ("dim", "last post by "),
                (str(last_author["color"]), "~" + last_author["user_name"])
            ]),
            urwid.AttrMap(urwid.Divider("-"), "dim")
        ]

        if self.prefs["index_spacing"]:
            pile.insert(4, urwid.Divider())

        pile = urwid.Pile(pile)
        pile.thread = thread
        return pile
项目:bbj    作者:desvox    | 项目源码 | 文件源码
def make_message_body(self, message, no_action=False):
        """
        Returns the widgets that comprise a message in a thread, including the
        text body, author info and the action button
        """
        info = "@ " + self.timestring(message["created"])
        if message["edited"]:
            info += " [edited]"

        if no_action:
            callback = ignore
            name = urwid_rainbows("~SYSTEM", True)
            color = "0"
        else:
            callback = self.on_post
            name = urwid.Text("~{}".format(self.usermap[message["author"]]["user_name"]))
            color = str(self.usermap[message["author"]]["color"])

        post = str(message["post_id"])
        head = urwid.Columns([
                (2 + len(post), urwid.AttrMap(
                    cute_button(">" + post, callback, message), "button", "hover")),
                (len(name._text) + 1, urwid.AttrMap(name, color)),
                urwid.AttrMap(urwid.Text(info), "dim")
            ])

        head.message = message
        return [
            head,
            urwid.Divider(),
            urwid.Padding(
                MessageBody(message),
                width=self.prefs["max_text_width"]),
            urwid.Divider(),
            urwid.AttrMap(urwid.Divider("-"), "dim")
        ]
项目:bbj    作者:desvox    | 项目源码 | 文件源码
def back(self, terminate=False):
        if app.mode == "index" and terminate:
            frilly_exit()

        elif self.overlay_p():
            self.loop.widget = self.loop.widget[0]

        elif self.window_split:
            # display a confirmation dialog before killing off an in-progress post
            buttons = [
                urwid.Text(("bold", "Discard current post?")),
                urwid.Divider(),
                cute_button(("10" , ">> Yes"), lambda _: [
                    self.remove_overlays(),
                    self.index()
                ]),
                cute_button(("30", "<< No"), self.remove_overlays)
            ]

            # TODO: create a central routine for creating popups. this is getting really ridiculous
            popup = OptionsMenu(
                urwid.ListBox(urwid.SimpleFocusListWalker(buttons)),
                **frame_theme())

            self.loop.widget = urwid.Overlay(
                popup, self.loop.widget,
                align=("relative", 50),
                valign=("relative", 25),
                width=30, height=6)

        else:
            mark()
            self.index()
项目:bbj    作者:desvox    | 项目源码 | 文件源码
def general_help(self):
        """
        Show a general help dialog. In all honestly, its not
        very useful and will only help people who have never
        really used terminal software before =)
        """
        widget = OptionsMenu(
            urwid.ListBox(
                urwid.SimpleFocusListWalker([
                    urwid_rainbows(
                        "This is BBJ, a client/server textboard made for tilde.town!",
                        True),
                    urwid.Text(("dim", "...by ~desvox")),
                    urwid.Divider("-"),
                    urwid.Button("Post Formatting Help", self.formatting_help),
                    urwid.Divider("-"),
                    urwid.Text(general_help)
                ])),
            title="?????",
            **frame_theme()
        )

        app.loop.widget = urwid.Overlay(
            widget, app.loop.widget,
            align=("relative", 50),
            valign=("relative", 50),
            width=30,
            height=("relative", 60)
        )
项目:papis    作者:alejandrogallo    | 项目源码 | 文件源码
def __init__(self, doc):
        self.doc = doc
        self.docid = self.doc["ref"]

        data = self.doc.to_dict()
        # fill the default attributes for the fields
        show_fields = papis.config.get(
            "show-fields", section="urwid-gui"
        ).replace(" ", "").split(",")
        self.fields = {}
        for field in show_fields:
            self.fields[field] = urwid.Text('')
            if field in data:
                self.fields[field].set_text(str(self.doc[field]))


        self.c1width = 10

        self.rowHeader = urwid.AttrMap(
            urwid.Text('ref:%s ' % (self.docid)),
            'head',
            'head_focus'
        )
        docfields = [self.docfield(field) for field in show_fields]

        # FIXME: how do we hightlight everything in pile during focus?
        w = urwid.Pile(
            [
                urwid.Divider('-'),
                self.rowHeader,
            ] + docfields,
            focus_item=1
        )
        self.__super.__init__(w)
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def menu(title, choices):
    body = [urwid.Text(title), urwid.Divider()]
    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'))
    return urwid.ListBox(urwid.SimpleFocusListWalker(body))
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def __init__(self, caption, choices):
        super(SubMenu, self).__init__(MenuButton(
            [caption, u"\N{HORIZONTAL ELLIPSIS}"], self.open_menu))
        line = urwid.Divider(u'\N{LOWER ONE QUARTER BLOCK}')
        listbox = urwid.ListBox(urwid.SimpleFocusListWalker([
            urwid.AttrMap(urwid.Text([u"\n  ", caption]), 'heading'),
            urwid.AttrMap(line, 'line'),
            urwid.Divider()] + choices + [urwid.Divider()]))
        self.menu = urwid.AttrMap(listbox, 'options')
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def menu(title, choices):
    body = [urwid.Text(title), urwid.Divider()]
    body.extend(choices)
    return urwid.ListBox(urwid.SimpleFocusListWalker(body))
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
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
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def add_buttons(self, buttons):
        l = []
        for name, exitcode in buttons:
            b = urwid.Button( name, self.button_press )
            b.exitcode = exitcode
            b = urwid.AttrWrap( b, 'selectable','focus' )
            l.append( b )
        self.buttons = urwid.GridFlow(l, 10, 3, 1, 'center')
        self.frame.footer = urwid.Pile( [ urwid.Divider(),
            self.buttons ], focus_item = 1)
项目:doubanfm-py    作者:nekocode    | 项目源码 | 文件源码
def _setup_ui(self):
        email = input('???? (Email??): ')
        password = getpass.getpass('????: ')

        api = DoubanFMApi()
        api.login(email, password)
        songs = api.get_redheart_songs()

        # ??
        self.title = urwid.Text('')
        self._update_title()
        divider = urwid.Divider()
        header = urwid.Padding(urwid.Pile([divider, self.title, divider]), left=4, right=4)

        # ????
        index = 0
        for song in songs:
            self.btns.append(SongButton(song, self._on_item_pressed, index))
            index += 1
        self.song_listbox = SongListBox(self.btns)

        # ??
        self.main = urwid.Padding(
            urwid.Frame(self.song_listbox, header=header, footer=divider),
            left=4, right=4)

        # ??????
        urwid.register_signal(
            SongListBox, ['exit', 'stop', 'next_song', 'change_mode'])
        urwid.connect_signal(self.song_listbox, 'exit', self._on_exit)
        urwid.connect_signal(self.song_listbox, 'stop', self.stop_song)
        urwid.connect_signal(self.song_listbox, 'next_song', self.next_song)
        urwid.connect_signal(self.song_listbox, 'change_mode', self.change_mode)

        self.loop = urwid.MainLoop(self.main, palette=self.palette)
        self.loop.screen.set_terminal_properties(colors=256)
项目:terminal-leetcode    作者:chishui    | 项目源码 | 文件源码
def __init__(self, quiz, host_view, result, loop = None):
        self.quiz = quiz
        self.host_view = host_view
        self.result = result
        self.loop = loop
        self.logger = logging.getLogger(__name__)
        if result:
            if 'status_code' not in result:
                raise ValueError('Unknow result format: %s' % json.dumps(result))
            if result['status_code'] is 20:
                self.listbox = self.make_compile_error_view()
            elif result['status_code'] is 10:
                self.listbox = self.make_success_view()
            elif result['status_code'] is 11:
                self.listbox = self.make_failed_view()
            elif result['status_code'] is 12:# memeory limit exceeded
                self.listbox = self.make_unified_error_view("Memory Limit Exceeded")
            elif result['status_code'] is 13:# output limit exceeded
                self.listbox = self.make_unified_error_view("Output Limit Exceeded")
            elif result['status_code'] is 14:# timeout
                self.listbox = self.make_unified_error_view("Time Limit Exceeded")
            elif result['status_code'] is 15:
                self.listbox = self.make_runtime_error_view()
            else:
                raise ValueError('Unknow status code: %d' % result['status_code'])
        else:
            raise ValueError('result shouldn\'t be None')

        self.overlay = urwid.Overlay(urwid.LineBox(self.listbox), host_view,
            align='center', width=('relative', 95),
            valign='middle', height=('relative', 95),
            min_width=40, min_height=40)

        footer = urwid.Pile([urwid.Text('Press Esc to close this view.', align='center'),
            urwid.Divider()])
        urwid.Frame.__init__(self, self.overlay, footer=footer)
项目:terminal-leetcode    作者:chishui    | 项目源码 | 文件源码
def _append_stdout_if_non_empty(self, list_items):
        std_output = self.result.get('std_output', '')
        if len(std_output) > 0:
            blank = urwid.Divider()
            stdout_header = urwid.Text('Stdout:')
            if len(std_output) > 100:
                std_output = '%s...%s\n(output trimmed due to its length)' %\
                    (std_output[:90], std_output[-10:])
            stdout = urwid.Text(std_output)
            list_items.extend([blank, stdout_header, stdout])
项目:terminal-leetcode    作者:chishui    | 项目源码 | 文件源码
def make_success_view(self):
        blank = urwid.Divider()
        status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body')
        status = urwid.AttrWrap(urwid.Text('Accepted'), 'accepted')
        columns = urwid.Columns([(20, status_header), (20, status)])
        runtime = urwid.Text('Run time: %s' % self.result['status_runtime'])
        result_header = urwid.Text('--- Run Code Result: ---', align='center')
        list_items = [
                result_header,
                blank, columns,
                blank, runtime
        ]
        self._append_stdout_if_non_empty(list_items)
        return urwid.Padding(urwid.ListBox(urwid.SimpleListWalker(list_items)), left=2, right=2)
项目:terminal-leetcode    作者:chishui    | 项目源码 | 文件源码
def __init__(self, quiz, loop = None):
        self.quiz = quiz
        self.loop = loop
        self.logger = logging.getLogger(__name__)
        blank = urwid.Divider()
        view_title = urwid.AttrWrap(urwid.Text(self.quiz.title), 'body')
        view_text = self.make_body_widgets()
        view_code_title = urwid.Text('\n --- Sample Code ---\n')
        view_code = urwid.Text(self.quiz.sample_code)
        listitems = [blank, view_title, blank] + view_text + \
                    [blank, view_code_title, blank, view_code, blank]
        self.listbox = urwid.ListBox(urwid.SimpleListWalker(listitems))
        urwid.Frame.__init__(self, self.listbox)
项目:terminal-leetcode    作者:chishui    | 项目源码 | 文件源码
def make_body_widgets(self):
        newline = 0
        tags = False
        text_widgets = []

        for line in self.quiz.content.split('\n'):
            text_widgets.append(urwid.Text(line))

        text_widgets.append(urwid.Divider())

        for tag in self.quiz.tags:
            text_widgets.append(urwid.Text(('tag', tag)))

        return text_widgets
项目:s-tui    作者:amanusk    | 项目源码 | 文件源码
def cpu_stats(self):
           """Read and display processor name """
           cpu_name = urwid.Text("CPU Name N/A", align="center")
           try:
               cpu_name = urwid.Text(get_processor_name().strip(), align="center")
           except:
               logging.info("CPU name not available")
           cpu_stats = [cpu_name, urwid.Divider()]
           return cpu_stats
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app, story_key):
        super(StoryView, self).__init__(urwid.Pile([]))
        self.log = logging.getLogger('boartty.view.story')
        self.searchInit()
        self.app = app
        self.story_key = story_key
        self.task_rows = {}
        self.event_rows = {}
        self.hide_events = True
        self.marked_seen = False
        self.title_label = urwid.Text(u'', wrap='clip')
        self.creator_label = mywid.TextButton(u'', on_press=self.searchCreator)
        self.tags_label = urwid.Text(u'', wrap='clip')
        self.created_label = urwid.Text(u'', wrap='clip')
        self.updated_label = urwid.Text(u'', wrap='clip')
        self.status_label = urwid.Text(u'', wrap='clip')
        self.permalink_label = mywid.TextButton(u'', on_press=self.openPermalink)
        story_info = []
        story_info_map={'story-data': 'focused-story-data'}
        for l, v in [("Title", self.title_label),
                     ("Creator", urwid.Padding(urwid.AttrMap(self.creator_label, None,
                                                           focus_map=story_info_map),
                                             width='pack')),
                     ("Tags", urwid.Padding(urwid.AttrMap(self.tags_label, None,
                                                           focus_map=story_info_map),
                                             width='pack')),
                     ("Created", self.created_label),
                     ("Updated", self.updated_label),
                     ("Status", self.status_label),
                     ("Permalink", urwid.Padding(urwid.AttrMap(self.permalink_label, None,
                                                               focus_map=story_info_map),
                                                 width='pack')),
                     ]:
            row = urwid.Columns([(12, urwid.Text(('story-header', l), wrap='clip')), v])
            story_info.append(row)
        story_info = urwid.Pile(story_info)
        self.description = DescriptionBox(app, u'')
        self.listbox = urwid.ListBox(urwid.SimpleFocusListWalker([]))
        self._w.contents.append((self.app.header, ('pack', 1)))
        self._w.contents.append((urwid.Divider(), ('pack', 1)))
        self._w.contents.append((self.listbox, ('weight', 1)))
        self._w.set_focus(2)

        self.listbox.body.append(story_info)
        self.listbox.body.append(urwid.Divider())
        self.listbox_tasks_start = len(self.listbox.body)
        self.listbox.body.append(urwid.Divider())
        self.listbox.body.append(self.description)
        self.listbox.body.append(urwid.Divider())

        self.refresh()
        self.listbox.set_focus(3)
项目:my_ros_tools    作者:groundmelon    | 项目源码 | 文件源码
def __init__(self, output_prefix=None):
        self.exit_message = None

        self.output_prefix = output_prefix

        text_header = (u"Command Generation for 'rosbag record' ")
        buttons = OrderedDict()
        buttons['quit'] = urwid.Button(u"Quit(ESC/q)", self.on_quit)
        buttons['save'] = dialog.PopUpButton(u"Save(F2)",
                                             self.on_save,
                                             prompt_text=u"Input file name:",
                                             default_text=u"record.sh")
        buttons['mark'] = urwid.Button(u"Mark all(F3)", self.on_mark_all)
        buttons['unmark'] = urwid.Button(u"Unmark all(F4)", self.on_unmark_all)
        buttons['refresh'] = urwid.Button(u"Refresh(F5)", self.on_refresh)
        self.buttons = buttons

        # blank = urwid.Divider()

        header = urwid.AttrWrap(urwid.Text(text_header, align='center'), 'header')

        button_bar = urwid.GridFlow(
            [urwid.AttrWrap(btn, 'buttn', 'buttnf')
             for (key, btn) in buttons.iteritems()], 18, 3, 1, 'left')
        status_bar = urwid.AttrWrap(urwid.Text(u""), 'footer')
        footer = urwid.Pile([button_bar, status_bar])

        self.listwalker = urwid.SimpleListWalker(self.create_listbox_from_ros())
        listbox = urwid.ListBox(self.listwalker)
        body = urwid.AttrWrap(listbox, 'body')

        self.frame = urwid.Frame(body=body, header=header, footer=footer)

        self.frame_focus_table = dict()
        self.frame_focus_table[body] = 'footer'
        self.frame_focus_table[footer] = 'body'

        palette = [
            ('body', 'white', 'black', 'standout'),
            ('reverse', 'light gray', 'black'),
            ('header', 'white', 'dark blue', 'bold'),
            ('footer', 'black', 'light gray'),
            ('important', 'dark blue', 'light gray', ('standout', 'underline')),
            ('editfc', 'white', 'dark blue', 'bold'),
            ('editbx', 'light gray', 'dark blue'),
            ('editcp', 'black', 'light gray', 'standout'),
            ('bright', 'dark gray', 'light gray', ('bold', 'standout')),
            ('buttn', 'black', 'light cyan'),
            ('buttnf', 'white', 'dark blue', 'bold'),
            ('popbg', 'white', 'dark gray'),
        ]

        self.show_msg = status_bar.set_text

        screen = urwid.raw_display.Screen()

        self.mainloop = urwid.MainLoop(self.frame, palette, screen,
                                       unhandled_input=self.unhandled, pop_ups=True)

    # UI functions
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
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
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def graph_controls(self):
        modes = self.controller.get_modes()
        # setup mode radio buttons
        self.mode_buttons = []
        group = []
        for m in modes:
            rb = self.radio_button( group, m, self.on_mode_button )
            self.mode_buttons.append( rb )
        # setup animate button
        self.animate_button = self.button( "", self.on_animate_button)
        self.on_animate_button( self.animate_button )
        self.offset = 0
        self.animate_progress = self.progress_bar()
        animate_controls = urwid.GridFlow( [
            self.animate_button,
            self.button("Reset", self.on_reset_button),
            ], 9, 2, 0, 'center')

        if urwid.get_encoding_mode() == "utf8":
            unicode_checkbox = urwid.CheckBox(
                "Enable Unicode Graphics",
                on_state_change=self.on_unicode_checkbox)
        else:
            unicode_checkbox = urwid.Text(
                "UTF-8 encoding not detected")

        self.animate_progress_wrap = urwid.WidgetWrap(
            self.animate_progress)

        l = [    urwid.Text("Mode",align="center"),
            ] + self.mode_buttons + [
            urwid.Divider(),
            urwid.Text("Animation",align="center"),
            animate_controls,
            self.animate_progress_wrap,
            urwid.Divider(),
            urwid.LineBox( unicode_checkbox ),
            urwid.Divider(),
            self.button("Quit", self.exit_program ),
            ]
        w = urwid.ListBox(urwid.SimpleListWalker(l))
        return w
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
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