Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python reportlab:流动中的流动_Python_Reportlab - Fatal编程技术网

Python reportlab:流动中的流动

Python reportlab:流动中的流动,python,reportlab,Python,Reportlab,我想有一个流动的,这只是一个盒子谁有固定的宽度和高度,但可以采取几个流动的内容。因此,该框中的可流动项应该认为框的结尾就是页面的结尾(例如,如果框的宽度不够,段落应该打断行) 我的第一次尝试如下所示: 经过一些研究,我发现我必须实现两种方法:wrapOn()和drawin()。但是我不知道怎么做。你为什么要这么做?你似乎在试图解决框架已经解决的问题。是的,你是对的,我没有注意到框架是我正在寻找的东西。我现在只是想弄明白。 from reportlab.platypus import Flowa

我想有一个流动的,这只是一个盒子谁有固定的宽度和高度,但可以采取几个流动的内容。因此,该框中的可流动项应该认为框的结尾就是页面的结尾(例如,如果框的宽度不够,段落应该打断行)

我的第一次尝试如下所示:


经过一些研究,我发现我必须实现两种方法:
wrapOn()
drawin()
。但是我不知道怎么做。

你为什么要这么做?你似乎在试图解决框架已经解决的问题。是的,你是对的,我没有注意到框架是我正在寻找的东西。我现在只是想弄明白。
from reportlab.platypus import Flowable

class Box(Flowable):

    def __init__(self, width, height, flowables=[]):
        self.width = width
        self.height = height
        self.flowables = flowables

    def draw(self):
        self.canv.rect(0, 0, self.width, self.height)

        for flowable in self.flowables:
           # how to handle flowables that they 
           # match into this flowable?