當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。