Gui: Introduce Gui::Document::createView to Python.

This commit is contained in:
tritao
2025-01-11 22:32:35 +00:00
committed by Chris Hennes
parent a524186ab4
commit 4c5aaeaf33
3 changed files with 34 additions and 1 deletions

View File

@@ -2456,7 +2456,7 @@ MDIView *Document::setActiveView(const ViewProviderDocumentObject* vp, Base::Typ
/**
* @brief Document::setActiveWindow
* If this document is active and the view is part of it then it will be
* activated. If the document is not active of the view is already active
* activated. If the document is not active or if the view is already active
* nothing is done.
* @param view
*/

View File

@@ -119,6 +119,16 @@ The active object of the document. Deprecated, use ActiveObject.</UserDocu>
The active view of the document. Deprecated, use ActiveView.</UserDocu>
</Documentation>
</Methode>
<Methode Name="createView">
<Documentation>
<UserDocu>createView(type) -> object or None
Return a newly created view of a given type.
type : str
Type name.</UserDocu>
</Documentation>
</Methode>
<Methode Name="mdiViewsOfType" Const="true">
<Documentation>
<UserDocu>mdiViewsOfType(type) -> list of MDIView

View File

@@ -254,6 +254,29 @@ PyObject* DocumentPy::activeView(PyObject *args)
PY_CATCH;
}
PyObject* DocumentPy::createView(PyObject *args)
{
char* sType;
if (!PyArg_ParseTuple(args, "s", &sType))
return nullptr;
Base::Type type = Base::Type::fromName(sType);
if (type.isBad()) {
PyErr_Format(PyExc_TypeError, "'%s' is not a valid type", sType);
return nullptr;
}
PY_TRY {
Gui::MDIView* pcView = getDocumentPtr()->createView(type);
if (pcView) {
return pcView->getPyObject();
} else {
Py_Return;
}
}
PY_CATCH;
}
PyObject* DocumentPy::mdiViewsOfType(PyObject *args)
{
char* sType;