Expose getMainWindow() to Python

This commit is contained in:
wmayer
2013-06-30 23:34:24 +02:00
parent 8a5d32892f
commit 112b25f9fc
4 changed files with 29 additions and 5 deletions

View File

@@ -83,6 +83,9 @@ PyMethodDef Application::Methods[] = {
{"addIcon", (PyCFunction) Application::sAddIcon, 1,
"addIcon(string, string or list) -> None\n\n"
"Add an icon as file name or in XPM format to the system"},
{"getMainWindow", (PyCFunction) Application::sGetMainWindow, 1,
"getMainWindow() -> QMainWindow\n\n"
"Return the main window instance"},
{"updateGui", (PyCFunction) Application::sUpdateGui, 1,
"updateGui() -> None\n\n"
"Update the main window and all its windows"},
@@ -418,6 +421,22 @@ PyObject* Application::sSendActiveView(PyObject * /*self*/, PyObject *args,PyObj
return Py_None;
}
PyObject* Application::sGetMainWindow(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
PythonWrapper wrap;
wrap.loadCoreModule();
wrap.loadGuiModule();
try {
return Py::new_reference_to(wrap.fromQWidget(Gui::getMainWindow(), "QMainWindow"));
}
catch (const Py::Exception&) {
return 0;
}
}
PyObject* Application::sUpdateGui(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C