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


Python Table._calc方法代码示例

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


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

示例1: wrap

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import _calc [as 别名]
    def wrap(self, availWidth, availHeight):
        """Reimplementation of Table.wrap().

        It works by mimicking the width calculation on a dummy Table, and if
        the result warrant it, by scaling down the text and padding of each
        cell.

        """

        ## Create a standard Table with the same contents and style as ours.
        ## Use it to determine if it fits inside our available width.

        args, kwargs = self.init_args
        std_table = Table(*args, **kwargs)
        std_table._calc(availWidth, availHeight)

        ## Cache the cell metrics. The Platypus layout algorithm may call this
        ## any number of times, and we only want to compute new metrics based
        ## on the original cell metrics.

        if not self._cached_cell_styles:
            self._cached_cell_styles = copy.deepcopy(self._cellStyles)

        if availWidth < std_table._width and len(self._cellStyles) > 0:

            ## If a standard table wouldn't fit, attempt to resize the current
            ## table's contents.

            ratio = availWidth / float(std_table._width)

            for current_line, cached_line in zip(self._cellStyles, self._cached_cell_styles):
                for current_cell, cached_cell in zip(current_line, cached_line):
                    current_cell.fontsize      = ratio * cached_cell.fontsize
                    current_cell.leftPadding   = ratio * cached_cell.leftPadding
                    current_cell.rightPadding  = ratio * cached_cell.rightPadding
                    current_cell.topPadding    = ratio * cached_cell.topPadding
                    current_cell.bottomPadding = ratio * cached_cell.bottomPadding

        return Table.wrap(self, availWidth, availHeight)
开发者ID:securactive,项目名称:sact.resizabletable,代码行数:41,代码来源:resizabletable.py


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