[Chicago] =?gb2312?q?=BB=D8=B8=B4=A3=BA=20Re:=20=20using=20wxPython=20gui?= =?gb2312?q?=20application=20in=20c=3F?=

=?gb2312?q?=B7=C5=DC=F8=20=CC=B8?= jolley84 at yahoo.com.cn
Tue Nov 14 04:51:16 CET 2006


thanks robert for the reply,and i have understood your revision on my script and i also feel sorry for not making you understand my intention,and here i will say it once more.
  it  is a python script project which uses python/c api to make the python interpreter for the script.and the python script part is something a simple frame , and in the c/c++ part, the work will involve with extending the python script functionality.
  which starts like:
  Py_Initialize();
  PyImport_ImportModule("app");
  and later goes on with the other operation
  and the nightmare comes when  i import the app python script.and it throws the notorious import error:ImportError:no module named "_core_",which actually resides in the location of C:\Python24\Lib\site-packages\wx-2.6-msw-unicode\wx,with other files named _core.py, _core.pyc. it seems that the python doesnot find the search path.and i added to the sys.path, to check whether the path now can be found,i type "import _core_".it response by"no module named _core_",.furthermore after checking this failure, i add the _core_.pyd,_core.py,_core.py directory to the path(advance->environment variable).certainly the sys.path increase the specific directory.but still when wanting to check whether it is feasible,the error remains(no module named "_core_").
  hope that u can get what i explains to u, pls be patient with a non-english country guy.thanks again :)
  regards,
  jolley
  

Robert Ramsdell <rcriii at ramsdells.net> дµÀ£º
  Hello Jolley. I'm not sure what is going on with your code, but try
this for the Python side of things:

import wx

class MyApp(wx.Frame):
def __init__(self, title='MyApp'):
self.app = wx.PySimpleApp()
self.title = title
self.windowCaption = title
wx.Frame.__init__(self,None,wx.ID_ANY, self.windowCaption,
size=(200,100),
style=wx.DEFAULT_FRAME_STYLE|
wx.NO_FULL_REPAINT_ON_RESIZE)

app = MyApp()
app.mainloop()

I posted a more elaborate example to the list last week.

Robert

On Mon, 2006-11-13 at 16:38 +0800, ·ÅÜø ̸ wrote:
> 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 
> 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¸½¼þ
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago

_______________________________________________
Chicago mailing list
Chicago at python.org
http://mail.python.org/mailman/listinfo/chicago


 		
---------------------------------
 ÑÅ»¢Ãâ·ÑÓÊÏä-3.5GÈÝÁ¿£¬20M¸½¼þ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/chicago/attachments/20061114/18691fcf/attachment.html 


More information about the Chicago mailing list