[Chicago] using python extension(wxpython) in c
=?gb2312?q?=B7=C5=DC=F8=20=CC=B8?=
jolley84 at yahoo.com.cn
Thu Nov 23 09:04:06 CET 2006
hello,all.
i am confronting with a weird problem, almost forcing to die,the feeling is miserable, so pls help me.
here is a python application named "helloWorld",a simple gui application, assisted with wxPython.
from wxPython.wx import *
class myApp(wxApp):
def OnInit(self):
frame = wxFrame(NULL,-1,"hello,world!");
frame.Show(true)
self.SetTopWindow(frame)
return true
app = myApp()
app.MainLoop()
also sorry for my unsmart code, which i should import wx not wxPython.wx.
and i want to use the simplest way to combine with c.so i use:
#include "python.h"
#include "wx/wxPython/wxPython.h"
#include <iostream>
using namespace std;
int main()
{
Py_Initialize();
if(!Py_IsInitialized())
{
cerr << "hello,world!"<< endl;
return -1;
}
PyRun_SimpleString("from wxPython.wx import *");
PyRun_SimpleString("class myApp(wxApp):");
PyRun_SimpleString(" def OnInit(self):");
PyRun_SimpleString(" frame = wxFrame(NULL,-1,"hello,world!")");
PyRun_SimpleString(" frame.Show(true)");
PyRun_SimpleString(" self.SetTopWindow(frame)");
PyRun_SimpleString(" return true");
PyRun_SimpleString("app = myApp()");
PyRun_SimpleString("app.MainLoop()");
Py_Finalize();
return 0;
}
in addition, to make this work, i have configure something like this:
add the wxpython include/library files in vc.
includes:
c:\wxPython-src-2.6.3.3\wxPython\include.
c:\python24\include\wx(it is the product of building wxPython)
also the python include here.
c:\python24\include
libraries:
c:\wxPython-src-2.6.3.3\lib\vc_dll(the build product of wxWidgets)
c:\wxPython-src-2.6.3.3\wxPython\wxPython
c:\python24\libs
to supplement the problem, i install wxPython from source code,and i have gotten three files,all of which will be uploaded here.
and both them can pass the build process,but get "detected memory leaks and dump objects"in the run process.
i figure that it has great memory leaks when loading certain symbols,like wxmsw26ud.lib or such,while other lib are not loaded "no symbol loaded!"
but i donot know why, and donot know how to build a wxPython script within c.
here is the error message:
Detected memory leaks!
Dumping objects ->
{6417} normal block at 0x01B72B30, 262144 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
{6339} normal block at 0x01B0A9C8, 480 bytes long.
Data: < @_ > 00 00 01 D0 FB FB FB FB 40 5F AD 01 20 92 AD 01
{6338} normal block at 0x01B0A7D0, 440 bytes long.
.....
{48} normal block at 0x003F2C88, 64 bytes long.
Data: <h h > 68 00 A4 00 08 20 A9 00 68 00 B4 00 B8 11 B8 00
{47} normal block at 0x00A40068, 262144 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
{45} normal block at 0x003F4F10, 12 bytes long.
Data: < > FF FF FF FF 00 00 00 00 C0 07 00 00
Object dump complete.
The thread 'Win32 Thread' (0x9ec) has exited with code 0 (0x0).
The program '[2960] wxPythonGUI.exe: Native' has exited with code 0 (0x0).
thanks one billion times if someone can tell me,coz the progress should be advanced further.and all my other people await it.
regards,
jolley.d.tan
---------------------------------
ÇÀ×¢ÑÅ»¢Ãâ·ÑÓÊÏä-3.5GÈÝÁ¿£¬20M¸½¼þ£¡
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/chicago/attachments/20061123/de693336/attachment.htm
More information about the Chicago
mailing list