[Chicago] using wxPython gui application in c?
=?gb2312?q?=B7=C5=DC=F8=20=CC=B8?=
jolley84 at yahoo.com.cn
Mon Nov 13 09:38:16 CET 2006
hello,all guys,
i am starting to make a python gui app with wxPython, and later i want to using c extension to call it.
there is my python code(app.py):
from wxPython.wx import *
class MyApp(wxApp):
def OnInit(self):
frame = wxFrame(NULL,-1,"Hello from wxPython")
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
and also the c extension code
#include "python.h"
//#include "wxPython.h"
#include <iostream>
using namespace std;
static PyMethodDef g_methodDefinition = {NULL};
#define ERROR(pyObject,msg) {if (pyObject == NULL){printf("%s",msg);PyErr_Print();exit(1);}}
int main()
{
PyObject *pWorkObject,*pModule,*pClass,*pInstance,*pMethod;//,*pWxpythonModule;
Py_Initialize();
if (!Py_IsInitialized())
{
cerr << "can not initialize the python object!" << endl;
return -1;
}
//pWxpythonModule = PyImport_ImportModule("wxPython.wx");
//ERROR(pWxpythonModule,"cannot load wxPython.wx");
//load the module
pModule = PyImport_ImportModule((char*)"app");
ERROR(pModule,"can not load app module!")
.//omit some
when the code comes to import the app module,it crashed.later with PyErr_Print,i get the error message is as follow:
can not load app module!Traceback (most recent call last):
File "c:\Program Files\Microsoft Visual Studio\MyProjects\runPythonGUI\app.py"
, line 1, in ?
from wxPython.wx import *
File "C:\Python24\lib\site-packages\wx-2.6-msw-unicode\wxPython\__init__.py",
line 10, in ?
import _wx
File "C:\Python24\lib\site-packages\wx-2.6-msw-unicode\wxPython\_wx.py", line
3, in ?
from _core import *
File "C:\Python24\lib\site-packages\wx-2.6-msw-unicode\wxPython\_core.py", lin
e 15, in ?
import wx._core
File "C:\Python24\lib\site-packages\wx-2.6-msw-unicode\wx\__init__.py", line 4
2, in ?
from wx._core import *
File "C:\Python24\lib\site-packages\wx-2.6-msw-unicode\wx\_core.py", line 4, i
n ?
import _core_
ImportError: No module named _core_
Press any key to continue
though i have added the directory where the pyd lives in sys.path or the environment,it doesnot come into effect.also, as the _core_.pyd is accompanied with _core.py and _core.pyc.and it means that it can satisfy the basic need that pyd searches the path.and i can make sure that the problem can not come because it is a .pyd.
any suggestions and feedback will be greatly appreciated!
thanks ,really
regards,
jolley
---------------------------------
ÑÅ»¢Ãâ·ÑÓÊÏä-3.5GÈÝÁ¿£¬20M¸½¼þ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/chicago/attachments/20061113/99fa4380/attachment.htm
More information about the Chicago
mailing list