How to use the sen.tui.widgets.util.SelectableText function in sen

To help you get started, we’ve selected a few sen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TomasTomecek / sen / sen / tui / views / image_info.py View on Github external
def _basic_data(self):
        data = [
            [SelectableText("Id", maps=get_map("main_list_green")),
             SelectableText(self.docker_image.image_id)],
            [SelectableText("Created", maps=get_map("main_list_green")),
             SelectableText("{0}, {1}".format(self.docker_image.display_formal_time_created(),
                                              self.docker_image.display_time_created()))],
            [SelectableText("Size", maps=get_map("main_list_green")),
             SelectableText(humanize_bytes(self.docker_image.total_size))],
        ]
        if self.docker_image.unique_size:
            data.append(
                [SelectableText("Unique Size", maps=get_map("main_list_green")),
                 SelectableText(humanize_bytes(self.docker_image.unique_size))])
        if self.docker_image.shared_size:
            data.append(
                [SelectableText("Shared Size", maps=get_map("main_list_green")),
                 SelectableText(humanize_bytes(self.docker_image.shared_size))])
        data.append([SelectableText("Command", maps=get_map("main_list_green")),
                     SelectableText(self.docker_image.container_command)])
        self.walker.extend(assemble_rows(data, ignore_columns=[1]))
github TomasTomecek / sen / sen / tui / views / container_info.py View on Github external
[SelectableText("Created", maps=get_map("main_list_green")),
             SelectableText("{0}, {1}".format(self.docker_container.display_formal_time_created(),
                                              self.docker_container.display_time_created()))],
            [SelectableText("Command", maps=get_map("main_list_green")),
             SelectableText(self.docker_container.command)],
        ]
        # TODO: add exit code, created, started, finished, pid
        if self.docker_container.names:
            data.append(
                [SelectableText("Name", maps=get_map("main_list_green")),
                 SelectableText("".join(self.docker_container.names))],
            )

        data.append(
            [SelectableText("FS-type", maps=get_map("main_list_white")),
             SelectableText("size", maps=get_map("main_list_white"))])
        data.append(
            [SelectableText("root"), SelectableText(humanize_bytes(self.docker_container.size_root_fs))])
        data.append(
            [SelectableText("rw"), SelectableText(humanize_bytes(self.docker_container.size_rw_fs))])

        self.view_widgets.extend(assemble_rows(data, ignore_columns=[1]))
github TomasTomecek / sen / sen / tui / views / container_info.py View on Github external
data = [
            [SelectableText("Id", maps=get_map("main_list_green")),
             SelectableText(self.docker_container.container_id)],
            [SelectableText("Status", maps=get_map("main_list_green")),
             ContainerStatusWidget(self.docker_container, nice_status=False)],
            [SelectableText("Created", maps=get_map("main_list_green")),
             SelectableText("{0}, {1}".format(self.docker_container.display_formal_time_created(),
                                              self.docker_container.display_time_created()))],
            [SelectableText("Command", maps=get_map("main_list_green")),
             SelectableText(self.docker_container.command)],
        ]
        # TODO: add exit code, created, started, finished, pid
        if self.docker_container.names:
            data.append(
                [SelectableText("Name", maps=get_map("main_list_green")),
                 SelectableText("".join(self.docker_container.names))],
            )

        data.append(
            [SelectableText("FS-type", maps=get_map("main_list_white")),
             SelectableText("size", maps=get_map("main_list_white"))])
        data.append(
            [SelectableText("root"), SelectableText(humanize_bytes(self.docker_container.size_root_fs))])
        data.append(
            [SelectableText("rw"), SelectableText(humanize_bytes(self.docker_container.size_rw_fs))])

        self.view_widgets.extend(assemble_rows(data, ignore_columns=[1]))
github TomasTomecek / sen / sen / tui / chunks / image.py View on Github external
def get_detailed_image_row(docker_image):
    row = []
    image_id = SelectableText(docker_image.short_id, maps=get_map())
    row.append(image_id)

    command = SelectableText(docker_image.command, maps=get_map(defult="main_list_ddg"))
    row.append(command)

    base_image = docker_image.base_image()
    base_image_text = ""
    if base_image:
        base_image_text = base_image.short_name
    base_image_w = SelectableText(base_image_text, maps=get_map())
    row.append(base_image_w)

    time = SelectableText(docker_image.display_time_created(),
                          maps=get_time_attr_map(docker_image.created))
    row.append(time)

    image_names_markup = get_image_names_markup(docker_image)
    # urwid.Text([]) tracebacks
    if image_names_markup:
