TechDraw: Improve and clean up code in some Python classes

This commit is contained in:
marioalexis
2022-11-10 13:07:13 -03:00
committed by WandererFan
parent 53f5883ea1
commit 93133040e8
7 changed files with 54 additions and 74 deletions

View File

@@ -63,35 +63,26 @@ int DrawSVGTemplatePy::setCustomAttributes(const char* attr, PyObject* obj)
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 = PyUnicode_FromString(content.c_str());
return PyUnicode_FromString(content.c_str());
}
return result;
Py_Return;
}
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 nullptr;
}
return result;
getDrawSVGTemplatePtr()->EditableTexts.setValue(fieldName, newContent);
Py_Return;
}