Flowable (rinoh.flowable)

class rinoh.flowable.Flowable(align=None, width=None, id=None, style=None, parent=None, source=None)

A document element that can be “flowed” into a container on the page.

A flowable can adapt to the width of the container, or it can horizontally align itself in the container.

Parameters:
align : HorizontalAlignment

horizontal alignment of the flowable

width : FlowableWidth or DimensionBase

the width of the flowable.

class rinoh.flowable.FlowableState(flowable, _initial=True)

Stores a flowable’s rendering state, which can be copied.

This enables saving the rendering state at certain points in the rendering process, so rendering can later be resumed at those points, if needed.

No-Output Flowables

These flowables do not directly place anything on the page. All except DummyFlowable do have side-effects however. Some of these side-effects affect the rendering of the document in an indirect way.

class rinoh.flowable.DummyFlowable(id=None, parent=None)

A flowable that does not directly place anything on the page.

Subclasses can produce side-effects to affect the output in another way.

class rinoh.flowable.AnchorFlowable(id=None, parent=None)

A dummy flowable that registers a destination anchor.

Places a destination for the flowable’s ID at the current cursor position.

class rinoh.flowable.SetMetadataFlowable(parent=None, **metadata)

A dummy flowable that stores metadata in the document.

The metadata is passed as keyword arguments. It will be available to other flowables during the rendering stage.

class rinoh.flowable.WarnFlowable(message, parent=None)

A dummy flowable that emits a warning during the rendering stage.

Parameters:
message : str

the warning message to emit

class rinoh.flowable.PageBreak(page_break='any')

Labeled Flowables

class rinoh.flowable.LabeledFlowable(label, flowable, id=None, style=None, parent=None)

A flowable with a label.

The flowable and the label are rendered side-by-side. If the label exceeds the label_max_width style attribute value, the flowable is rendered below the label.

Parameters:
label : Flowable

the label for the flowable

flowable : Flowable

the flowable to label

style_class

alias of LabeledFlowableStyle

prepare(flowable_target)

Determine number labels and register references with the document

render(container, last_descender, state, label_column_width=None, space_below=0, **kwargs)

Renders the flowable’s content to container, with the flowable’s top edge lining up with the container’s cursor. descender is the descender height of the preceding line or None.

class rinoh.flowable.LabeledFlowableState(flowable, content_flowable_state, _initial=True)

Grouping Flowables

class rinoh.flowable.GroupedFlowables(align=None, width=None, id=None, style=None, parent=None, source=None)

Groups a list of flowables and renders them one below the other.

Makes sure that a flowable for which keep_with_next is enabled is not seperated from the flowable that follows it.

Subclasses should implement flowables().

style_class

alias of GroupedFlowablesStyle

flowables(container)

Generator yielding the Flowables to group

render(container, descender, state, first_line_only=False, **kwargs)

Renders the flowable’s content to container, with the flowable’s top edge lining up with the container’s cursor. descender is the descender height of the preceding line or None.

class rinoh.flowable.GroupedFlowablesState(groupedflowables, flowables, first_flowable_state=None, _initial=True, _index=0)
class rinoh.flowable.StaticGroupedFlowables(flowables, align=None, width=None, id=None, style=None, parent=None, source=None)

Groups a static list of flowables.

Parameters:
flowables : iterable[Flowable]

the flowables to group

flowables(container)

Generator yielding the Flowables to group

build_document(flowable_target)

Set document metadata and populate front and back matter

prepare(flowable_target)

Determine number labels and register references with the document

class rinoh.flowable.GroupedLabeledFlowables(align=None, width=None, id=None, style=None, parent=None, source=None)

Groups a list of labeled flowables, lining them up.

render(container, descender, state, **kwargs)

Renders the flowable’s content to container, with the flowable’s top edge lining up with the container’s cursor. descender is the descender height of the preceding line or None.

Floating Flowables

class rinoh.flowable.Float(align=None, width=None, id=None, style=None, parent=None, source=None)

A flowable that can optionally be placed elsewhere on the page.

If this flowable’s float style attribute is set to True, it is not flowed in line with the surrounding flowables, but it is instead flowed into another container pointed to by the former’s Container.float_space attribute.

This is typically used to place figures and tables at the top or bottom of a page, instead of in between paragraphs.

style_class

alias of FloatStyle

flow(container, last_descender, state=None, **kwargs)

Flow this flowable into container and return the vertical space consumed.

The flowable’s contents are preceded by a vertical space with a height as specified in its style’s space_above attribute. Similarly, the flowed content is followed by a vertical space with a height given by the space_below style attribute.

Styling Properties

class rinoh.flowable.HorizontalAlignment

Controls horizontal placement

Accepts: left, right, center

class rinoh.flowable.FlowableWidth

Controls the width of a flowable

Accepts: auto, fill or a numeric value followed by a unit (pt, in, pc, mm, cm, %, /2, /4)