33 #include <wx/msgdlg.h> 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() )
68 #if 1 // defined(DEBUG) 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 );
123 PyObject* result =
CallMethod( aMethod, aArglist );
127 if( !PyList_Check( result ) )
130 ret.Add( wxT(
"PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, result is not a list" ),
135 ret = PyArrayStringToWx( result );
174 PyObject* result =
CallMethod(
"GetNumParameterPages",
nullptr );
178 if( !PyLong_Check( result ) )
181 ret = PyLong_AsLong( result );
195 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
196 PyObject* result =
CallMethod(
"GetParameterPageName", arglist );
198 Py_DECREF( arglist );
200 if( result == Py_None )
206 ret = PyStringToWx( result );
207 Py_XDECREF( result );
218 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
221 Py_DECREF( arglist );
223 for(
unsigned i = 0; i < ret.GetCount(); i++ )
226 wxString item = ret[i];
228 if( item.StartsWith( wxT(
"*" ), &rest ) )
243 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
246 Py_DECREF( arglist );
256 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
259 Py_DECREF( arglist );
269 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
272 Py_DECREF( arglist );
281 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
284 Py_DECREF( arglist );
293 PyObject* arglist = Py_BuildValue(
"(i)", aPage );
296 Py_DECREF( arglist );
303 int len = aValues.size();
307 PyObject* py_list = PyList_New( len );
309 for(
int i = 0; i < len; i++ )
311 wxString& str = aValues[i];
312 PyObject* py_str = PyUnicode_FromString( (
const char*) str.mb_str() );
313 PyList_SetItem( py_list, i, py_str );
318 arglist = Py_BuildValue(
"(i,O)", aPage, py_list );
320 Py_DECREF( arglist );
341 PyObject* result =
CallMethod(
"GetFootprint",
nullptr );
349 PyObject* obj = PyObject_GetAttrString( result,
"this" );
351 if( PyErr_Occurred() )
This file contains miscellaneous commonly used macros and functions.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.