當前位置: 首頁>>代碼示例>>Python>>正文


Python urwid.WidgetWrap方法代碼示例

本文整理匯總了Python中urwid.WidgetWrap方法的典型用法代碼示例。如果您正苦於以下問題:Python urwid.WidgetWrap方法的具體用法?Python urwid.WidgetWrap怎麽用?Python urwid.WidgetWrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urwid的用法示例。


在下文中一共展示了urwid.WidgetWrap方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [as 別名]
def __init__(self, controller: Any, question: Any,
                 success_callback: Callable[[], bool]):
        self.controller = controller
        self.success_callback = success_callback
        yes = urwid.Button('Yes', self.exit_popup_yes)
        no = urwid.Button('No', self.exit_popup_no)
        yes._w = urwid.AttrMap(urwid.SelectableIcon(
            'Yes', 4), None, 'selected')
        no._w = urwid.AttrMap(urwid.SelectableIcon(
            'No', 4), None, 'selected')
        display_widget = urwid.GridFlow([yes, no], 3, 5, 1, 'center')
        wrapped_widget = urwid.WidgetWrap(display_widget)
        prompt = urwid.LineBox(
            urwid.ListBox(
                urwid.SimpleFocusListWalker(
                    [question, urwid.Divider(), wrapped_widget]
                )))
        urwid.Overlay.__init__(self, prompt, self.controller.view,
                               align="left", valign="top",
                               width=self.controller.view.LEFT_WIDTH + 1,
                               height=8) 
開發者ID:zulip,項目名稱:zulip-terminal,代碼行數:23,代碼來源:views.py

示例2: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [as 別名]
def __init__(self, data, cells):
        self._data = data    # Info of torrent/tracker/file/peer/... as mapping
        self._cells = cells  # Group instance that combines widgets horizontally

        # Create focusable or unfocusable item widget
        if self.columns_focus_map is not NotImplemented:
            item_widget = urwid.AttrMap(
                urwid.AttrMap(cells, attr_map=None, focus_map=self.columns_focus_map),
                self.palette_unfocused, self.palette_focused
            )
        else:
            item_widget = urwid.AttrMap(cells, self.palette_unfocused)
        urwid.WidgetWrap.__init__(self, item_widget)

        # Initialize cell widgets
        self.update(data) 
開發者ID:rndusr,項目名稱:stig,代碼行數:18,代碼來源:base.py

