bootstack.Splash#
- class bootstack.Splash(*, until='ready', skippable=False, min_duration=0.0, fade=True, size=None, surface='card', padding=24, gap=12)#
Bases:
FlexContainerA borderless app intro screen shown while the main window is built.
Constructing a
Splashinside anAppcontext registers it with that app and shows it; the app then defers revealing its own window until the splash dismisses. Author the splash’s contents — a logo, a title, a status line — inside itswithblock exactly as you would the app body:with bs.App(title="My App") as app: with bs.Splash(min_duration=1.0): bs.Picture(logo) bs.Label("My App", font="heading-lg") bs.Label("Loading…", textsignal=status) # ...build the heavy app body — the splash covers this cost... app.run()
Where you write the
Splashdetermines how much of startup it covers: put it first to cover the most. Thewithblock scopes content authoring only — it does not bound the splash’s lifetime, which is governed byuntil,min_duration,skippable, anddismiss().- Parameters:
until (float | Literal['ready', 'manual']) – What automatically closes the splash.
'ready'(default) closes it when the app finishes building. A number of seconds closes it after that delay (app-ready does not auto-close it).'manual'never auto-closes — useskippable, an authored button, ordismiss().skippable (bool) – When
True, a click or the Escape key dismisses the splash.min_duration (float) – A floor in seconds — the splash never closes before this has elapsed, even if its trigger fires sooner (prevents a blink on a fast startup).
fade (bool) – Fade the window in and out where the platform supports window alpha; snap instantly where it does not.
size (tuple[int, int] | None) – Fixed size as
(width, height). Defaults to auto-fitting the content. Either way the splash is centered on screen.surface (SurfaceToken | str) – Surface token for the panel background.
padding (Padding) – Inner content padding.
gap (int) – Spacing between content items.
- property schedule: Schedule#
Scheduler tied to this widget’s lifetime.
All jobs are automatically cancelled when the widget is destroyed. First access creates the
Scheduleinstance; subsequent accesses return the same instance.Usage:
self.schedule.delay(500, callback) self.schedule.every(1000, tick) job = self.schedule.idle(refresh) job.cancel()
- destroy()#
Destroy the widget and release the resources it holds.
Removes the widget from its parent, destroys its children, and cancels any pending or repeating jobs on its
schedule. After this the widget must not be used again. Destroying a container destroys everything inside it.
- dismiss()#
Dismiss the splash now, fading out and revealing the app.
Respects
min_duration— if the floor has not elapsed, the dismissal is deferred until it has. Safe to call more than once; later calls are ignored once a dismissal is under way.
- emit(event, *, data=None)#
Fire a named event on this widget, as if it produced the event itself.
This is how a composite widget surfaces high-level activity to its listeners, and the generic counterpart to the
on_*()shorthands for firing events that have no dedicated method.- Parameters:
event (str) – The event name, unprefixed — the same name you pass to
on()or anon_<event>()shorthand (e.g.'change','select').data (Any) – The payload delivered to handlers. For a data-carrying event, pass the matching payload dataclass from
bootstack.events— the same object anon_<event>()handler receives. Leave as None for native events (click, hover, focus, …), which carry no payload.
Example
widget.emit("change", data=bs.events.ChangeEvent(value=new_value))
- guide_layout(child, **layout_kw)#
Place
childinto this container’s flow and snapshot its placement.
- on(event, handler=None)#
Bind
handlertoevent, or return a composableStream.With a handler — binds immediately and returns a
Subscription:sub = widget.on("change", handler) sub.cancel()
Without a handler — returns a
Streamfor operator chaining. The Tk binding is created lazily when.listen()is called:sub = widget.on("change").debounce(300).listen(handler) sub.cancel()
- Parameters:
event (str) – Event name (e.g.
"change","click").handler (Callable[[Any], Any] | None) – Optional callback. If omitted, a
Streamis returned.
- Returns:
Subscriptionwhen a handler is provided;Streamotherwise.- Return type:
- on_destroy(handler=None)#
Register a callback fired when the widget is destroyed.
Fires once, as the widget is torn down — the place to release resources the widget owns that aren’t cleaned up automatically (file handles, observers, external subscriptions). The handler receives a curated
Event.- Parameters:
handler (Callable[[Event], Any] | None) – Called as the widget is destroyed. Omit to get a composable
Stream.- Returns:
A cancellable
Subscriptionwhen a handler is given, otherwise aStream.- Return type:
- on_dismiss() Stream#
- on_dismiss(handler: Callable[[SplashDismissEvent], Any]) Subscription
Register a callback fired when the splash begins dismissing.
The handler receives a
SplashDismissEventwhosereasonsays why it closed ('ready','timer','manual', or'skip'). Fires once, as the fade-out starts.- Parameters:
handler (Callable[[SplashDismissEvent], Any] | None) – Called with the dismiss event. Omit to get a composable
Stream.- Returns:
A cancellable
Subscriptionwhen a handler is given, otherwise aStream.- Return type: