当前位置: 首页>>代码示例>>Python>>正文


Python urwid.AttrWrap方法代码示例

本文整理汇总了Python中urwid.AttrWrap方法的典型用法代码示例。如果您正苦于以下问题:Python urwid.AttrWrap方法的具体用法?Python urwid.AttrWrap怎么用?Python urwid.AttrWrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urwid的用法示例。


在下文中一共展示了urwid.AttrWrap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def __init__(self, key=None, value=('', '')):
        self.trigger = key
        self.yn = value[0]
        self.yn_but = MyButton([('attention', 'Use proxy: '), self.yn], self.on_change)
        self.input_addr = urwid.Edit(('attention', u' \N{BULLET} Address  : '), edit_text=value[1], wrap='clip')
        self.input_port = urwid.IntEdit(('attention', u' \N{BULLET} Port     : '), default=value[2])
        self.input_port.set_wrap_mode('clip')
        exit_but = urwid.Padding(urwid.Button('OKay'.center(8), self.item_callback), 'center', 12)

        widgets = [self.yn_but] \
                  + [urwid.AttrMap(wid, None, 'popbgs') for wid in (self.input_addr, self.input_port, exit_but)]

        self.pile = urwid.Pile(widgets)
        fill = urwid.LineBox(urwid.Filler(self.pile))
        self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))

        self.chosen = value 
开发者ID:Dragon2fly,项目名称:vpngate-with-proxy,代码行数:19,代码来源:ui_elements.py

示例2: make_table_with_categories

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def make_table_with_categories(contents: PopUpViewTableContent,
                                   column_widths: List[int],
                                   dividechars: int=2) -> List[Any]:
        """
        Returns a list of widgets to render a table with different categories.
        """
        widgets = []  # type: List[Any]
        for category, content in contents:
            if category:
                if len(widgets) > 0:  # Separate categories with newline.
                    widgets.append(urwid.Text(''))
                widgets.append(urwid.Text(('popup_category', category)))
            for index, row in enumerate(content):
                label, data = row
                strip = urwid.Columns([
                        urwid.Text(label),
                        (column_widths[1], urwid.Text(data))
                    ], dividechars=dividechars)
                widgets.append(urwid.AttrWrap(
                    strip, None if index % 2 else 'popup_contrast')
                )
        return widgets 
开发者ID:zulip,项目名称:zulip-terminal,代码行数:24,代码来源:views.py

示例3: stream_header

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def stream_header(self) -> Any:
        stream_topic_separator = '▶'
        color = self.model.stream_dict[self.stream_id]['color']
        bar_color = 's' + color
        stream_title_markup = ('bar', [
            (bar_color, '{} {} '.format(self.stream_name,
                                        stream_topic_separator)),
            ('title', ' {}'.format(self.topic_name))
        ])
        stream_title = urwid.Text(stream_title_markup)
        header = urwid.Columns([
            ('pack', stream_title),
            (1, urwid.Text((color, ' '))),
            urwid.AttrWrap(urwid.Divider('━'), color),
        ])
        header.markup = stream_title_markup
        return header 
开发者ID:zulip,项目名称:zulip-terminal,代码行数:19,代码来源:boxes.py

示例4: build

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def build(self):
        wlist = []
        addnew = urwid.Button("Add")
        urwid.connect_signal(addnew, 'click', self._add_new_option)
        addnew = urwid.AttrWrap(addnew, 'selectable', 'butfocus')
        wlist.append(addnew)
        for attrib in getattr(self.row, self.metadata.colname): # list-like attribute
            entry = ListEntry(urwid.Columns(
                    [(30, urwid.Text(str(attrib.type))),
                     urwid.Text(unicode(attrib.value).encode("utf-8"))]))
            entry.attrname = attrib.type.name
            urwid.connect_signal(entry, 'activate', self._edit_option)
            urwid.connect_signal(entry, 'delete', self._delete)
            wlist.append(entry)
        listbox = urwid.ListBox(urwid.SimpleFocusListWalker(wlist))
        return urwid.BoxAdapter(urwid.LineBox(listbox), max(7, len(wlist)+2)) 
