zuke.tools.qr
@zuke/qr 1.2.0: @zuke/qr — QR codes for any data, from a Zuke build, with no dependency.
zuke on PyPI ↗ 2 symbols
Symbols
class QrSettings(Settings) Configuration for encoding and rendering a QR code, set through a lambda passed to a QrTasks method. Every setter returns this so calls chain.
-
error_correction(level: Literal['L', 'M', 'Q', 'H']) -> SelfSet the error-correction level:
"L"(~7%),"M"(~15%),"Q"(~25%) or"H"(~30%). -
boost_error_correction(enabled: bool | None=None) -> SelfWhether to raise the error-correction level when a higher one fits the same version. On by default; turn it off to get exactly the level asked for.
-
quiet_zone(modules: float) -> SelfSet the width of the light border around the symbol, in modules (0 to MAX_QUIET_ZONE).
-
invert(enabled: bool | None=None) -> SelfSwap the colours: light modules become blocks and dark ones spaces. Use it on a terminal whose text is light on dark, where the default rendering shows the code with dark and light exchanged.
-
compact(enabled: bool | None=None) -> SelfWhether to draw two module rows per line with
▀/▄/█(the default, which keeps a version-3 code under 20 lines) or one row per line with a two-character██cell per module.
class QrTasks Task-shaped QR code operations. Each method takes the text to encode (a URL, usually) and an optional settings lambda:
``ts import { QrTasks } from "@zuke/qr";
QrTasks.print("https://zuke.build", (s) => s.errorCorrection("Q")); ``
-
static async encode(ctx: ServiceContext, text: str, configure: Callable[[QrSettings], QrSettings] | None=None) -> objectEncode
text(as UTF-8, byte mode) into a QrCode matrix. -
static async render_lines(ctx: ServiceContext, text: str, configure: Callable[[QrSettings], QrSettings] | None=None) -> objectEncode
textand render it as terminal lines (see QrSettings.compact). -
static async render(ctx: ServiceContext, text: str, configure: Callable[[QrSettings], QrSettings] | None=None) -> objectEncode
textand render it as one newline-joined string.