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


Python tags.table方法代码示例

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


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

示例1: add_images

# 需要导入模块: from dominate import tags [as 别名]
# 或者: from dominate.tags import table [as 别名]
def add_images(self, ims, txts, links, width=400):
        """add images to the HTML file

        Parameters:
            ims (str list)   -- a list of image paths
            txts (str list)  -- a list of image names shown on the website
            links (str list) --  a list of hyperref links; when you click an image, it will redirect you to a new page
        """
        self.t = table(border=1, style="table-layout: fixed;")  # Insert a table
        self.doc.add(self.t)
        with self.t:
            with tr():
                for im, txt, link in zip(ims, txts, links):
                    with td(style="word-wrap: break-word;", halign="center", valign="top"):
                        with p():
                            with a(href=os.path.join('images', link)):
                                img(style="width:%dpx" % width, src=os.path.join('images', im))
                            br()
                            p(txt) 
开发者ID:Mingtzge,项目名称:2019-CCF-BDCI-OCR-MCZJ-OCR-IdentificationIDElement,代码行数:21,代码来源:html.py

示例2: add_images

# 需要导入模块: from dominate import tags [as 别名]
# 或者: from dominate.tags import table [as 别名]
def add_images(self, ims, txts, links, K, width=400):
        """add images to the HTML file

        Parameters:
            ims (str list)   -- a list of image paths
            txts (str list)  -- a list of image names shown on the website
            links (str list) --  a list of hyperref links; when you click an image, it will redirect you to a new page
        """
        self.t = table(border=1, style="table-layout: fixed;")  # Insert a table
        self.doc.add(self.t)
        with self.t:
            with tr():
                for im, txt, link in zip(ims, txts, links):
                    with td(style="word-wrap: break-word;", halign="center", valign="top"):
                        with p():
                            with a(href=os.path.join('images', link)):
                                if txt == 'refs':
                                    img(style="width:%dpx" % K*width, src=os.path.join('images', im))
                                else:
                                    img(style="width:%dpx" % width, src=os.path.join('images', im))
                            br()
                            if txt == 'refs':
                                p(txt+':K='+str(K))
                            else:
                                p(txt) 
开发者ID:liweileev,项目名称:FET-GAN,代码行数:27,代码来源:html.py

示例3: make_table

# 需要导入模块: from dominate import tags [as 别名]
# 或者: from dominate.tags import table [as 别名]
def make_table(exp_list):
    table = []
    headers = list(exp_list[0].keys())
    table.append(headers)
    for exp_info in exp_list:
        exp_vals = []
        for header in headers:
            if header in exp_info:
                exp_vals.append(exp_info[header])
            else:
                exp_vals.append("Not found...")
        table.append(exp_vals)
    return table 
开发者ID:hassony2,项目名称:obman_train,代码行数:15,代码来源:analyzlogutils.py

示例4: add_table

# 需要导入模块: from dominate import tags [as 别名]
# 或者: from dominate.tags import table [as 别名]
def add_table(table):
    with dtags.table().add(dtags.tbody()):
        for row in table:
            with dtags.tr():
                for col_idx, col_val in enumerate(row[1:]):
                    if col_idx == 0:
                        dtags.td().add(dtags.a("{}".format(col_val), href=row[0]))
                    else:
                        if isinstance(col_val, float):
                            col_val = "{0:.5f}".format(col_val)
                        dtags.td().add("{}".format(col_val)) 
开发者ID:hassony2,项目名称:obman_train,代码行数:13,代码来源:analyzlogutils.py

示例5: make_image_table

# 需要导入模块: from dominate import tags [as 别名]
# 或者: from dominate.tags import table [as 别名]
def make_image_table(doc, img_root, img_folders, shuffle=False, max_imgs=20):
    # Get all images for each folder
    all_images = []
    for img_folder in img_folders:
        img_names = [
            os.path.join(img_folder, name)
            for name in sorted(os.listdir(os.path.join(img_root, img_folder)))
        ]
        if shuffle:
            random.shuffle(img_names)
        all_images.append(img_names[:max_imgs])

    # Arrange as list [{0: img_1_folder_0, 1:img_1_folder_1, ..}, ]
    max_len = max([len(images) for images in all_images])
    all_arranged_imgs = []

    # Generate for each row dictionary of folder_idx: img_path
    for idx in range(max_len):
        idx_dic = {}
        for folder_idx, img_names in enumerate(all_images):
            if idx < len(img_names):
                idx_dic[folder_idx] = img_names[idx]
        all_arranged_imgs.append(idx_dic)

    num_folders = len(img_folders)

    with doc:
        with dtags.article(cls="markdown-body"):
            with dtags.table().add(dtags.tbody()):
                for arranged_imgs in all_arranged_imgs:
                    with dtags.tr():
                        for folder_idx in range(num_folders):
                            if folder_idx in arranged_imgs:
                                img_path = arranged_imgs[folder_idx]
                                dtags.td().add(dtags.img(src=img_path))
                            else:
                                dtags.td() 
开发者ID:hassony2,项目名称:obman_train,代码行数:39,代码来源:analyzlogutils.py

示例6: write_table

# 需要导入模块: from dominate import tags [as 别名]
# 或者: from dominate.tags import table [as 别名]
def write_table(self, **kwargs) -> None:
        """
        |write_table| with HTML table format.

        Args:
            write_css (bool):
                If |True|, write CSS corresponding to the specified styles,
                instead of attributes of HTML tags.

        Example:
            :ref:`example-html-table-writer`

        .. note::
            - |None| values will be replaced with an empty value
        """

        tags, raw = _get_tags_module()
        write_css = kwargs.get("write_css", False)

        with self._logger:
            self._verify_property()
            self._preprocess()

            css_class = None

            if write_css:
                css_class = kwargs.get("css_class")
                css_class = css_class if css_class else "{}-css".format(self.table_name)
                css_class = replace_symbol(self.table_name, replacement_text="-")

                css_writer = CssTableWriter()
                css_writer.from_writer(self)
                css_writer.table_name = css_class
                css_writer.write_table(write_style_tag=True)

            if typepy.is_not_null_string(self.table_name):
                if css_class:
                    self._table_tag = tags.table(
                        id=sanitize_python_var_name(self.table_name), class_name=css_class
                    )
                else:
                    self._table_tag = tags.table(id=sanitize_python_var_name(self.table_name))
                self._table_tag += tags.caption(MultiByteStrDecoder(self.table_name).unicode_str)
            else:
                self._table_tag = tags.table()

            try:
                self._write_header()
            except ValueError:
                pass

            self._write_body(not write_css) 
开发者ID:thombashi,项目名称:pytablewriter,代码行数:54,代码来源:_html.py


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