call python with python extension in c

放茗 谈 jolley84 at
Fri Nov 24 08:41:22 CET 2006

hello all,  i am a newcomer, and i bring a quesition here: how can i call python app with wxPython/other python extensions in c?
  here is my code here,though not smart,it can explain myself to some extent,in addition,pls forgive me not checking the return value after each calling PyRun_SimpleString,just in the purpose of keeping the code more easier readability:
  #include "python.h" 
#include <iostream> 
using namespace std; 

  int main() 
    cerr << " initialization fails!" << endl; 
    return -1; 

    PyRun_SimpleString("from wxPython.wx import *"); 
  PyRun_SimpleString("class myApp(wxApp):"); 
  PyRun_SimpleString("        def OnInit(self):"); 
  PyRun_SimpleString("              frame 
  PyRun_SimpleString("              frame.Show(true)"); 
  PyRun_SimpleString("              self.SetTopWindow(frame)"); 
  PyRun_SimpleString("              return true"); 
  PyRun_SimpleString("app = myApp()"); 

   return 0; 
from the code above,we can see clearly i intend to build up an simple framework with its title "hello,world".but it doesnot work. mainly due to the python extension wxpython, i think.coz if i doesnot write something connected with python extension,such as will run normally, later my work on wxpython include ,first build the wxpython source code into  some pyds and dlls, at this point, i add the pyds and dlls to the vc directory and c:\WINDOWS\system32\.unfortunately,it doesnot my head aches, the whole progress is messed up. i nearly want to say goodbye to my anyway,help me,ok?
  and i have searched  almost anywhere,nobody i could turn to help,the feedback is little,and i am in despair.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list