Exposed doCommand (Gui version) to python - fixes #1564

This commit is contained in:
Yorik van Havre 2014-08-05 19:28:36 -03:00
parent 6dd35078a2
commit 81e983b6ac
2 changed files with 13 additions and 0 deletions

View File

@ -234,6 +234,7 @@ public:
PYFUNCDEF_S(sGetDocument);
PYFUNCDEF_S(sDoCommand);
PYFUNCDEF_S(sDoCommandGui);
PYFUNCDEF_S(sAddModule);
static PyMethodDef Methods[];

View File

@ -136,6 +136,9 @@ PyMethodDef Application::Methods[] = {
{"doCommand", (PyCFunction) Application::sDoCommand, 1,
"doCommand(string) -> None\n\n"
"Prints the given string in the python console and runs it"},
{"doCommandGui", (PyCFunction) Application::sDoCommandGui, 1,
"doCommandGui(string) -> None\n\n"
"Prints the given string in the python console and runs it but doesn't record it in macros"},
{"addModule", (PyCFunction) Application::sAddModule, 1,
"addModule(string) -> None\n\n"
"Prints the given module import only once in the macro recording"},
@ -845,6 +848,15 @@ PyObject* Application::sDoCommand(PyObject * /*self*/, PyObject *args,PyObject *
return Py_None;
}
PyObject* Application::sDoCommandGui(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
char *pstr=0;
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
return NULL; // NULL triggers exception
Command::doCommand(Command::Gui,pstr);
return Py_None;
}
PyObject* Application::sAddModule(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
char *pstr=0;