Skip to content

header_widget

anomaly_match_ui.widgets.header_widget

Reusable header widget with ESA/AM branding, version, log controls, and help.

HeaderWidget(app, out_widget=None, *, show_back_button=False, back_to='main_menu', config_text='')

Reusable application header bar with ESA/AM branding.

Supports two modes controlled by constructor arguments:

  • Main-menu mode (default): version left, dual logos centred, help right.
  • Sub-screen mode (out_widget provided): adds back button, log-level dropdown, and log-toggle button.

Parameters:

Name Type Description Default
app AnomalyMatchApp

The parent application instance (used for navigation).

required
out_widget Output | None

The output widget for terminal logs. None hides log-level / log-toggle controls.

None
show_back_button bool

If True, a back button is shown on the left.

False
back_to str

Screen name to navigate to when back is pressed. Defaults to "main_menu".

'main_menu'
Source code in anomaly_match_ui/widgets/header_widget.py
def __init__(
    self,
    app: AnomalyMatchApp,
    out_widget: widgets.Output | None = None,
    *,
    show_back_button: bool = False,
    back_to: str = "main_menu",
    config_text: str = "",
) -> None:
    self._app = app
    self._back_btn: widgets.Button | None = None
    self._build(app, out_widget, show_back_button, back_to, config_text)

set_back_to(screen_name)

Re-target the back button at screen_name on the next click.

Image-detail navigation needs this — the same screen serves both training and prediction galleries, so the back-button target depends on which gallery navigated here (#427 / #434 follow-up).

Parameters:

Name Type Description Default
screen_name str

Screen name to navigate to on back-click.

required
Source code in anomaly_match_ui/widgets/header_widget.py
def set_back_to(self, screen_name: str) -> None:
    """Re-target the back button at *screen_name* on the next click.

    Image-detail navigation needs this — the same screen serves
    both training and prediction galleries, so the back-button
    target depends on which gallery navigated here (#427 / #434
    follow-up).

    Args:
        screen_name: Screen name to navigate to on back-click.
    """
    self._back_to = screen_name
    if self._back_btn is not None:
        self._back_btn.description = "← Back" if screen_name != "main_menu" else "← Menu"

set_config_text(text)

Update the config info bar below the header.

Parameters:

Name Type Description Default
text str

HTML content for the config bar. Empty string hides it.

required
Source code in anomaly_match_ui/widgets/header_widget.py
def set_config_text(self, text: str) -> None:
    """Update the config info bar below the header.

    Args:
        text: HTML content for the config bar. Empty string hides it.
    """
    if text:
        self._config_html.value = f'<span style="color:#ccc; font-size:11px;">{text}</span>'
        self._config_html.layout.display = ""
    else:
        self._config_html.value = ""
        self._config_html.layout.display = "none"