简体   繁体   English

是否可以在IronPython中使用wxPython?

[英]Is it possible to use wxPython inside IronPython?

When my IronPython program gets to the line 当我的IronPython程序到达该行时

import wx

I get this message: 我收到这条消息:

A first chance exception of type
'IronPython.Runtime.Exceptions.PythonImportErrorException' occurred in IronPython.dll

Additional information: No module named _core_

although I do have the file wx\\_core_.pyd. 虽然我有文件wx \\ _core_.pyd。 Also, before attempting the import, I have the lines: 此外,在尝试导入之前,我有以下几行:

sys.path.append('c:\\Python24\\Lib\\site-packages')
sys.path.append('c:\\Python24\\Lib\\site-packages\\wx-2.6-msw-unicode')
sys.path.append('c:\\Python24\\Lib\\site-packages\\wx-2.6-msw-unicode\\wx')
sys.path.append('c:\\Python24\\Lib\\site-packages\\wx-2.6-msw-unicode\\wx\\lib')
sys.path.append('c:\\Python24\\Lib\\site-packages\\wx-2.6-msw-unicode\\wxpython\\lib')
sys.path.append('c:\\Python24\\Lib\\site-packages\\wxaddons')

which I hoped would let IronPython find everything it needed. 我希望IronPython能够找到所需的一切。

No, this won't work. 不,这不行。 Wx bindings (like most other "python bindings") are actually compiled against CPython. Wx绑定(像大多数其他“python绑定”)实际上是针对CPython编译的。

In this regards they are not just packages on sys.path to be found, as you have tried. 在这方面,他们不仅仅是要找到的sys.path上的包,正如您所尝试的那样。 They actually depend on CPython itself. 他们实际上依赖于CPython本身。 This rather dry document explains the process. 这个相当干燥的文件解释了这个过程

Note: There was a mission by some of the crew at Resolver Systems to allow you to use CPython bindings with IronPython (called IronClad ) but this is in its early stages, and I think they will concentrate on getting things like Numpy working first, GUI toolkits will always be the last, and hardest. 注意:Resolver Systems的一些工作人员执行了一项任务,允许您使用与IronPython(称为IronClad )的CPython绑定,但这还处于早期阶段,我认为他们将专注于让Numpy首先工作,GUI工具包将永远是最后的,也是最难的。

While wxPython is unavailable for the reasons listed by @Ali, you may want to take a look at wx.NET . 虽然由于@Ali列出的原因wxPython不可用,但您可能需要查看wx.NET You could use IronPython to call these assemblies instead, and it should be cross-platform (I'm assuming that's what you're after, or you would just use WinForms). 您可以使用IronPython来调用这些程序集,它应该是跨平台的(我假设您正在使用它,或者您只是使用WinForms)。 If all you're looking for is API compatibility, I think you're out of luck :( 如果您正在寻找的是API兼容性,我认为你运气不好:(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM