This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: using python extension(wxPython) in c
Type: Stage:
Components: Extension Modules Versions: Python 2.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jolleydtan, loewis
Priority: normal Keywords:

Created on 2006-11-23 08:52 by jolleydtan, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg30659 - (view) Author: jolleydtan (jolleydtan) Date: 2006-11-23 08:52
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 awaits it.
regards,
jolley.d.tan






msg30660 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-11-23 18:02
Please don't use the bug tracker as a means to get support; it is not meant to be used that way.
Instead, try to get help e.g. on news:comp.lang.python

I can see various errors in your code; as a starting point, check the result of PyRun_SimpleString.

Closing the report as invalid.
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44267
2006-11-23 08:52:08jolleydtancreate