导入 wx 时无法设置默认语言环境

问题描述 投票:0回答:2

收到“无法设置默认区域设置错误:‘不支持的区域设置’” 当导入wx.刚刚重新安装了 Win10 以及 eclipse 和 python,但不明白为什么会出现此错误。 使用 eclipse 4.20、python 3.9.6、wxPython 4.1.1

它给我这个错误的示例代码

import wx

class calc(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, title="Calculator", size=(400,400))
        self.panel = wx.Panel(self)
        global a
        a = wx.Button(self.panel, label="GO", pos=(100,100), size=(50,50))
        a.Bind(wx.EVT_ENTER_WINDOW, self.change, a)

    def change(self,event):
        a.SetBackgroundColour("red")
        self.Refresh()  # for windows
        event.Skip()

if __name__=="__main__":
    app = wx.App(False)
    frame = calc()
    frame.Show()
    app.MainLoop()

感谢您的帮助

python-3.x wxpython
2个回答
1
投票

不是隐私问题!区域设置 - 如国家/语言设置。

class App(wx.App):
  '''Derive your own App class.'''
  
  def InitLocale(self):
    '''Override with nothing (or implement local if actually needed)'''
    pass
  #enddef

#endclass

MyApp = App()
MyApp.MainLoop()

Windows 上的 Python 3.8 打破了这一点

wx.App()

参见wxPhonix迁移指南: https://docs.wxpython.org/MigrationGuide.html#possible-locale-mismatch-on-windows

Kevin 和 Robin 正在研究这个问题 :-) 这是非常深入的问题讨论 https://github.com/wxWidgets/Phoenix/issues/1616

罗宾发布解决方案:https://discuss.wxpython.org/t/apperarence-of-error-popup-each-time-i-run-the-script/35089


0
投票

在 Windows 10 隐私设置中,位置已关闭,这阻止了应用程序访问位置。打开位置,问题就消失了。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.