pyboxbuilder.lid.builder.LidBuilder

class pyboxbuilder.lid.builder.LidBuilder(text: str | None = None, label_mode: LabelMode | None = None, label_shape: LabelShape | str | None = None, font: str | None = None, text_spacing: float | None = None, label_finial: LabelFinial | str | None = None, diagonal: bool | None = None, text_color: Color | None = None, frame_color: Color | None = None, pattern: PatternBuilder | PatternType | str | None = PatternBuilder(type=<PatternType.HEX: 'hex'>, colors=(), spacing=None, web=None, border=None, inlay=False, through_inlay=False, inlay_depth_mm=None, through_holes=False, hole_ratio=0.5, backing_pattern=<PatternType.HEX: 'hex'>, backing_spacing=None, backing_web=None, top_skin_mm=None), pattern_color: Color | str | None = None, pattern_colors: tuple[Color | str, ...] | list[Color | str] | None = None, pattern_through_inlay: bool | tuple[int, ...] | None = None, pattern_inlay_depth_mm: float | None = None, backing_pattern: PatternBuilder | PatternType | str | None = None, top_skin_mm: float | None = None, logo: Any | None = None, logo_color: Color | None = None, logo_position: str | None = None, label_logo_size_mm: float | None = None, min_text_height_mm: float | None = None, max_text_height_mm: float | None = None, border_margin_mm: float | None = None, label_border_mm: float | None = None, label_text_gap_mm: float | None = None, label_rounding_mm: float | None = None, label_solid_background: bool | None = None, label_background_color: Color | str | None = None, label_clearance_mm: float | None = None, label_center: tuple[float, float] | None = None, label_area: tuple[float, float, float, float] | None = None, min_hole_size_mm: float = 10.0, mmu_label: LidBuilder | None = None, single_label: LidBuilder | None = None)[source]

Bases: object

Lid decoration configuration.

One of these usually describes a style rather than a single lid — the same frame, pattern and colours across a whole insert — so titled() makes a copy carrying one box’s text instead of repeating the style at every box (FR-000b):

LEAF = LidBuilder(label_mode=LabelMode.FRAMELESS, diagonal=True,
                  pattern=PatternBuilder(PatternType.HEX))
...
project.box(BoxType.SLIDING, "Favor", lid=LEAF.titled("Favors"))

Examples

A frameless diagonal label on a hex-patterned lid:

project = Project("FancyGame", game_box_size=(300, 200, 80))
STYLE = LidBuilder(
    label_mode=LabelMode.FRAMELESS,
    diagonal=True,
    pattern=PatternBuilder(PatternType.HEX, spacing=10.0),
)
project.box(
    BoxType.SLIDING, "Treasure", size=(90, 70, 40),
    lid=STYLE.titled("Treasure", text_color=Color("gold")),
)
project.show(only="Treasure")
Loading 3-D preview…

⬇ Download STL mesh

for_mode(mode: ColorMode | str) → LidBuilder[source]

Return this lid as it prints in one colour mode.

A per-mode override carries only the fields it sets. That has to be decided by what the caller passed rather than by comparing against the field’s default, which is what this used to do: a single_label asking for LabelMode.FRAMED was indistinguishable from one that said nothing, diagonal=False could not turn off a diagonal, and the margins were taken from the override whether it mentioned them or not.

Parameters:
mode: ColorMode | str

ColorMode or string ("mmu" or "single").

Returns:

The effective configuration; self when that mode sets nothing.

resolve_for_mode(mode: ColorMode | str) → LidBuilder[source]

Return the deprecated alias for for_mode().

titled(text: str, **overrides: Any) → LidBuilder[source]

Return this lid style, carrying a particular box’s text.

Parameters:
text: str

The label for this box.

**overrides: Any

Any other field to change for this box — usually a colour.

Returns:

A copy; the style it was made from is unchanged.

backing_pattern : PatternBuilder | PatternType | str | None = None

Override for the backing lattice pattern on the lid underside behind top-layer inlays (defaults to HEX).

property border_margin : float

The margin kept clear at the lid’s edge, resolved.

border_margin_mm : float | None = None

Margin the auto-sized label keeps clear of the lid’s edge; None uses BORDER_MARGIN_MM.

diagonal : bool | None = None

Run the text corner to corner rather than along the lid; None is no.

property finial : LabelFinial

The decorative ornament placed underneath label text, resolved.

font : str | None = None

Font family/style for lid label text (e.g. "Futura:style=Bold"); None uses the library default ("Liberation Sans:style=Bold").

frame_color : Color | None = None

Top-layer colour of the framed label’s outer edge border ring; None leaves the border the box’s own lid colour. The interior 1.5mm spacing and strips holding the text always keep the lid colour with open through-holes between the strips.

property is_diagonal : bool

Whether the text runs corner to corner, resolved.

label_area : tuple[float, float, float, float] | None = None

Explicit (x, y, width, length) bounding box for the label in the lid’s local frame.

When None on a polygon lid, the largest inscribed rectangle is used.

label_background_color : Color | str | None = None

Top-layer colour for the solid interior background inside a framed label’s border ring. Setting a colour automatically enables a solid background (no hatching holes); None leaves a solid background in the lid’s own colour.