github TomasTomecek / sen / sen / tui / views / container_info.py View on Github external
def _basic_data(self):
        data = [
            [SelectableText("Id", maps=get_map("main_list_green")),
             SelectableText(self.docker_container.container_id)],
            [SelectableText("Status", maps=get_map("main_list_green")),
             ContainerStatusWidget(self.docker_container, nice_status=False)],
            [SelectableText("Created", maps=get_map("main_list_green")),
             SelectableText("{0}, {1}".format(self.docker_container.display_formal_time_created(),
                                              self.docker_container.display_time_created()))],
            [SelectableText("Command", maps=get_map("main_list_green")),
             SelectableText(self.docker_container.command)],
        ]
        # TODO: add exit code, created, started, finished, pid
        if self.docker_container.names:
            data.append(
                [SelectableText("Name", maps=get_map("main_list_green")),
                 SelectableText("".join(self.docker_container.names))],
            )

        data.append(
github TomasTomecek / sen / sen / tui / views / container_info.py View on Github external
def _image(self):
        if self.docker_container.image:
            self.view_widgets.append(RowWidget([SelectableText("")]))
            self.view_widgets.append(RowWidget([SelectableText("Image", maps=get_map("main_list_white"))]))
            self.view_widgets.append(RowWidget([LayerWidget(self.ui, self.docker_container.image)]))
github TomasTomecek / sen / sen / tui / views / container_info.py View on Github external
def _basic_data(self):
        data = [
            [SelectableText("Id", maps=get_map("main_list_green")),
             SelectableText(self.docker_container.container_id)],
            [SelectableText("Status", maps=get_map("main_list_green")),
             ContainerStatusWidget(self.docker_container, nice_status=False)],
            [SelectableText("Created", maps=get_map("main_list_green")),
             SelectableText("{0}, {1}".format(self.docker_container.display_formal_time_created(),
                                              self.docker_container.display_time_created()))],
            [SelectableText("Command", maps=get_map("main_list_green")),
             SelectableText(self.docker_container.command)],
        ]
        # TODO: add exit code, created, started, finished, pid
        if self.docker_container.names:
            data.append(
                [SelectableText("Name", maps=get_map("main_list_green")),
                 SelectableText("".join(self.docker_container.names))],
            )

        data.append(
            [SelectableText("FS-type", maps=get_map("main_list_white")),
             SelectableText("size", maps=get_map("main_list_white"))])
        data.append(
github TomasTomecek / sen / sen / tui / views / container_info.py View on Github external
BoxAdapter(cpu_g, 12),
            BoxAdapter(mem_g, 12),
            ("weight", 0.5, BoxAdapter(blk_r_g, 12)),
            ("weight", 0.5, BoxAdapter(blk_w_g, 12)),
            ("weight", 0.5, BoxAdapter(net_r_g, 12)),
            ("weight", 0.5, BoxAdapter(net_w_g, 12)),
            BoxAdapter(UnselectableListBox(urwid.SimpleFocusListWalker([
                UnselectableRowWidget([(12, cpu_label), cpu_value]),
                UnselectableRowWidget([(12, mem_label), mem_value]),
                UnselectableRowWidget([(12, blk_r_label), blk_r_value]),
                UnselectableRowWidget([(12, blk_w_label), blk_w_value]),
                UnselectableRowWidget([(12, net_r_label), net_r_value]),
                UnselectableRowWidget([(12, net_w_label), net_w_value]),
            ])), 12),
        ]))
        self.view_widgets.append(RowWidget([SelectableText("")]))

        @log_traceback
        def realtime_updates():
            g = self.docker_container.stats().response
            while True:
                try:
                    update = next(g)
                except Exception as ex:
                    if "Timeout" in ex.__class__.__name__:
                        logger.info("timeout when reading stats: %r", ex)
                        g = self.docker_container.stats().response
                        continue
                    logger.error("error while getting stats: %r", ex)
                    self.ui.notify_message("Error while getting stats: %s" % ex, level="error")
                    # TODO: if debug raise
                    break
github TomasTomecek / sen / sen / tui / widgets / list / util.py View on Github external
def __init__(self, text_markup, maps=None):
        super().__init__([SelectableText(text_markup, maps=maps)])