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


Python urwid.Columns方法代码示例

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


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

示例1: _create_widget

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [as 别名]
def _create_widget(self, instance):
        widgets = [
            (25, SSHCheckBox(
                instance.name[:21],
                instance.is_connectable,
                self._run_tmux,
                self.not_checkable_callback,
                on_state_change=self.instance_check_changed,
                user_data=instance)),
            (15, ClippedText(instance.private_ip or '-')),
            (15, ClippedText(instance.public_ip or '-')),
            (15, ClippedText(instance.type[:15])),
            (3, ClippedText('O' if instance.is_running else 'X')),
            ClippedText(instance.key_name or '-'),
        ]

        columns_widget = Columns(widgets, dividechars=1)
        return AttrMap(columns_widget, None, 'instance_focus') 
开发者ID:leejaycoke,项目名称:ec2-gazua,代码行数:20,代码来源:gazua.py

示例2: _init_views

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [as 别名]
def _init_views(self):
        aws_names = list(self.manager.aws_names)
        self.aws_view = AWSView(aws_names)

        aws_name = self.aws_view.get_selected_name()
        group_names = list(self.manager.instances[aws_name].keys())
        self.group_view = GroupView(group_names)

        group_name = self.group_view.get_selected_name()
        init_instances = self.manager.instances[aws_name][group_name]
        self.instance_view = InstanceView(init_instances)

        urwid.connect_signal(self.aws_view.get_walker(), "modified",
                             self.on_aws_changed)
        urwid.connect_signal(self.group_view.get_walker(), "modified",
                             self.on_group_changed)

        self.view = Columns([
            (15, self.aws_view.get_widget()),
            (25, self.group_view.get_widget()),
            self.instance_view.get_widget()
        ]) 
开发者ID:leejaycoke,项目名称:ec2-gazua,代码行数:24,代码来源:gazua.py

