【问题标题】:How to embed wxPython in wxWidgets (c++) app如何在 wxWidgets (c++) 应用程序中嵌入 wxPython
【发布时间】:2014-04-27 12:49:35
【问题描述】:

我正在开发带有嵌入式 wxPython-3.0 的 MSVC++ wxWidgets-3.0 应用程序。

虽然我的系统已经安装了 Python 2.7 和 wxPython -3.0,但我已经完成了以下操作:(因为我们需要为 wxWidgets 应用程序、Python 和 wxPython 提供相同的构建配置)

  • 我已经下载并构建了 wxWidgets 作为 64 位的 DLL-Debug ,然后我 以 DLL-Debug 模式(64 位)成功运行示例最小项目。

    我下载了 Python2.7 源码并在 Debug(64 bit) 中构建它,然后我 将调试 dll 和库复制到 python 安装文件夹 (\DLLs & \libs)。

    我下载了wxPython3.0源码并在DLL-Debug模式下构建(64 bit) ,然后我将调试 dll 和库复制到 python 安装文件夹 (\Lib\site-packages\wx-3.0-msw\wx)。

我从 wxPython 嵌入式示例中获取了 embedded.cpp,并将代码从 Embedded.cpp 复制到了我的 wxWidgets 示例最小应用程序的 minimum.cpp。

项目属性设置:

c/c++:

  General    --  Additional include directories

                     C:\Python27\include

                     .\..\..\lib\vc_dll\mswud

                     .\..\..\include

链接器:

   General    --   Additional library directories

                         C:\Python27\libs

                         D:\Nuvsoft27\newpy\wxWidgets-3.0.0\lib\vc_dll


   Input         --   Additional dependncies

                          wxmsw30ud_core.lib
                                     .
                                     .
                                     .
                          Python27_d.lib

系统环境变量。

 PATH   --    D:\Nuvsoft27\newpy\wxWidgets-3.0.0\lib\vc_dll

PYTHONPATH -- C:\Python27;C:\Python27\Lib\site-packages\wx-3.0-msw

问题:

它在 wxPyCoreAPI_IMPORT() 函数中失败,它返回 false。

你能帮我解决这个问题吗,我做错了什么吗?

您可以在此处查看 callstack

wxPyCoreAPI_IMPORT() --> 

(wxPyCoreAPI*)PyCObject_Import("wx._core_", "_wxPyCoreAPI")  -->

PyImport_ImportModule(module_name) --> PyImport_Import(pname) -->

PyObject_CallFunction(import, "OOOOi", module_name, globals, globals, silly_list, 0, NULL);     --> 

call_function_tail(callable, args) --> PyObject_Call(callable, args, NULL) -->

PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) --> 

 builtin___import__(PyObject *self, PyObject *args, PyObject *kwds) -->

PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals,  PyObject *fromlist, int level)  -->

 import_module_level(name, globals, locals, fromlist, level) -->

load_next(parent, level < 0 ? Py_None : parent, &name, buf,  &buflen); --> 

import_submodule(mod, p, buf); 

在上面的函数中,他们正在检查模块,如果 mod == Py_None 他们返回 NULL ,它进入那里并返回 NULL。

【问题讨论】:

  • 不是和你的other question一样吗?
  • 我认为这更具体:在这个问题中,他在问“为什么导入返回 false”?上一个问题是“我该怎么做呢?”
  • @VZ 抱歉重复,我希望我之前的问题不清楚。你能帮帮我吗

标签: python visual-c++ wxpython wxwidgets


【解决方案1】:

您可能还需要在 PYTHONPATH 上有 c:\Python27\Lib\site-packages\wx-3.0-msw。

【讨论】:

  • 感谢重播,但我仍然有这个问题,现在你可以看到我更新的数据和调用堆栈,也可以确切地知道它失败的地方。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-07-13
  • 2010-10-31
  • 1970-01-01
  • 1970-01-01
  • 2015-09-30
  • 2017-09-13
  • 1970-01-01
相关资源
最近更新 更多