Py convenience functions for Template EditableTexts
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user