示例3: make_table_with_categories

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [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

示例4: stream_header

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [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

示例5: test_main_view_generates_stream_header

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [as 别名]
def test_main_view_generates_stream_header(self, mocker, message,
                                               to_vary_in_last_message):
        self.model.stream_dict = {
            5: {
                'color': '#bd6',
            },
        }
        last_message = dict(message, **to_vary_in_last_message)
        msg_box = MessageBox(message, self.model, last_message)
        view_components = msg_box.main_view()
        assert len(view_components) == 3

        assert isinstance(view_components[0], Columns)

        assert isinstance(view_components[0][0], Text)
        assert isinstance(view_components[0][1], Text)
        assert isinstance(view_components[0][2], Divider) 
开发者ID:zulip,项目名称:zulip-terminal,代码行数:19,代码来源:test_ui_tools.py

示例6: _build_footer

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [as 别名]
def _build_footer(self):
        no = menu_btn(on_press=self.cancel,
                      label="\n  NO\n")
        yes = menu_btn(on_press=self.submit,
                       label="\n  YES\n")
        self.buttons = Columns([
            ('fixed', 2, Text("")),
            ('fixed', 11, Color.menu_button(
                no,
                focus_map='button_primary focus')),
            Text(""),
            ('fixed', 11, Color.menu_button(
                yes,
                focus_map='button_primary focus')),
            ('fixed', 2, Text(""))
        ])

        self.footer = Pile([
            Padding.line_break(""),
            self.buttons
        ])
        return Color.frame_footer(self.footer) 
开发者ID:conjure-up,项目名称:conjure-up,代码行数:24,代码来源:destroy_confirm.py

示例7: _build_widget

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [as 别名]
def _build_widget(self):
        applications = self.app.juju.client.applications
        total_items = [Instruction("Deployment Information:"), HR()]
        tbl = Pile([
            Columns([('fixed', 15, Text("Name")),
                     Text(self.model['name'])]),
            Columns([('fixed', 15, Text("Cloud")),
                     Text(self.model['cloud'])]),
            Columns([('fixed', 15, Text("Status")),
                     Text(self.model['status']['current'])]),
            Columns([('fixed', 15, Text("Online")),
                     Text(self._sanitize_date(
                         self.model['status']['since']))]),
            Columns([('fixed', 15, Text("Applications")),
                     Text(", ".join(applications.keys()))]),
            Columns([('fixed', 15, Text("Machines")),
                     Text(str(self._total_machines(self.model)))])

        ])
        total_items.append(tbl)
        total_items.append(HR())
        return Padding.center_80(Filler(Pile(total_items), valign='top')) 
开发者ID:conjure-up,项目名称:conjure-up,代码行数:24,代码来源:destroy_confirm.py

示例8: _build_sudo_field

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [as 别名]
def _build_sudo_field(self):
        if not utils.is_linux() or not self.model.needs_sudo:
            return []

        rows = []
        if not self.app.sudo_pass:
            self.sudo_input = PasswordEditor()
        self.clear_sudo_error()
        columns = [
            ('weight', 0.5, Padding.left(self.sudo_label, left=5)),
        ]
        if self.sudo_input:
            columns.append((
                'weight', 1,
                Filler(Color.string_input(self.sudo_input,
                                          focus_map='string_input focus'),
                       valign='bottom')))
        rows.extend([
            Padding.line_break(""),
            Columns(columns, dividechars=3, box_columns=[1]),
        ])
        return rows 
开发者ID:conjure-up,项目名称:conjure-up,代码行数:24,代码来源:step.py

示例9: run

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [as 别名]
def run(self):
        """
        prompt for text input.
        """
        # set up widgets
        leftpart = urwid.Text(self.arguments.prompt_text, align='left')
        editpart = urwid.Edit(multiline=True, edit_text=self.arguments.initial_text)

        # build promptwidget
        edit = urwid.Columns([
            ('fixed', len(self.arguments.prompt_text), leftpart),
            ('weight', 1, editpart),
        ])
        self.ui.prompt_bar = urwid.AttrMap(edit, "main_list_dg")

        self.ui.reload_footer()
        self.ui.set_focus("footer")

        urwid.connect_signal(editpart, "change", run_command_callback,
                             user_args=[self.ui, self.docker_object]) 
开发者ID:TomasTomecek,项目名称:sen,代码行数:22,代码来源:ui.py

示例10: build

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [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

示例11: build

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [as 别名]
def build(self):
        environments = db.get_environment_names()
        reports = [None] + db.get_report_names()

        self._envsel = widgets.ListScrollSelector(environments)
        self._repsel = widgets.ListScrollSelector(reports)
        self._tclist = urwid.SimpleListWalker([])
        butcols = urwid.Columns([
                ("pack", urwid.Text("environment:")),
                AM(self._envsel, "selectable", "butfocus"),
                ("pack", urwid.Text("report:")),
                AM(self._repsel, "selectable", "butfocus"),
            ], dividechars=2)
        header = urwid.Pile([
        AM(urwid.Text("Select environment, report, and set options. Use Tab to switch to environment selector. Selected:"), "subhead"),
                urwid.BoxAdapter(urwid.ListBox(self._tclist), 2),
                butcols,
        ])
        body = self._build_test_selector(False)
        return urwid.Frame(body, header=header, focus_part="body") 
开发者ID:kdart,项目名称:pycopia,代码行数:22,代码来源:runner.py

示例12: _construct_spacer

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [as 别名]
def _construct_spacer(self, pos, acc):
        """
        build a spacer that occupies the horizontally indented space between
        pos's parent and the root node. It will return a list of tuples to be
        fed into a Columns widget.
        """
        parent = self._walker.parent_position(pos)
        if parent is not None:
            grandparent = self._walker.parent_position(parent)
            if self._indent > 0 and grandparent is not None:
                parent_sib = self._walker.next_sibling_position(parent)
                draw_vbar = parent_sib is not None and self._arrow_vbar_char is not None
                space_width = self._indent - 1 * (
                    draw_vbar) - self._childbar_offset
                if space_width > 0:
                    void = AttrMap(urwid.SolidFill(' '), self._arrow_att)
                    acc.insert(0, ((space_width, void)))
                if draw_vbar:
                    barw = urwid.SolidFill(self._arrow_vbar_char)
                    bar = AttrMap(
                        barw, self._arrow_vbar_att or self._arrow_att)
                    acc.insert(0, ((1, bar)))
            return self._construct_spacer(parent, acc)
        else:
            return acc 
开发者ID:kdart,项目名称:pycopia,代码行数:27,代码来源:treewidgets.py

示例13: _construct_line

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [as 别名]
def _construct_line(self, pos):
        """
        builds a list element for given position in the tree.
        It consists of the original widget taken from the TreeWalker and some
        decoration columns depending on the existence of parent and sibling
        positions. The result is a urwid.Culumns widget.
        """
        line = None
        if pos is not None:
            original_widget = self._walker[pos]
            cols = self._construct_spacer(pos, [])

            # Construct arrow leading from parent here,
            # if we have a parent and indentation is turned on
            if self._indent > 0:
                indent = self._construct_first_indent(pos)
                if indent is not None:
                    cols = cols + indent

            # add the original widget for this line
            cols.append(original_widget)
            # construct a Columns, defining all spacer as Box widgets
            line = urwid.Columns(cols, box_columns=range(len(cols))[:-1])
        return line 
开发者ID:kdart,项目名称:pycopia,代码行数:26,代码来源:treewidgets.py

示例14: _create_relation_input

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [as 别名]
def _create_relation_input(self):
        choices = dict(models.get_choices(self.session, self.modelclass, self.metadata.colname, None))
        addnew = urwid.Button("Add New")
        urwid.connect_signal(addnew, 'click', self._add_new_related)
        # Cancel
        canc = urwid.Button("Cancel")
        urwid.connect_signal(canc, 'click', self._cancel)
        butcol = urwid.Columns([AM(addnew, "buttn", "buttnf"), AM(canc, "buttn", "buttnf")])
        wlist = [butcol]
        if self.metadata.nullable:
            entry = ListEntry(urwid.Text("None (remove)"))
            urwid.connect_signal(entry, 'activate', self._single_select)
            wlist.append(entry)
        for pk, cname in choices.items():
            entry = ListEntry(urwid.Text(cname))
            urwid.connect_signal(entry, 'activate', self._single_select, pk)
            wlist.append(entry)
        listbox = urwid.ListBox(urwid.SimpleListWalker(wlist))
        return urwid.BoxAdapter(urwid.LineBox(listbox), 9) 
开发者ID:kdart,项目名称:pycopia,代码行数:21,代码来源:widgets.py

示例15: build

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Columns [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


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