34#include "../../scripting/python_scripting.h"
42 Py_XINCREF( aWizard );
60 PyObject* pFunc = PyObject_GetAttrString(
m_PyWizard, aMethod );
62 if( pFunc && PyCallable_Check( pFunc ) )
64 PyObject* result = PyObject_CallObject( pFunc, aArglist );
66 if( PyErr_Occurred() )
69 wxMessageBox( PyErrStringWithTraceback(),
70 _(
"Exception on python footprint wizard code" ),
71 wxICON_ERROR | wxOK );
83 wxString msg = wxString::Format(
_(
"Method '%s' not found, or not callable" ), aMethod );
84 wxMessageBox( msg,
_(
"Unknown Method" ), wxICON_ERROR | wxOK );
101 PyObject* result =
CallMethod( aMethod, aArglist );
103 if( result == Py_None )
109 ret = PyStringToWx( result );
110 Py_XDECREF( result );
122 PyObject* result =
CallMethod( aMethod, aArglist );
126 if( !PyList_Check( result ) )
129 ret.Add( wxT(
"PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, result is not a list" ),
134 ret = PyArrayStringToWx( result );
173 PyObject* result =
CallMethod(
"GetNumParameterPages",
nullptr );
177 if( !PyLong_Check( result ) )
180 ret = PyLong_AsLong( result );
194 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
195 PyObject* result =
CallMethod(
"GetParameterPageName", arglist );
197 Py_DECREF( arglist );
199 if( result == Py_None )
205 ret = PyStringToWx( result );
206 Py_XDECREF( result );
217 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
220 Py_DECREF( arglist );
222 for(
unsigned i = 0; i < ret.GetCount(); i++ )
225 wxString item = ret[i];
227 if( item.StartsWith( wxT(
"*" ), &rest ) )
242 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
245 Py_DECREF( arglist );
255 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
258 Py_DECREF( arglist );
268 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
271 Py_DECREF( arglist );
280 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
283 Py_DECREF( arglist );
292 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
295 Py_DECREF( arglist );
302 int len = aValues.size();
306 PyObject* py_list = PyList_New( len );
308 for(
int i = 0; i < len; i++ )
310 wxString& str = aValues[i];
311 PyObject* py_str = PyUnicode_FromString( (
const char*) str.mb_str() );
312 PyList_SetItem( py_list, i, py_str );
317 arglist = Py_BuildValue(
"(i,O)", aPage, py_list );
319 Py_DECREF( arglist );
340 PyObject* result =
CallMethod(
"GetFootprint",
nullptr );
348 PyObject* obj = PyObject_GetAttrString( result,
"this" );
350 if( PyErr_Occurred() )
This file contains miscellaneous commonly used macros and functions.