Welcome to reportlab-flexbox!¶
ReportLab-FlexBox is a implementation of the css FlexBox for reportlab. Simply layout manager inspired by the powerful flexbox, intended to reduce the tedious work of positioning and sizing flowables using the Wrap(availWidth, availHeight)
method. Additionally the package adds some basic css inspired styling options such as paddings, margins, background and borders.
Reportlab-flexbox has two main components.
- The FlexItem , a flowable with does two things. Firstly it provides an automatic wrapping function and secondly it provides some basic css-inspired styling.
- The FlexBox , a layout manager (which it self is also a FlexItem) which positions given Flowables/FlexItems.
- Github
- https://github.com/SverkerSbrg/reportlab-flexbox/
- Documentation
- http://reportlab-flexbox.readthedocs.io/en/latest/
- Python package index (pypi)
- https://pypi.python.org/pypi/reportlab-flexbox/
- ReportLab
- https://www.reportlab.com/ https://pypi.python.org/pypi/reportlab/
Warning
This package is still in beta. The api may still be subject to change and the documentation is patchy.
Table of contents¶
Welcome to reportlab-flexbox!¶
ReportLab-FlexBox is a implementation of the css FlexBox for reportlab. Simply layout manager inspired by the powerful flexbox, intended to reduce the tedious work of positioning and sizing flowables using the Wrap(availWidth, availHeight)
method. Additionally the package adds some basic css inspired styling options such as paddings, margins, background and borders.
Reportlab-flexbox has two main components.
- The FlexItem , a flowable with does two things. Firstly it provides an automatic wrapping function and secondly it provides some basic css-inspired styling.
- The FlexBox , a layout manager (which it self is also a FlexItem) which positions given Flowables/FlexItems.
- Github
- https://github.com/SverkerSbrg/reportlab-flexbox/
- Documentation
- http://reportlab-flexbox.readthedocs.io/en/latest/
- Python package index (pypi)
- https://pypi.python.org/pypi/reportlab-flexbox/
- ReportLab
- https://www.reportlab.com/ https://pypi.python.org/pypi/reportlab/
Warning
This package is still in beta. The api may still be subject to change and the documentation is patchy.
QuickStart¶
FlexItem¶
A flowable providing a automatic wrapping function and basic css-style styling intended to be used as base-class for better flowables.
Sizing your FlexItem¶
Sizing flowables in ReportLab is build around the wrap(availWidth, availHeight)
which allows each flowable to determine how much space they need given the avaliable width and height.
The size of a FlexItem is determined by two things
- The min_width, width, max_width, min_height, height and max_height arguments
- The size of its content, determined by the
wrap_content(content_width, content_height)
method used to determine the size of the content in the FlexItem. By default wrap_content returns 0, 0
The final size of the FlexItem is the largest of the two. That is if the content of a FlexItem is larger then the FlexItem’s arguments stipulates the content size will take precedence.
Adding content¶
Two methods ´´wrap_content´´ and ´´draw_content´´
FlexFlowable¶
A simple utility class which empowers a existing Flowable by wrapping it in a FlexItem.
For example a FlexParagraph
which automatically uses half of the avaliable width can be implemented like so:
class FlexParagraph(FlexFlowable):
def __init__(self, text, style):
super().__init__(
flowable=Paragraph(text, style),
width="50%"
)
FlexBox¶
A layout manager inspired by the css FlexBox.