S
Susanne
Hello!
In have embedded python into my MFC application.
It works fine using the PyRun_SimpleString method, giving it a string with
some simple commands.
When i am using PyRun_SimpleFile instead, my application crashes.
I have also created a console application. There i also call PyRun_SimpleFile.
The console application executes the given script.
My code looks like the following:
**********************************
MFC-Application:
**********************************
****************************************
Now the code of the console application:
****************************************
**********************
My python script file:
**********************
************************
So, does anyone of you have an idea, what i am doing wrong in my mfc app?
Susanne
In have embedded python into my MFC application.
It works fine using the PyRun_SimpleString method, giving it a string with
some simple commands.
When i am using PyRun_SimpleFile instead, my application crashes.
I have also created a console application. There i also call PyRun_SimpleFile.
The console application executes the given script.
My code looks like the following:
**********************************
MFC-Application:
**********************************
Py_SetProgramName("testclient");
/* Initialize the Python interpreter. Required. */
Py_Initialize();
curMode = DEBUG_MODE;
//**** is running!!!!*****
//CString command = "import CORBA; CORBA.SetTPData();";
//PyRun_SimpleString(command);
//CORBA is my python module, SetTPData a method of this modul
//in SetTPData i open an AfxMessageBox, so thats why i know that
//it works
int result;//path of my file
char * filename2 = "C:\\cvsroot\\OCI-TestClient\\projects\\main\\tao\\test.py";
FILE *fp =fopen(filename2,"r");
if(fp !=NULL)
{
//does not work :-(
result = PyRun_SimpleFile(fp,filename2);
fclose(fp);
}
Py_Finalize();
****************************************
Now the code of the console application:
****************************************
/* Pass argv[0] to the Python interpreter */
Py_SetProgramName(argv[0]);
/* Initialize the Python interpreter. Required. */
Py_Initialize();
//create instance of my class
PythonExtension * pythi = new PythonExtension();
//init my module (not the same module like in MFC app)
pythi->initspam();
char * filename2 = "C:\\cvsroot\\OCI-TestClient\\projects\\main\\tao\\test.py";
FILE *fp =fopen(filename2,"r");
int result;
//works fine, only says, that there is no modul called CORBA
//see below
result = PyRun_SimpleFile(fp,filename2);
printf("Result: %d",result);
**********************
My python script file:
**********************
import CORBA;
CORBA.SetTPData();
//...
************************
So, does anyone of you have an idea, what i am doing wrong in my mfc app?
Susanne