Skip to content

gui_port

freecad.datamanager_wb.ports.gui_port

GUI port abstraction for FreeCADGui-dependent behavior.

This module isolates FreeCADGui/PySideUic access behind a small interface so the UI layer can be tested without importing FreeCADGui.

FreeCadGuiAdapter

Runtime implementation of GuiPort using FreeCADGui.

add_subwindow(*, mdi_area, widget)

Add a widget to an MDI area and return the created subwindow.

Source code in freecad/datamanager_wb/ports/gui_port.py
def add_subwindow(self, *, mdi_area: object, widget: object) -> object:  # noqa: ANN401
    """Add a widget to an MDI area and return the created subwindow."""
    has_add = cast(_HasAddSubWindow, mdi_area)
    return has_add.addSubWindow(widget)

get_main_window()

Return the FreeCAD main window via FreeCADGui.

Source code in freecad/datamanager_wb/ports/gui_port.py
def get_main_window(self) -> object:  # noqa: ANN401
    """Return the FreeCAD main window via FreeCADGui."""
    import FreeCADGui as Gui  # pylint: disable=import-error

    return Gui.getMainWindow()

get_mdi_area()

Return the QMdiArea from the FreeCAD main window, if present.

Source code in freecad/datamanager_wb/ports/gui_port.py
def get_mdi_area(self) -> object | None:  # noqa: ANN401
    """Return the QMdiArea from the FreeCAD main window, if present."""
    from PySide import QtWidgets

    main_window = self.get_main_window()
    has_find_child = cast(_HasFindChild, main_window)
    mdi = has_find_child.findChild(QtWidgets.QMdiArea)
    return mdi

load_ui(ui_path)

Load a Qt Designer .ui file via FreeCADGui.

Source code in freecad/datamanager_wb/ports/gui_port.py
def load_ui(self, ui_path: str) -> object:  # noqa: ANN401
    """Load a Qt Designer .ui file via FreeCADGui."""
    import FreeCADGui as Gui  # pylint: disable=import-error

    return Gui.PySideUic.loadUi(ui_path)

GuiPort

Port interface for FreeCADGui-dependent operations.

add_subwindow(*, mdi_area, widget)

Add a widget as a subwindow under the given MDI area.

Source code in freecad/datamanager_wb/ports/gui_port.py
def add_subwindow(self, *, mdi_area: object, widget: object) -> object:  # noqa: ANN401
    """Add a widget as a subwindow under the given MDI area."""

get_main_window()

Return the FreeCAD main window.

Source code in freecad/datamanager_wb/ports/gui_port.py
def get_main_window(self) -> object:  # noqa: ANN401
    """Return the FreeCAD main window."""

get_mdi_area()

Return the QMdiArea of the FreeCAD main window when available.

Source code in freecad/datamanager_wb/ports/gui_port.py
def get_mdi_area(self) -> object | None:  # noqa: ANN401
    """Return the QMdiArea of the FreeCAD main window when available."""

load_ui(ui_path)

Load a Qt Designer .ui file and return the root form.

Source code in freecad/datamanager_wb/ports/gui_port.py
def load_ui(self, ui_path: str) -> object:  # noqa: ANN401
    """Load a Qt Designer .ui file and return the root form."""