label_border_mm : float | None = None

Solid outer border width of the label backing plate; None uses defaults.

label_center : tuple[float, float] | None = None

Explicit (x, y) center position for the label in the lid’s local frame.

When None on a polygon lid, the label is placed in the largest inscribed rectangular space.

property label_clearance : float

The margin kept around the lettering, resolved.

label_clearance_mm : float | None = None

Solid margin kept around the lettering where a pattern meets it.

None uses LABEL_CLEARANCE_MM, which is 0: the holes stop at the glyphs, so the letters read as letters and not as letters on a plaque. They keep their support either way — the keep-out is the glyph outline, and the label is inlaid into the lid rather than perched on it. Raise it for a lid whose pattern is coarse enough that a stroke would otherwise finish on the very edge of a hole.

label_finial : LabelFinial | str | None = None

Decorative typographic ornament placed underneath the label text (NONE, DIAMOND, TRIPLE_DOT, FLEURON, CHEVRON, SCROLLWORK, or SPEAR). Inlaid in frame_color when set, falling back to text_color.

label_logo_size_mm : float | None = None

Target height/width in mm for an image/logo bay embedded inside a framed label. None sizes it automatically from the text height and available lid area.

label_mode : LabelMode | None = None

Framed (border + hatching behind the text) or frameless (text only).

None means FRAMED. It is spelled as None rather than defaulted directly so a per-mode override can tell “I want framed” from “I said nothing about the frame” — see for_mode().

label_rounding_mm : float | None = None

Corner rounding radius of the label backing plate; None uses defaults.

label_shape : LabelShape | str | None = None

Plaque silhouette for framed labels (RECT, PILL, CHAMFERED, HEXAGON, HEX_BRACKET, NOTCHED, RIBBON, DOUBLE_FRAME, UNDERLINE, OVAL, SCALLOPED, BRACKET, SHIELD, SCROLL, CORNER_STUD, or ORNATE_FRAME).

None defaults to RECT. Non-rect decorative shapes default to a clean solid interior plaque unless label_solid_background=False is passed explicitly.

label_solid_background : bool | None = None

Use a solid unperforated background inside a framed label instead of diagonal hatching slots; None uses open through-hole strips unless label_background_color is set.

label_text_gap_mm : float | None = None

Gap between label text and inside of the border; None uses defaults.

SVG path (monochrome or multi-colour), a single- or multi-coloured Bosl2Solid, a PatternResult, a sequence of (shape, colour) pairs, or a callable (width, length, depth) -> ... returning any of those.

logo_color : Color | None = None

Default colour for uncoloured logo parts in inlaid mode; None uses text_color.

logo_position : str | None = None

Placement of logo when combined with text inside a label: "top" (default when both text and logo are set), "left", "right", "bottom", or "center" (overlapping / standalone).

property max_text_height : float

The tallest auto-sized label cap height, resolved.

max_text_height_mm : float | None = None

Maximum cap height for auto-sized label text in mm; None uses MAX_TEXT_HEIGHT_MM.

min_hole_size_mm : float = 10.0

Minimum span (width/length in mm) for the central opening in a polygon lid frame.

If the inner opening in the middle is smaller than this value, it is omitted, leaving the label plate continuous and solid.

property min_text_height : float

The shortest printable label, resolved.

min_text_height_mm : float | None = None

Below this the label is skipped rather than printed illegibly (FR-020).

None uses MIN_TEXT_HEIGHT_MM.

mmu_label : LidBuilder | None = None

Fields to override for the multi-material export (see for_mode()).

property mode : LabelMode

The label style, resolved.

pattern : PatternBuilder | PatternType | str | None = PatternBuilder(type=<PatternType.HEX: 'hex'>, colors=(), spacing=None, web=None, border=None, inlay=False, through_inlay=False, inlay_depth_mm=None, through_holes=False, hole_ratio=0.5, backing_pattern=<PatternType.HEX: 'hex'>, backing_spacing=None, backing_web=None, top_skin_mm=None)

Through-hole pattern, or None for a plain lid.

pattern_color : Color | str | None = None

Colour of the pattern’s top layer; None contrasts with the body.

pattern_colors : tuple[Color | str, ...] | list[Color | str] | None = None

Palette of colours for multi-colour patterns; falls back to pattern.colors or pattern_color.

pattern_inlay_depth_mm : float | None = None

Override for top-layer pattern inlay depth in mm.

pattern_through_inlay : bool | tuple[int, ...] | None = None

Override for whether pattern inlays extend completely through the lid thickness.

property shape : LabelShape

The framed label plaque shape, resolved.

single_label : LidBuilder | None = None

Fields to override for the single-colour export.

text : str | None = None

Label text; None leaves the lid unlabelled.

text_color : Color | None = None

Colour the lettering is inlaid in; None uses black (FR-022).

A label is read against a lid whose colour is the game’s choice, so the default is the one colour that reads against all of them.

text_spacing : float | None = None

Letter-spacing multiplier for lid label text (e.g. 1.18 for wide sci-fi tracking); None uses 1.0.

top_skin_mm : float | None = None

Override for the solid top skin thickness in mm supporting thin colored inlays above the backing lattice.