Skip to content

TabWidget

oldmangan edited this page Oct 6, 2026 · 1 revision

Tabs with badges, closable and disabled tabs, and keep-alive panels.

from wapyt import DataTable, DataTableConfig, TabConfig, TabWidgetConfig

tabs = self.add_tabwidget("main", TabWidgetConfig(
    tabs=[TabConfig(id="files", title="Files", icon="mdi-folder"),
          TabConfig(id="log", title="Log", badge=3)],
    active="files",
))
files = DataTable(DataTableConfig(...), container=tabs.get_cell("files"))
tabs.attach_html("log", "<pre id='log'></pre>")
tabs.on_change(lambda p: refresh(p["id"]))

Config

TabConfig(id, title, icon, closable, badge, disabled, html). TabWidgetConfig(tabs, active, orientation="top" | "left", fill_height=True, keep_alive=True, extra).

  • Mount widgets with container=tabs.get_cell(tab_id). TabWidget has no add_* helpers.
  • keep_alive=True keeps hidden panels mounted. A hidden panel has no size, so re-measure size-sensitive widgets when their tab becomes active, e.g. call terminal.fit() from on_change.
  • TabConfig(html=...) is raw markup; escape any data in it.

Events

Method Payload
on_change {id, viaClick}
on_close {id}
on_ready —

Methods

add_tab(tab, index=None), remove_tab, set_active, get_active, attach_html, attach, set_badge, disable_tab, enable_tab, get_cell.

Clone this wiki locally