kumiki.finishing¶
Flat import path
kumiki/__init__.py re-exports everything on this page via from kumiki import *, so every name below is also available directly as kumiki.FinishingCancelled -- you do not need to import from the submodule path shown in the heading above.
kumiki.finishing
¶
Work a frame leaves for after it is shown, and the tools it offers.
A frame function can hand back slow work, such as generated drawings, to run once the frame is on screen. The routine is written inside the frame function, so it uses what the build computed::
@frame
def shed(k: Optional[Kiwari] = None) -> Frame:
frame = Frame.from_joints(joints, kiwari=k)
groups = match_timbers(frame.cut_timbers)
def later(finishing: Finishing) -> None:
for group in groups:
finishing.add_drawing(piece_drawing(group))
return frame.with_finishing(later)
Kigumi runs the routine in the background after showing the frame, and shows each drawing as it
is added. frame.finish() runs it straight away, for scripts and tests.
A frame also offers tools: functions the viewer can run on demand, each returning text to show::
frame = replace(frame, tools=[Tool("leg report", "How many legs there are",
lambda: f"{k.count('legs')} legs")])
FinishingCancelled
¶
Bases: Exception
Raised inside a finishing routine when its frame has been replaced and its work is no longer wanted.
Finishing
¶
Finishing(on_drawing: Callable[[Drawing], None], on_progress: Optional[Callable[[int, Optional[int], Optional[str]], None]] = None, should_cancel: Optional[Callable[[], bool]] = None)
What a finishing routine is handed: where to put what it makes.
Every call raises FinishingCancelled once the work is no longer wanted, so a routine stops at its next call without checking for itself.