Gui: extend PySide2 wrapper of MainWindow with extra functions

This commit is contained in:
wmayer
2021-11-19 15:45:56 +01:00
parent 67cc5c9047
commit c8fcb9405e
5 changed files with 220 additions and 10 deletions

View File

@@ -44,6 +44,7 @@
#include "Command.h"
#include "Document.h"
#include "MainWindow.h"
#include "MainWindowPy.h"
#include "Macro.h"
#include "EditorView.h"
#include "PythonEditor.h"
@@ -705,20 +706,13 @@ PyObject* Application::sSendFocusView(PyObject * /*self*/, PyObject *args)
PyObject* Application::sGetMainWindow(PyObject * /*self*/, PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
return nullptr;
PythonWrapper wrap;
if (!wrap.loadCoreModule() ||
!wrap.loadGuiModule() ||
!wrap.loadWidgetsModule()) {
PyErr_SetString(PyExc_RuntimeError, "Failed to load Python wrapper for Qt");
return 0;
}
try {
return Py::new_reference_to(wrap.fromQWidget(Gui::getMainWindow(), "QMainWindow"));
return Py::new_reference_to(MainWindowPy::createWrapper(Gui::getMainWindow()));
}
catch (const Py::Exception&) {
return 0;
return nullptr;
}
}