nachdem mein PyInstaller Problem gelöst ist, hier noch eine andere Frage.
Wie kann ich per C API 'Enumerationen' generieren, die ich in Python in der Art Modul.Enum1, Modul.Enum2, ... ansprechen kann?
Bisher sieht mein sehr einfaches C-API-Modul (HW-API-Wrapper) gekürzt wie folgt aus:
Code: Alles auswählen
//------------------------------------------------------------------------------
#include "Python.h"
#include "api.h"
//------------------------------------------------------------------------------
static PyObject* WrapperApiInit(PyObject *self, PyObject *args) {
if(! PyArg_ParseTuple(args, "") ) {
PyErr_SetString(error, "Error: apiInit Arguments");
return NULL;
}
return Py_BuildValue( "h", apiInit() );
}
//------------------------------------------------------------------------------
static PyObject* WrapperApiBreak(PyObject *self, PyObject *args) {
if(! PyArg_ParseTuple(args, "") ) {
PyErr_SetString(error, "Error: apiBreak Arguments");
return NULL;
}
apiBreak();
return Py_BuildValue( "h", 0 );
}
//------------------------------------------------------------------------------
static PyMethodDef apiMethods[] = {
{"apiInit", WrapperApiInit, METH_VARARGS},
{"apiBreak", WrapperApiBreak, METH_VARARGS},
{NULL, NULL} }
//------------------------------------------------------------------------------
void WrapperApi(void) {
Py_InitModule( "WrapperApi", apiMethods );
}
//------------------------------------------------------------------------------
Vielen Dank
Menno