Dui¶
dui ¶
Declarative UI packages for deckui (.dui).
Load SVG + YAML packages and use them as touchscreen cards or physical keys without writing any Python rendering code.
Examples:
::
from deckui import DuiCard, DuiKey
# Resolve by name — uses the built-in DUI repository
card = DuiCard("DashboardCard")
key = DuiKey("IconKey")
key.set("label", "Power")
@card.on("toggle_play_pause")
async def handle():
...
# Add a custom search path for your own packages
from deckui import add_dui_path
add_dui_path("~/my-dui-packages")
VALID_CATEGORIES
module-attribute
¶
VALID_CATEGORIES = frozenset({'media', 'productivity', 'system', 'gaming', 'social', 'development', 'utilities', 'streaming', 'home-automation', 'communication'})
Controlled vocabulary for the category manifest field.
SpinnerAnimator ¶
Drive frame-by-frame spinner animation on an asyncio event loop.
The animator cycles through pre-rendered frames at a fixed interval, pushing each frame to the device via the provided push_fn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
list[bytes]
|
List of encoded image bytes (one per frame). |
required |
interval_ms
|
int
|
Milliseconds between frame updates. |
required |
push_fn
|
PushFn
|
Async callable |
required |
Source code in src/deckui/dui/animator.py
start
async
¶
Begin the animation loop.
If already running, this is a no-op.
stop
async
¶
Stop the animation loop.
Cancels the running task and waits for it to finish.
Source code in src/deckui/dui/animator.py
DuiCard ¶
Bases: Card
A touchscreen card whose layout and events are defined by a .dui package.
Instead of writing a Python class with imperative Pillow rendering, you describe the UI in an SVG layout and a YAML manifest. The card loads the package, lets you set binding values, and renders the SVG into a PIL Image for the Stream Deck touchscreen.
Examples:
::
from deckui import DuiCard
# Resolve by name from the DUI repository
card = DuiCard("AudioCard")
card.set("artist", "Ash Walker")
@card.on("toggle_play_pause")
async def handle():
...
You can also pass a pre-loaded :class:~deckui.dui.schema.PackageSpec
directly::
from deckui.dui import load_package, DuiCard
spec = load_package("./AudioCard.dui")
card = DuiCard(spec)
The card index is assigned automatically when you install the card
on a screen with :meth:~deckui.ui.screen.Screen.set_card.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
PackageSpec or str
|
A validated :class: |
required |
Source code in src/deckui/dui/card.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | |
set_push_fn ¶
Set the async function used to push animation frames to the device.
This must be called before spinner animations can play.
Typically set by :class:~deckui.runtime.deck.Deck.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
push_fn
|
PushFn
|
Async callable |
required |
panel_size
|
tuple[int, int]
|
|
required |
Source code in src/deckui/dui/card.py
set ¶
Set a binding value. Marks the card dirty if changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name as defined in the manifest. |
required |
value
|
Any
|
New value (type depends on binding kind). |
required |
Returns:
| Type | Description |
|---|---|
DuiCard
|
self, for method chaining. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
Source code in src/deckui/dui/card.py
set_many ¶
get ¶
Get the current value of a binding.
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
set_range ¶
Set a range/slider binding using a domain-scale value.
Normalises value from [min_val, max_val] to [0.0, 1.0]
and delegates to :meth:set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name (must be a |
required |
value
|
float
|
Value in domain units (e.g. 0–100 for a percentage). |
required |
min_val
|
float
|
Lower bound of the domain range. |
0
|
max_val
|
float
|
Upper bound of the domain range. |
1
|
Returns:
| Type | Description |
|---|---|
DuiCard
|
self, for method chaining. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
ValueError
|
If min_val equals max_val. |
Source code in src/deckui/dui/card.py
adjust_range ¶
Adjust a range/slider binding by delta domain-scale units.
Reads the current normalised value, denormalises it, adds delta,
clamps, re-normalises, and calls :meth:set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name (must be a |
required |
delta
|
float
|
Amount to add in domain units (negative to decrease). |
required |
min_val
|
float
|
Lower bound of the domain range. |
0
|
max_val
|
float
|
Upper bound of the domain range. |
1
|
Returns:
| Type | Description |
|---|---|
float
|
The new value in domain units (clamped to
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
ValueError
|
If min_val equals max_val. |
Source code in src/deckui/dui/card.py
get_range ¶
Get a range/slider binding denormalised to domain units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name. |
required |
min_val
|
float
|
Lower bound of the domain range. |
0
|
max_val
|
float
|
Upper bound of the domain range. |
1
|
Returns:
| Type | Description |
|---|---|
float
|
The current value in domain units. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
ValueError
|
If min_val equals max_val. |
Source code in src/deckui/dui/card.py
on ¶
Decorator to register a handler for a named semantic event.
Examples:
::
@card.on("toggle_play_pause")
async def handle():
...
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
Semantic event name from the manifest. |
required |
Returns:
| Type | Description |
|---|---|
Callable
|
A decorator that registers the handler and returns it unchanged. |
Source code in src/deckui/dui/card.py
bind_event ¶
Imperatively register a handler for a named semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
Semantic event name from the manifest. |
required |
handler
|
AsyncHandler
|
The async callable to invoke. |
required |
Source code in src/deckui/dui/card.py
bind ¶
Subscribe to event; on emit, write binding name and refresh.
This fuses three operations that otherwise repeat across every
controller: subscribe to a service AsyncEvent, translate
the emitted value into the binding's domain, and request a
refresh.
Without transform, the binding receives the first positional
argument from the event (args[0]). With transform, the
callable is invoked with all event args/kwargs and its
return value becomes the binding value.
The subscriber lives for the lifetime of the card -- there is
no automatic teardown. Bind once during construction or
:meth:on_attach-style lifecycle hooks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name as defined in the manifest. |
required |
event
|
AsyncEvent
|
The :class: |
required |
transform
|
Callable[..., Any] | None
|
Optional sync callable that maps event args to the binding
value. If |
None
|
Returns:
| Type | Description |
|---|---|
DuiCard
|
self, for method chaining. |
Source code in src/deckui/dui/card.py
bind_range ¶
bind_range(name: str, event: AsyncEvent, *, min_val: float = 0, max_val: float = 1, transform: Callable[..., float] | None = None) -> DuiCard
Subscribe to event; on emit, write binding name via :meth:set_range.
Same shape as :meth:bind, but routes through :meth:set_range
so the emitted value can be in domain units (e.g. a 0--100
percentage).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name (must be a |
required |
event
|
AsyncEvent
|
The :class: |
required |
min_val
|
float
|
Lower bound of the domain range. |
0
|
max_val
|
float
|
Upper bound of the domain range. |
1
|
transform
|
Callable[..., float] | None
|
Optional sync callable that maps event args to a numeric
value in domain units. If |
None
|
Returns:
| Type | Description |
|---|---|
DuiCard
|
self, for method chaining. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If min_val equals max_val. |
Source code in src/deckui/dui/card.py
bind_many ¶
Subscribe to event; transform args into a dict and :meth:set_many it.
Use this when one event drives several bindings at once -- e.g.
a track_changed event populating artist, title,
album, and state from a single track dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
AsyncEvent
|
The :class: |
required |
transform
|
Callable[..., dict[str, Any]]
|
Required sync callable that maps event args to a dict of binding names to values. |
required |
Returns:
| Type | Description |
|---|---|
DuiCard
|
self, for method chaining. |
Source code in src/deckui/dui/card.py
forward ¶
Register target as the handler for manifest event event_name.
Sugar for the very common shape::
@card.on("toggle")
async def _h() -> None:
await svc.toggle()
which becomes::
card.forward("toggle", svc.toggle)
target may be an async function or any sync callable that returns an awaitable (e.g. a lambda whose body invokes an async method). All positional and keyword arguments emitted by the event are forwarded to target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
Semantic event name from the manifest. |
required |
target
|
Callable[..., Any]
|
Async-callable forwarding target. |
required |
Returns:
| Type | Description |
|---|---|
DuiCard
|
self, for method chaining. |
Source code in src/deckui/dui/card.py
render ¶
Render the SVG layout with current bindings to a PIL Image.
Returns:
| Type | Description |
|---|---|
Image
|
A panel-sized RGB :class: |
Source code in src/deckui/dui/card.py
prepare_assets
async
¶
handle_encoder_turn ¶
Route encoder turn through the event map.
handle_encoder_press ¶
handle_encoder_release ¶
dispatch_touch
async
¶
Dispatch touch events through regions and the event map.
Falls back to the base Card touch handlers (on_tap, etc.) if the event map doesn't handle the event.
Source code in src/deckui/dui/card.py
start_busy
async
¶
Enter the busy state and start the spinner animation.
While busy, the card suppresses further start_busy() calls.
The spinner keeps running until :meth:finish_busy is called.
If no spinner is configured in the manifest the busy flag is still set (suppressing duplicate calls) but no animation plays.
Source code in src/deckui/dui/card.py
finish_busy
async
¶
Stop the spinner and exit the busy state.
Call this from your application code when the asynchronous work is truly complete (e.g. after receiving a state update from an external system).
If the card is not currently busy this is a no-op.
Source code in src/deckui/dui/card.py
EventMap ¶
Map physical hardware events to named semantic events.
Handles simple mappings (encoder_press → semantic name) as well as compound gestures:
encoder_press_release: fires only if the press duration is withinmax_duration_ms.encoder_hold/key_hold: starts a timer on press and fires the handler afterhold_mswhile the key/encoder is still held. Suppresses anypress_releaseorreleaseevent for that press–release cycle.encoder_turn: fires turn events only while the encoder is not pressed. Turning while pressed never falls through to this mapping. Immediately after releasing a press cycle that included at least one turn,encoder_turnis suppressed forrelease_turn_grace_msto debounce the spurious tick a finger often produces while lifting off the dial.encoder_press_turn: fires turn events only while the encoder is held down. When declared with a direction filter, mismatching turns while pressed are silent — there is no fallback toencoder_turn. Any turn while pressed cancels a pendingencoder_holdregardless of whether a handler fires.- Direction filtering:
encoder_turnwithdirection: leftonly fires for counter-clockwise turns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
tuple[EventMapping, ...]
|
Event mappings from the package manifest. |
required |
regions
|
tuple[Region, ...]
|
Touch regions from the package manifest. |
()
|
release_turn_grace_ms
|
int
|
Suppression window (in milliseconds) applied to plain
|
DEFAULT_RELEASE_TURN_GRACE_MS
|
Source code in src/deckui/dui/event_map.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
on ¶
Register a handler for a named semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
The semantic event name (as defined in the manifest). |
required |
handler
|
AsyncHandler
|
An async callable to invoke when the event fires.
For accumulated events the handler signature must accept
a single |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
If event_name is not defined in the manifest. |
Source code in src/deckui/dui/event_map.py
cancel_accumulators ¶
handle_encoder_turn ¶
Match an encoder turn to a semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
direction
|
int
|
Positive for clockwise, negative for counter-clockwise. |
required |
Returns:
| Type | Description |
|---|---|
AsyncHandler or None
|
The matched handler, or |
Source code in src/deckui/dui/event_map.py
handle_encoder_press ¶
Match an encoder press to semantic events.
Records the press timestamp for gesture detection and starts
a hold timer if an encoder_hold mapping exists.
Returns:
| Type | Description |
|---|---|
list[AsyncHandler]
|
A list of matched handlers (may be empty). |
Source code in src/deckui/dui/event_map.py
handle_encoder_release ¶
Match an encoder release to semantic events.
Cancels any running hold timer. The simple encoder_release
event always fires regardless of whether a hold fired.
encoder_press_release is suppressed when a hold already
fired for this press–release cycle (since the interaction was
a hold, not a press-release gesture).
If at least one turn occurred during the press cycle, opens a
release_turn_grace_ms window during which subsequent plain
encoder_turn events are ignored.
Returns:
| Type | Description |
|---|---|
list[AsyncHandler]
|
A list of matched handlers (may be empty). |
Source code in src/deckui/dui/event_map.py
handle_key_press ¶
Match a key press to semantic events.
Records the press timestamp and starts a hold timer if a
key_hold mapping exists.
Returns:
| Type | Description |
|---|---|
list[AsyncHandler]
|
A list of matched handlers (may be empty). |
Source code in src/deckui/dui/event_map.py
handle_key_release ¶
Match a key release to semantic events.
Cancels any running hold timer. The simple key_release
event always fires regardless of whether a hold fired.
key_press_release is suppressed when a hold already
fired for this press–release cycle (since the interaction was
a hold, not a press-release gesture).
Returns:
| Type | Description |
|---|---|
list[AsyncHandler]
|
A list of matched handlers (may be empty). |
Source code in src/deckui/dui/event_map.py
handle_touch ¶
Match a touch event to a semantic event via regions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
EventType
|
The touch event type (TOUCH_SHORT or TOUCH_LONG). |
required |
x
|
int
|
Touch x coordinate (relative to card origin). |
required |
y
|
int
|
Touch y coordinate (relative to card origin). |
required |
Returns:
| Type | Description |
|---|---|
AsyncHandler or None
|
The matched handler, or |
Source code in src/deckui/dui/event_map.py
IconifyError ¶
DuiKey ¶
Bases: KeySlot
A physical key whose layout and events are defined by a .dui package.
DuiKey extends :class:~deckui.ui.controls.key_slot.KeySlot
so that it is accepted wherever a KeySlot is expected. It
replaces the icon + label rendering with SVG-based rendering from
a .dui package.
Examples:
::
from deckui import DuiKey
# Resolve by name from the DUI repository
key = DuiKey("IconKey")
key.set("label", "Shutdown")
@key.on_event("activate")
async def handle():
...
You can also pass a pre-loaded :class:~deckui.dui.schema.PackageSpec
directly::
from deckui.dui import load_package, DuiKey
spec = load_package("./PowerKey.dui")
key = DuiKey(spec)
The key index is assigned automatically when you install the key
on a screen with :meth:~deckui.ui.screen.Screen.set_key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
PackageSpec or str
|
A validated :class: |
required |
Source code in src/deckui/dui/key.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | |
has_dui_content
property
¶
Always True — this key is backed by a .dui package.
set_push_fn ¶
Set the async function used to push animation frames to the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
push_fn
|
PushFn
|
Async callable |
required |
key_size
|
tuple[int, int]
|
|
required |
Source code in src/deckui/dui/key.py
set ¶
Set a binding value. Marks the key dirty if changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name as defined in the manifest. |
required |
value
|
Any
|
New value (type depends on binding kind). |
required |
Returns:
| Type | Description |
|---|---|
DuiKey
|
self, for method chaining. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
Source code in src/deckui/dui/key.py
set_many ¶
get ¶
Get the current value of a binding.
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
set_range ¶
Set a range/slider binding using a domain-scale value.
Normalises value from [min_val, max_val] to [0.0, 1.0]
and delegates to :meth:set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name (must be a |
required |
value
|
float
|
Value in domain units (e.g. 0–100 for a percentage). |
required |
min_val
|
float
|
Lower bound of the domain range. |
0
|
max_val
|
float
|
Upper bound of the domain range. |
1
|
Returns:
| Type | Description |
|---|---|
DuiKey
|
self, for method chaining. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
ValueError
|
If min_val equals max_val. |
Source code in src/deckui/dui/key.py
adjust_range ¶
Adjust a range/slider binding by delta domain-scale units.
Reads the current normalised value, denormalises it, adds delta,
clamps, re-normalises, and calls :meth:set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name (must be a |
required |
delta
|
float
|
Amount to add in domain units (negative to decrease). |
required |
min_val
|
float
|
Lower bound of the domain range. |
0
|
max_val
|
float
|
Upper bound of the domain range. |
1
|
Returns:
| Type | Description |
|---|---|
float
|
The new value in domain units (clamped to
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
ValueError
|
If min_val equals max_val. |
Source code in src/deckui/dui/key.py
get_range ¶
Get a range/slider binding denormalised to domain units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name. |
required |
min_val
|
float
|
Lower bound of the domain range. |
0
|
max_val
|
float
|
Upper bound of the domain range. |
1
|
Returns:
| Type | Description |
|---|---|
float
|
The current value in domain units. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
ValueError
|
If min_val equals max_val. |
Source code in src/deckui/dui/key.py
on_event ¶
Decorator to register a handler for a named semantic event.
Examples:
::
@key.on_event("activate")
async def handle():
...
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
Semantic event name from the manifest. |
required |
Returns:
| Type | Description |
|---|---|
Callable
|
A decorator that registers the handler and returns it unchanged. |
Source code in src/deckui/dui/key.py
bind_event ¶
Imperatively register a handler for a named semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
Semantic event name from the manifest. |
required |
handler
|
AsyncHandler
|
The async callable to invoke. |
required |
Source code in src/deckui/dui/key.py
bind ¶
Subscribe to event; on emit, write binding name and refresh.
Mirror of :meth:DuiCard.bind. Subscribes to a service
AsyncEvent, optionally transforms the emitted value, calls
:meth:set, and requests a refresh if the binding changed.
Without transform, the binding receives the first positional
argument from the event. With transform, the callable is
invoked with all event args/kwargs and its return
value becomes the binding value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name as defined in the manifest. |
required |
event
|
AsyncEvent
|
The :class: |
required |
transform
|
Callable[..., Any] | None
|
Optional sync callable that maps event args to the binding
value. If |
None
|
Returns:
| Type | Description |
|---|---|
DuiKey
|
self, for method chaining. |
Source code in src/deckui/dui/key.py
bind_range ¶
bind_range(name: str, event: AsyncEvent, *, min_val: float = 0, max_val: float = 1, transform: Callable[..., float] | None = None) -> DuiKey
Subscribe to event; on emit, write binding name via :meth:set_range.
Mirror of :meth:DuiCard.bind_range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name (must be a |
required |
event
|
AsyncEvent
|
The :class: |
required |
min_val
|
float
|
Lower bound of the domain range. |
0
|
max_val
|
float
|
Upper bound of the domain range. |
1
|
transform
|
Callable[..., float] | None
|
Optional sync callable that maps event args to a numeric
value in domain units. If |
None
|
Returns:
| Type | Description |
|---|---|
DuiKey
|
self, for method chaining. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If min_val equals max_val. |
Source code in src/deckui/dui/key.py
bind_many ¶
Subscribe to event; transform args into a dict and :meth:set_many it.
Mirror of :meth:DuiCard.bind_many.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
AsyncEvent
|
The :class: |
required |
transform
|
Callable[..., dict[str, Any]]
|
Required sync callable that maps event args to a dict of binding names to values. |
required |
Returns:
| Type | Description |
|---|---|
DuiKey
|
self, for method chaining. |
Source code in src/deckui/dui/key.py
forward ¶
Register target as the handler for manifest event event_name.
Mirror of :meth:DuiCard.forward. Sugar for forwarding a DUI
event directly to a service method or callable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
Semantic event name from the manifest. |
required |
target
|
Callable[..., Any]
|
Async-callable forwarding target (async function or sync callable returning an awaitable). |
required |
Returns:
| Type | Description |
|---|---|
DuiKey
|
self, for method chaining. |
Source code in src/deckui/dui/key.py
render_image ¶
Render the SVG layout to image bytes for the key.
The SVG is rasterised and scaled edge-to-edge to key_size (no margins or padding) and encoded in image_format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_size
|
tuple[int, int]
|
Target key dimensions |
required |
image_format
|
str
|
Image encoding format ( |
'JPEG'
|
Returns:
| Type | Description |
|---|---|
bytes
|
Encoded image bytes. |
Source code in src/deckui/dui/key.py
dispatch
async
¶
Dispatch a key press/release through the event map.
All matching handlers (simple and compound) are called. Falls back to the base KeySlot handlers if the event map returns no matches.
Source code in src/deckui/dui/key.py
start_busy
async
¶
Enter the busy state and start the spinner animation.
While busy, the key suppresses further start_busy() calls.
The spinner keeps running until :meth:finish_busy is called.
If no spinner is configured in the manifest the busy flag is still set (suppressing duplicate calls) but no animation plays.
Source code in src/deckui/dui/key.py
finish_busy
async
¶
Stop the spinner and exit the busy state.
Call this from your application code when the asynchronous work is truly complete (e.g. after receiving a state update from an external system).
If the key is not currently busy this is a no-op.
Source code in src/deckui/dui/key.py
PackageError ¶
DuiRepository ¶
Registry of .dui package search paths with in-memory caching.
Directories are searched in priority order — the most recently added path wins when two directories contain a package with the same name. The bundled packages directory is always present as the lowest-priority source and cannot be removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_bundled
|
bool
|
Whether to include the bundled packages directory. Set to
|
True
|
Examples:
::
repo = DuiRepository()
repo.add_path("/home/user/my-packages")
spec = repo.resolve("IconKey")
Source code in src/deckui/dui/repository.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
add_path ¶
Register a directory as a DUI package source.
The directory is inserted at the highest priority position.
If it is already registered it is moved to the top. The
in-memory cache is cleared so that subsequent :meth:resolve
calls pick up any overrides.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Directory containing |
required |
Raises:
| Type | Description |
|---|---|
PackageError
|
If path does not exist or is not a directory. |
Source code in src/deckui/dui/repository.py
remove_path ¶
Unregister a directory. Clears the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Previously registered directory. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If path is not currently registered. |
Source code in src/deckui/dui/repository.py
list_paths ¶
Return registered search paths in priority order (highest first).
The bundled directory is included at the end when
include_bundled is True.
Returns:
| Type | Description |
|---|---|
list[Path]
|
Ordered list of directories. |
Source code in src/deckui/dui/repository.py
resolve ¶
Look up a package by name and return a cached spec.
Search order: user paths (most recently added first), then
bundled packages. The result is cached so that repeated calls
with the same name return the identical :class:PackageSpec
object without re-reading the filesystem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Package name without the |
required |
Returns:
| Type | Description |
|---|---|
PackageSpec
|
A validated, frozen package specification. |
Raises:
| Type | Description |
|---|---|
PackageError
|
If no package with that name exists in any registered path. |
Source code in src/deckui/dui/repository.py
clear_cache ¶
Drop all cached :class:PackageSpec objects.
Subsequent :meth:resolve calls will re-read packages from
disk.
Source code in src/deckui/dui/repository.py
invalidate ¶
Remove a single package from the cache.
Use this after editing a .dui package on disk to force
:meth:resolve to reload it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Package name to invalidate. |
required |
Source code in src/deckui/dui/repository.py
list_packages ¶
List all package names visible across all search paths.
Packages are returned in alphabetical order. If the same name exists in multiple paths only one entry is returned.
Returns:
| Type | Description |
|---|---|
list[str]
|
Sorted package names (without the |
Source code in src/deckui/dui/repository.py
BindingType ¶
Bases: Enum
Supported binding types for SVG node manipulation.
Source code in src/deckui/dui/schema.py
ColorBinding
dataclass
¶
Bind a colour value to an SVG element's fill, stroke, or color.
Source code in src/deckui/dui/schema.py
EventMapping
dataclass
¶
Map a physical input to a named semantic event.
Source code in src/deckui/dui/schema.py
IconifyBinding
dataclass
¶
Load an Iconify icon by name and embed it into an SVG <g> element.
The icon name follows the Iconify convention <prefix>:<name> (for
example line-md:home). Icons are fetched from
https://api.iconify.design on first use and cached in-process.
The resolved icon SVG is inserted as children of the target <g>
node, scaled to a size × size square. Setting the binding
value to None or an empty string removes any previously embedded
icon from the node.
Source code in src/deckui/dui/schema.py
ImageBinding
dataclass
¶
ImageFit ¶
OverflowMode ¶
PackageSpec
dataclass
¶
Fully validated, immutable representation of a loaded .dui package.
Source code in src/deckui/dui/schema.py
PackageType ¶
RangeBinding
dataclass
¶
Scale an SVG element's width or height proportional to a 0–1 value.
Source code in src/deckui/dui/schema.py
RangeDirection ¶
Region
dataclass
¶
A touchscreen hit-test region for touch events.
Source code in src/deckui/dui/schema.py
RotateTransform
dataclass
¶
Rotate an SVG element between two angles proportional to a 0–1 value.
The element is rotated by interpolating linearly between from_angle and to_angle based on the binding's current value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_angle
|
float
|
Rotation angle (degrees) when the value is 0.0. |
0.0
|
to_angle
|
float
|
Rotation angle (degrees) when the value is 1.0. |
360.0
|
origin
|
str
|
Rotation origin. |
'center'
|
Source code in src/deckui/dui/schema.py
SliderBinding
dataclass
¶
Translate an SVG element between two positions proportional to a 0–1 value.
Source code in src/deckui/dui/schema.py
SpinnerSpec
dataclass
¶
Configuration for a spinner animation.
The spinner is started and stopped explicitly by the application
via :meth:~deckui.dui.card.DuiCard.start_busy /
:meth:~deckui.dui.card.DuiCard.finish_busy (and the equivalent
methods on :class:~deckui.dui.key.DuiKey). It provides visual
feedback by cycling pre-rendered animation frames on the key or
card panel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
SpinnerType
|
Animation strategy: |
required |
node
|
str | None
|
SVG element ID to animate (required for |
None
|
frames
|
int
|
Number of frames per animation cycle. |
DEFAULT_SPINNER_FRAMES
|
interval_ms
|
int
|
Milliseconds between frames. |
DEFAULT_SPINNER_INTERVAL_MS
|
background_node
|
str | None
|
Optional SVG element ID shown behind the spinner during busy
state. The node is made visible when the spinner is active and
hidden at rest, but it is not animated (no rotation, pulse,
or opacity changes are applied to it). Ignored for |
None
|
Source code in src/deckui/dui/schema.py
SpinnerType ¶
TextBinding
dataclass
¶
Bind a value to a <text> SVG element's content.
When wrap is True the renderer word-wraps the text into
multiple <tspan> lines that each fit within max_width pixels.
Font metrics are auto-detected from the SVG <text> element.
If the wrapped text exceeds max_height, the last visible line is
truncated according to overflow.
Source code in src/deckui/dui/schema.py
ToggleBinding
dataclass
¶
Switch between two SVG elements based on a boolean value.
When the value is truthy, node_on is visible and node_off
is hidden. When falsy, the opposite applies.
Source code in src/deckui/dui/schema.py
TransformBinding
dataclass
¶
Apply one or more SVG transforms to a node proportional to a 0–1 value.
Each entry in transforms produces an SVG transform attribute
fragment; multiple transforms are composed (space-separated) in order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
str
|
ID of the SVG element to transform. |
required |
default
|
float
|
Initial normalised value (0.0–1.0). |
0.0
|
transforms
|
tuple[TransformSpec, ...]
|
Ordered sequence of transform specifications applied to the node. |
()
|
Source code in src/deckui/dui/schema.py
TransformKind ¶
VisibilityBinding
dataclass
¶
SpinnerFrames ¶
Pre-renders spinner animation frames from an SVG template.
Frames are generated lazily on first access and cached for the lifetime of the instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
PackageSpec
|
The package specification containing the SVG source and spinner config. |
required |
width
|
int
|
Target image width in pixels. |
required |
height
|
int
|
Target image height in pixels. |
required |
image_format
|
str
|
Encoding format ( |
'JPEG'
|
Source code in src/deckui/dui/spinner.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
SvgRenderer ¶
Render a .dui SVG layout with live data bindings.
The renderer holds a parsed copy of the SVG template. Each call
to :meth:render clones the template, applies current binding
values, inlines image assets, and rasterises to a PIL Image via
CairoSVG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
PackageSpec
|
The validated package specification. |
required |
Source code in src/deckui/dui/svg_renderer.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | |
set ¶
Set a binding value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Binding name as defined in the manifest. |
required |
value
|
Any
|
The new value. Type depends on the binding:
text → |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
Source code in src/deckui/dui/svg_renderer.py
set_many ¶
Set multiple binding values at once.
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/deckui/dui/svg_renderer.py
get ¶
Get the current value of a binding.
Raises:
| Type | Description |
|---|---|
KeyError
|
If name is not a known binding. |
Source code in src/deckui/dui/svg_renderer.py
render ¶
Rasterise the SVG with current binding values to a PIL Image.
Returns:
| Type | Description |
|---|---|
Image
|
An RGB :class: |
Source code in src/deckui/dui/svg_renderer.py
render_svg ¶
Return the SVG source with current bindings applied (not rasterised).
This is used by the spinner system to generate frames that reflect the current binding state rather than the raw template.
Returns:
| Type | Description |
|---|---|
str
|
SVG markup as a Unicode string. |
Source code in src/deckui/dui/svg_renderer.py
fetch_icon ¶
Fetch an Iconify icon by prefix:icon name.
The lookup order is: in-memory cache, disk cache, network. Successful fetches are stored in both caches. Negative lookups (404 / network failure) are cached in memory only so a restart retries previously-failed icons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Icon identifier in |
required |
Returns:
| Type | Description |
|---|---|
str
|
The raw SVG source string as served by the Iconify API. |
Raises:
| Type | Description |
|---|---|
IconifyError
|
If the name is malformed, the icon does not exist, or the network request fails. |
Source code in src/deckui/dui/iconify.py
clear_iconify_cache ¶
Drop all cached Iconify icons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
persistent
|
bool
|
When |
False
|
Source code in src/deckui/dui/iconify.py
load_all_packages ¶
Load all .dui packages from a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Path to scan for |
required |
Returns:
| Type | Description |
|---|---|
dict[str, PackageSpec]
|
A dict mapping package names to their specs. |
Raises:
| Type | Description |
|---|---|
PackageError
|
If any package fails validation. |
Source code in src/deckui/dui/loader.py
load_package ¶
Load a .dui package directory into a validated PackageSpec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the |
required |
Returns:
| Type | Description |
|---|---|
PackageSpec
|
A frozen :class: |
Raises:
| Type | Description |
|---|---|
PackageError
|
If the package is invalid or incomplete. |
Source code in src/deckui/dui/loader.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 | |
add_dui_path ¶
Register a directory as a DUI package source.
The directory is inserted at the highest priority position. Packages in this directory will override bundled packages and packages from previously added directories when names collide.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Directory containing |
required |
Raises:
| Type | Description |
|---|---|
PackageError
|
If path does not exist or is not a directory. |
Examples:
::
import deckui
deckui.add_dui_path("/home/user/my-packages")
card = deckui.DuiCard("MyCustomCard")
Source code in src/deckui/dui/repository.py
clear_dui_cache ¶
Drop all cached package specs from the default repository.
Subsequent DuiCard("name") / DuiKey("name") calls will
re-read packages from disk.
list_dui_packages ¶
List all DUI package names visible across all search paths.
Returns:
| Type | Description |
|---|---|
list[str]
|
Sorted package names (without the |
Source code in src/deckui/dui/repository.py
remove_dui_path ¶
Unregister a previously added DUI package directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Previously registered directory. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If path is not currently registered. |
Source code in src/deckui/dui/repository.py
resolve_dui ¶
Look up a DUI package by name and return its spec.
This is the function called internally when DuiCard("name")
or DuiKey("name") receive a string argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Package name without the |
required |
Returns:
| Type | Description |
|---|---|
PackageSpec
|
A validated, frozen package specification. |
Raises:
| Type | Description |
|---|---|
PackageError
|
If no package with that name exists in any registered path. |