py3: Gui: files A-P ported to python3

This commit is contained in:
Yorik van Havre
2017-05-05 19:33:03 +02:00
committed by wmayer
parent 226dd17e5f
commit aa3f9288d6
10 changed files with 274 additions and 25 deletions

View File

@@ -616,7 +616,11 @@ PyObject* Application::sGetLocale(PyObject * /*self*/, PyObject *args,PyObject *
return NULL; // NULL triggers exception
std::string locale = Translator::instance()->activeLanguage();
#if PY_MAJOR_VERSION >= 3
return PyUnicode_FromString(locale.c_str());
#else
return PyString_FromString(locale.c_str());
#endif
}
PyObject* Application::sCreateDialog(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
@@ -658,7 +662,11 @@ PyObject* Application::sAddPreferencePage(PyObject * /*self*/, PyObject *args,Py
PyObject* dlg;
// old style classes
#if PY_MAJOR_VERSION >= 3
if (PyArg_ParseTuple(args, "O!s", &PyType_Type, &dlg, &grp)) {
#else
if (PyArg_ParseTuple(args, "O!s", &PyClass_Type, &dlg, &grp)) {
#endif
// add to the preferences dialog
new PrefPagePyProducer(Py::Object(dlg), grp);
@@ -1046,7 +1054,11 @@ PyObject* Application::sListCommands(PyObject * /*self*/, PyObject *args,PyObjec
PyObject* pyList = PyList_New(cmds.size());
int i=0;
for ( std::vector<Command*>::iterator it = cmds.begin(); it != cmds.end(); ++it ) {
#if PY_MAJOR_VERSION >= 3
PyObject* str = PyUnicode_FromString((*it)->getName());
#else
PyObject* str = PyString_FromString((*it)->getName());
#endif
PyList_SetItem(pyList, i++, str);
}
return pyList;