示例3: make_compile_error_view

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [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

示例4: make_runtime_error_view

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [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

示例5: make_unified_error_view

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [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

示例6: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [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

示例7: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [as 別名]
def __init__(self, text, app, align='left'):
        """
        @param text: same as urwid.Text's text parameter
        @param align: same as urwid.Text's align parameter
        """

        self._was_focused = False
        self.text = text
        self.app = app
        urwid.WidgetWrap.__init__(self, urwid.Text(text, align=align))

        if 'X' in self.text[:3]:
            self._selected = True
        else:
            self._selected = False

        data_field = self.text[3:].split()
        hostname = data_field[1]

        self.roles = self.app.hosts[hostname].roles
        self._mon = True if 'mon' in self.roles else False
        self._rgw = True if 'rgw' in self.roles else False
        self._osd = True if 'osd' in self.roles else False 
開發者ID:pcuzner,項目名稱:ceph-ansible-copilot,代碼行數:25,代碼來源:base.py

示例8: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [as 別名]
def __init__(self, name):
        t = urwid.Text(name)
        w = urwid.AttrMap(t, 'body', 'focus')
        urwid.WidgetWrap.__init__(self, w) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:6,代碼來源:widgets.py

示例9: construct_example_tree

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [as 別名]
def construct_example_tree(selectable_nodes=True):

    class FocusableText(urwid.WidgetWrap):
        """Selectable Text used for nodes in our example"""
        def __init__(self, txt):
            t = urwid.Text(txt)
            w = urwid.AttrMap(t, 'body', 'focus')
            urwid.WidgetWrap.__init__(self, w)

        def selectable(self):
            return selectable_nodes

        def keypress(self, size, key):
            return key

    # define root node
    tree = (FocusableText('ROOT'), [])

    # define some children
    c = g = gg = 0  # counter
    for i in range(4):
        subtree = (FocusableText('Child %d' % c), [])
        # and grandchildren..
        for j in range(2):
            subsubtree = (FocusableText('Grandchild %d' % g), [])
            for k in range(3):
                leaf = (FocusableText('Grand Grandchild %d' % gg), None)
                subsubtree[1].append(leaf)
                gg += 1  # inc grand-grandchild counter
            subtree[1].append(subsubtree)
            g += 1  # inc grandchild counter
        tree[1].append(subtree)
        c += 1
    return tree 
開發者ID:kdart,項目名稱:pycopia,代碼行數:36,代碼來源:widgets.py

示例10: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [as 別名]
def __init__(self, txt, handle_keypress=None):
        self._handle_keypress = handle_keypress
        urwid.WidgetWrap.__init__(self, Text(txt)) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:5,代碼來源:treewidgets.py

示例11: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [as 別名]
def __init__(self, data):
        """
        Construct the Question Page.
        :param data: tuple of (answers, question_title, question_desc, question_stats, question_url)
        """
        answer_frame = self.make_frame(data)
        urwid.WidgetWrap.__init__(self, answer_frame) 
開發者ID:gautamkrishnar,項目名稱:socli,代碼行數:9,代碼來源:tui.py

示例12: keypress

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [as 別名]
def keypress(self, size, key):
        """
        Overrides keypress in superclass, so don't fall for the trap! size parameter is needed!
        """
        if key in {'down', 'n', 'N'}:
            self.answer_text.next_ans()
        elif key in {'up', 'b', 'B'}:
            self.answer_text.prev_ans()
        elif key in {'o', 'O'}:
            import webbrowser
            display_header.event('browser', "Opening in your browser...")
            webbrowser.open(self.url)
        elif key == 'left':
            global question_post
            global question_page
            question_post = None
            if question_page is None:
                sys.exit(0)
            else:
                MAIN_LOOP.widget = question_page
        elif key == 'window resize':
            screen_height, screen_width = subprocess.check_output(['stty', 'size']).split()
            if self.screenHeight != screen_height:
                self._invalidate()
                answer_frame = self.make_frame(self.data)
                urwid.WidgetWrap.__init__(self, answer_frame)
        elif key in {'q', 'Q'}:
            sys.exit(0) 
開發者ID:gautamkrishnar,項目名稱:socli,代碼行數:30,代碼來源:tui.py

示例13: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [as 別名]
def __init__(self, txt):
        self.t = urwid.Text(txt)
        w = urwid.AttrMap(self.t, 'body', 'focus')
        urwid.WidgetWrap.__init__(self, w) 
開發者ID:hootnot,項目名稱:oandapyV20-examples,代碼行數:6,代碼來源:oanda_console.py

示例14: mksection

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [as 別名]
def mksection(title, width, items):
    # Setting class variable 'title = title' below produces "NameError: name
    # 'title' is not defined"
    title_, width_ = title, width

    class Section(urwid.WidgetWrap):
        title = title_
        width = width_

        def __init__(self):
            value_widgets = {}
            needed_keys = set()
            rows = []
            label_width = max(len(item.label) for item in items)
            for item in items:
                label_w = urwid.Text(item.label.rjust(label_width))
                value_w = urwid.Text('')
                value_widgets[item] = value_w
                rows.append(urwid.Columns([('pack', label_w),
                                           ('pack', urwid.Text(': ')),
                                           value_w]))
                needed_keys.update(item.needed_keys)
            self._value_widgets = value_widgets
            self.needed_keys = needed_keys
            super().__init__(urwid.Pile(rows))

        def update(self, torrent):
            for item,value_w in self._value_widgets.items():
                value_w.set_text(item.human_readable(torrent))

    return Section 
開發者ID:rndusr,項目名稱:stig,代碼行數:33,代碼來源:details.py

示例15: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import WidgetWrap [as 別名]
def __init__(self, instr, disasmblr, view):
        urwid.WidgetWrap.__init__(self, None)
        self.instruction = instr
        self.hexcode = list(self.instruction.bytes)
        self.isthumb = disasmblr.is_thumb_instr(instr)
        self._editbox = None
        self._hexeditbox = None
        self.edit_mode = False
        self.hex_edit_mode = False
        self.disasmblr = disasmblr
        self.view = view
        self.repeat = 1
        self.mode_plain() 
開發者ID:tunz,項目名稱:binch,代碼行數:15,代碼來源:view.py


注:本文中的urwid.WidgetWrap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。