Skip to content

uimodules

Class info

Classes

Name Children Inherits
DockSpec
datacook.app.uimodules
DockSpec(id: str, title: object, area: Area, create: Callable[[AppController, MainWindow], QtWidgets.QWidget], tabify_with: str | None \= None, visible: bool \= True)

    🛈 DocStrings

    Registration point for docks, status bar widgets and actions (no shared file to edit).

    UI_MODULES already lists every planned UI module. A module that does not exist yet is skipped, so a work package only creates its module; nothing else needs an edit. A module may define:

    • DOCKS: Sequence[DockSpec]: widgets the main window puts into a dock area, the central area or the status bar (create(app, window) builds the widget);
    • install(app, window) -> None: called after all docks exist (menus, toolbar actions, shortcuts, the op palette).

    DockSpec dataclass

    Source code in src/datacook/app/uimodules.py
    @dataclass(frozen=True, slots=True)
    class DockSpec:
        id: str
        """Object name of the dock (window state, `window.docks[id]`)."""
        title: object
        """`LazyText` (`_("…")`) or str; converted with `str()` on every retranslate."""
        area: Area
        create: Callable[[AppController, MainWindow], QtWidgets.QWidget]
        tabify_with: str | None = None
        """Put this dock as a tab onto the dock with that id (same area)."""
        visible: bool = True
    

    id instance-attribute

    id: str
    

    Object name of the dock (window state, window.docks[id]).

    tabify_with class-attribute instance-attribute

    tabify_with: str | None = None
    

    Put this dock as a tab onto the dock with that id (same area).

    title instance-attribute

    title: object
    

    LazyText (_("…")) or str; converted with str() on every retranslate.

    load_modules

    load_modules(names: tuple[str, ...] = UI_MODULES) -> list[ModuleType]
    

    Import the UI modules that exist (a missing module is skipped, a broken one raises).

    Source code in src/datacook/app/uimodules.py
    def load_modules(names: tuple[str, ...] = UI_MODULES) -> list[ModuleType]:
        """Import the UI modules that exist (a missing module is skipped, a broken one raises)."""
        modules = []
        for name in names:
            try:
                modules.append(importlib.import_module(name))
            except ModuleNotFoundError as e:
                if e.name is None or not (name == e.name or name.startswith(f"{e.name}.")):
                    raise
        return modules