annie.pages.visibility

Which tab a browser shows, so key handlers and pollers run only while theirs is visible.

NiceGUI keeps every tab panel alive once built, and a ui.keyboard listens on the whole document. Without this, the Annotator’s keys (Space, the arrows, digits) still acted while the reviewer typed or scrolled on Browse, and the 10 Hz playhead poll kept talking to the browser from a hidden tab.

Elements with an active flag (ui.keyboard, ui.timer) are registered with only_while_shown(); show() (called on every tab switch) turns them on for the visible tab and off for the others.

Functions

shown_tab(→ str | None)

The tab the current browser tab shows (None before the first show()).

show(→ None)

Record that the current browser tab now shows tab; switch members on or off.

only_while_shown(→ T)

Keep element active only while tab is the shown tab of its browser tab.

Module Contents

annie.pages.visibility.shown_tab() → str | None[source]

The tab the current browser tab shows (None before the first show()).

annie.pages.visibility.show(tab: str) → None[source]

Record that the current browser tab now shows tab; switch members on or off.

annie.pages.visibility.only_while_shown[T: _Switchable](element: T, tab: str) → T[source]

Keep element active only while tab is the shown tab of its browser tab.

Parameters:
  • element – A ui.keyboard or ui.timer built inside tab.

  • tab – The tab name it belongs to (e.g. "annotator").

Returns:

The element, already switched to match the tab shown now.