开发者ID:kdart,项目名称:pycopia,代码行数:18,代码来源:widgets.py

示例5: build

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def build(self):
        wlist = []
        addnew = urwid.Button("Add")
        urwid.connect_signal(addnew, 'click', self._add_new_attribute)
        addnew = urwid.AttrWrap(addnew, 'selectable', 'butfocus')
        wlist.append(addnew)
        for attrib in getattr(self.row, self.metadata.colname): # list-like attribute
            entry = ListEntry(urwid.Columns(
                    [(30, urwid.Text(str(attrib.type))),
                     urwid.Text(unicode(attrib.value).encode("utf-8"))]))
            entry.attrname = attrib.type.name
            urwid.connect_signal(entry, 'activate', self._edit_attribute)
            urwid.connect_signal(entry, 'delete', self._delete)
            wlist.append(entry)
        listbox = urwid.ListBox(urwid.SimpleFocusListWalker(wlist))
        return urwid.BoxAdapter(urwid.LineBox(listbox), max(7, len(wlist)+2))

    # edit attrib 
开发者ID:kdart,项目名称:pycopia,代码行数:20,代码来源:widgets.py

示例6: on_unicode_checkbox

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def on_unicode_checkbox(self, w=None, state=False):
        """Enable smooth edges if utf-8 is supported"""
        logging.debug("unicode State is %s", state)

        # Update the controller to the state of the checkbox
        self.controller.smooth_graph_mode = state
        if state:
            self.hline = urwid.AttrWrap(
                urwid.SolidFill(u'\N{LOWER ONE QUARTER BLOCK}'), 'line')
        else:
            self.hline = urwid.AttrWrap(urwid.SolidFill(u' '), 'line')

        for graph in self.graphs.values():
            graph.set_smooth_colors(state)

        self.show_graphs() 
开发者ID:amanusk,项目名称:s-tui,代码行数:18,代码来源:s_tui.py

示例7: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def __init__(self, filename):
        self.header = urwid.Text(" BINCH: %s" % (filename))

        self.disasmblr = Disassembler(filename)

        items = self.setup_list(True)
        self.disasmlist = DisassembleList(items)
        start_index = self.find_index(self.disasmblr.entry)
        if start_index != -1:
            self.disasmlist.set_focus(start_index)

        self.history = list()

        self.body = urwid.Padding(self.disasmlist, 'center', 105)
        self.body = urwid.Filler(self.body, ('fixed top',1), ('fixed bottom',1))

        self.footer = StatusBar("HotKeys -> g: Go to a address | s: Save | d: Remove | enter: Modify | q: Quit", self)
        self.view = DisassembleWindow(self,
                urwid.AttrWrap(self.body, 'body'),
                urwid.AttrWrap(self.header, 'head'),
                self.footer)

        signals.call_delay.connect(self.sig_call_delay) 
开发者ID:tunz,项目名称:binch,代码行数:25,代码来源:view.py

示例8: make_failed_view

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
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) 
开发者ID:chishui,项目名称:terminal-leetcode,代码行数:27,代码来源:result.py

示例9: make_compile_error_view

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
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) 
开发者ID:chishui,项目名称:terminal-leetcode,代码行数:24,代码来源:result.py

示例10: make_runtime_error_view

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def make_runtime_error_view(self):
        blank = urwid.Divider()
        status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body')
        status = urwid.AttrWrap(urwid.Text('Runtime Error'), 'hometag')
        columns = urwid.Columns([(17, status_header), (20, status)])
        column_wrap = urwid.WidgetWrap(columns)
        result_header = urwid.Text('--- Run Code Result: ---', align='center')
        error_header = urwid.Text('Runtime Error Message:')
        error_message = urwid.Text(self.result['runtime_error'])
        your_input_header = urwid.Text('Last input:')
        your_input = urwid.Text(self.result['last_testcase'])
        list_items = [
            result_header,
            blank, column_wrap,
            blank, error_header, error_message,
            blank, your_input_header, your_input,
        ]
        self._append_stdout_if_non_empty(list_items)
        return urwid.Padding(urwid.ListBox(urwid.SimpleListWalker(list_items)), left=2, right=2) 
开发者ID:chishui,项目名称:terminal-leetcode,代码行数:21,代码来源:result.py

示例11: make_unified_error_view

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
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) 
开发者ID:chishui,项目名称:terminal-leetcode,代码行数:24,代码来源:result.py

示例12: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def __init__(self, data, marks, sel=True):
        self.sel = sel
        self.id = data.id
        self.data = data
        lockbody = 'body' if not self.data.locked else 'lock'
        pass_symbol = u''
        if self.data.submission_status == 'ac':
            pass_symbol = u'\u2714'
        elif self.data.submission_status == 'notac':
            pass_symbol = u'\u2718'
        text = str(self.data.id)
        mark = make_mark(marks, self.data.id)
        self.item = [
            (4, urwid.AttrWrap(urwid.Text(text), lockbody, 'focus')),
            (2, urwid.AttrWrap(urwid.Text(pass_symbol), lockbody, 'focus')),
            (10, urwid.AttrWrap(urwid.Text(mark), 'hometag', 'focus')),
            urwid.AttrWrap(urwid.Text('%s ' % data.title + (u'\u2605'if self.data.favorite else '')), lockbody, 'focus'),
            (15, urwid.AttrWrap(urwid.Text('%s' % data.acceptance), lockbody, 'focus')),
            (15, urwid.AttrWrap(urwid.Text('%s' % data.difficulty), lockbody, 'focus')),
        ]
        w = urwid.Columns(self.item)
        urwid.WidgetWrap.__init__(self, w) 
开发者ID:chishui,项目名称:terminal-leetcode,代码行数:24,代码来源:home.py

示例13: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def __init__(self, urwidViewManager):
        uvm = urwidViewManager
        close_button = urwid.Button("that's pretty cool")
        urwid.connect_signal(close_button, 'click',
            lambda button:self._emit("close"))

        historyButtonList = []
        for i in uvm.history:
            historyButtonList.append(urwid.Button(str(i), uvm.displayThread))

        pile = urwid.Pile(historyButtonList)
        # 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')) 
开发者ID:wtheisen,项目名称:TerminusBrowser,代码行数:18,代码来源:customUrwidClasses.py

示例14: _add_item

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def _add_item(self, name, func):
        """
        Add an item to the list with a divider.

        Args:
           name (str): The name of the option
           func: The function to call afterwards
        """
        self.options.append(
            urwid.AttrWrap(
                urwid.Divider(u'\u2500'),
                'panel_divider',
                'panel_divider_focus'))

        self.options.append(
            urwid.AttrWrap(
                urwid.Button(name, on_press=func),
                'panel',
                'panel_focus')) 
开发者ID:and3rson,项目名称:clay,代码行数:21,代码来源:songlist.py

示例15: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import AttrWrap [as 别名]
def __init__(self):
        self._header = urwid.Text("Command: ")
        self._edit_box = urwid.Edit()
        self._output_list = urwid.ListBox(urwid.SimpleFocusListWalker([]))
        self._output_layout = urwid.BoxAdapter(self._output_list, 0)  # Dynamically change size.

        self._lock = Lock()
        self._prompt_mode = False
        self._prompt_queue = Queue()

        self._main_loop = None

        urwid.Pile.__init__(self, [
            urwid.AttrWrap(self._header, "reversed"),
            self._output_layout,
            self._edit_box
        ])

        self.focus_item = self._edit_box 
开发者ID:Marten4n6,项目名称:EvilOSX,代码行数:21,代码来源:cli.py


注:本文中的urwid.AttrWrap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。