我有一个适用于wxpython旧版本的应用程序
现在使用wxpython 3.0,在尝试运行应用程序时,我收到以下错误
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手动设置语言环境:
locale = wx.Locale(wx.LANGUAGE_ENGLISH)
但是,请确保将输出分配给非局部变量.一旦变量超出范围,就会破坏Locale对象.所以如果它在一个类中:
class MyApp(wx.App):
...
def OnInit(self):
self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
...