wxpython3.0打破了旧的应用程序?(区域设置错误)

2024-10-01 18:46:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个应用程序,可以正常工作的老版本的wxpython

现在使用wxpython3.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!

错误来自这条线

^{pr2}$

非常感谢帮助


Tags: andtoin版本应用程序错误wxpythonlocale
2条回答

我也遇到过同样的问题。 似乎我们需要在使用wx.应用程序公司名称:

import locale
locale.setlocale(locale.LC_ALL, 'C')

两个链接帮助我解决了这个问题:

我的原始错误消息:

^{pr2}$

我知道已经有一段时间没有问这个问题了,但我也有同样的问题,我想我会添加我的解决方案,以防有人发现这条线索。基本上所发生的是,脚本的区域设置与机器的区域设置存在某种冲突,尽管我不确定如何或为什么。也许其他对此有更具体了解的人可以填补这个空缺。尝试使用wxPython对象手动设置区域设置wx.区域设置公司名称:

locale = wx.Locale(wx.LANGUAGE_ENGLISH)

但是,请确保将输出指定给非局部变量。一旦变量超出范围,Locale对象就会被破坏。所以如果是在课堂上:

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

相关问题 更多 >

    热门问题