Py convenience functions for Template EditableTexts

This commit is contained in:
WandererFan
2016-05-16 13:37:38 -04:00
committed by wmayer
parent 2c73823788
commit 015c538638
3 changed files with 45 additions and 4 deletions

View File

@@ -37,7 +37,40 @@ int DrawSVGTemplatePy::setCustomAttributes(const char* attr, PyObject* obj)
return 1;
}
return 0;
return 0;
}
PyObject* DrawSVGTemplatePy::getEditFieldContent(PyObject* args)
{
PyObject* result = nullptr;
char* fieldName;
if (!PyArg_ParseTuple(args, "s",&fieldName)) {
Base::Console().Error("Error: DrawSVGTemplatePy::getEditFieldNames - Bad Arg\n");
return nullptr;
}
std::string content = getDrawSVGTemplatePtr()->EditableTexts[fieldName];
if (!content.empty()) {
result = PyString_FromString(content.c_str());
}
return result;
}
PyObject* DrawSVGTemplatePy::setEditFieldContent(PyObject* args)
{
PyObject* result = Py_True;
char* fieldName;
char* newContent;
if (!PyArg_ParseTuple(args, "ss", &fieldName,&newContent)) {
Base::Console().Error("Error: DrawSVGTemplatePy::getEditFieldNames - Bad Args\n");
result = Py_False;
} else {
try {
getDrawSVGTemplatePtr()->EditableTexts.setValue(fieldName, newContent);
}
catch (...) {
result = Py_False;
}
}
return result;
}