diff --git a/src/Gui/MainWindowPy.cpp b/src/Gui/MainWindowPy.cpp index 2b9576437c..f5b1400a56 100644 --- a/src/Gui/MainWindowPy.cpp +++ b/src/Gui/MainWindowPy.cpp @@ -32,6 +32,7 @@ #include "MDIView.h" #include "MDIViewPy.h" #include "PythonWrapper.h" +#include using namespace Gui; @@ -118,12 +119,40 @@ Py::Object MainWindowPy::getWindows(const Py::Tuple& args) if (!PyArg_ParseTuple(args.ptr(), "")) throw Py::Exception(); - return Py::None(); + Py::List mdis; + if (_mw) { + QList windows = _mw->windows(); + for (auto it : windows) { + MDIView* view = qobject_cast(it); + if (view) { + mdis.append(Py::asObject(view->getPyObject())); + } + } + } + + return mdis; } Py::Object MainWindowPy::getWindowsOfType(const Py::Tuple& args) { - return Py::None(); + PyObject* t; + if (!PyArg_ParseTuple(args.ptr(), "O!", &Base::TypePy::Type, &t)) + throw Py::Exception(); + + Base::Type typeId = *static_cast(t)->getBaseTypePtr(); + + Py::List mdis; + if (_mw) { + QList windows = _mw->windows(); + for (auto it : windows) { + MDIView* view = qobject_cast(it); + if (view && view->isDerivedFrom(typeId)) { + mdis.append(Py::asObject(view->getPyObject())); + } + } + } + + return mdis; } Py::Object MainWindowPy::setActiveWindow(const Py::Tuple& args)