本文整理汇总了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)