本文介绍了wxpython 3.0 会破坏旧的应用程序吗?(语言环境错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序可以与 wxpython 的旧版本一起正常运行

I had an app that was working properly with old verions of wxpython

现在使用 wxpython 3.0,尝试运行应用程序时,出现以下错误

Now with wxpython 3.0, when trying to run the app, I get the following error

  File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_controls.py", line 6523, in __init__
    _controls_.DatePickerCtrl_swiginit(self,_controls_.new_DatePickerCtrl(*args, **kwargs))
wx._core.PyAssertionError: C++ assertion "strcmp(setlocale(LC_ALL, NULL), "C") == 0" failed at ..\..\src\common\intl.cpp(1449) in wxLocale::GetInfo(): You probably called setlocale() directly instead of using wxLocale and now there is a mismatch between C/C++ and Windows locale.
Things are going to break, please only change locale by creating wxLocale objects to avoid this!

错误来自这一行

File "C:\Users\hadi\Dropbox\Projects\Python\dialysis\profile.py", line 159, in __init__
    style=wx.DP_DROPDOWN)

非常感谢帮助

推荐答案

我知道这个问题已经有一段时间了,但我遇到了同样的问题,我想我会添加我的解决方案,以防其他人发现这个问题线.基本上发生的事情是脚本的语言环境与机器的语言环境在某种程度上发生冲突,尽管我不确定如何或为什么.也许其他对此有更具体知识的人可以填写.尝试使用 wxPython 对象 wx.Locale 手动设置区域设置:

I know it's been a while since this question was asked, but I just had the same issue and thought I'd add my solution in case someone else finds this thread. Basically what's happening is that the locale of your script is somehow conflicting with the locale of the machine, although I'm not sure how or why. Maybe someone else with more specific knowledge on this can fill that in. Try manually setting the locale using the wxPython object wx.Locale:

locale = wx.Locale(wx.LANGUAGE_ENGLISH)

但是,请确保将输出分配给非局部变量.一旦变量超出范围,Locale 对象就会被销毁.所以如果它在一个类中:

However, make sure that you assign the output to a non-local variable. As soon as the variable goes out of scope, the Locale object is destructed. So if it's in a class:

class MyApp(wx.App):...def OnInit(self):self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)...

这篇关于wxpython 3.0 会破坏旧的应用程序吗?(语言环境错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 19:20