Localization after building the program using pyinstaller

I have a dialog with buttons that are created using the self.CreateButtonSizer(wx.OK | wx.CANCEL) method.

import wx

class Dialog(wx.Dialog):

    def __init__(self, parent):
        self.btn_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)

class Frame(wx.Frame):

    def __init__(self):
        btn = wx.Button(self, -1, 'click')
        def on_btn(e):
            with Dialog(self) as dlg:
        btn.Bind(wx.EVT_BUTTON, on_btn)

app = wx.App()

If I launch the application through PyCharm, then the text on the buttons is set in accordance with the localization parameters (Russian).


Then I build the application using pyinstaller:
py -3.7 C:\Python\Python37-32\Scripts\pyinstaller.exe .\wxapp.py

If you open the dialog in the assembled application, then the buttons display English text.


How to solve this problem?
Setting self.locale = wx.Locale(wx.LANGUAGE_RUSSIAN) for wx.App did not help.

what does the pyinstaller team say (this is obviously not out-of-the-box); what about an ordinary button?

Uhm… I can’t reproduce your issue. To me, the stock buttons will always display English labels, unless I set a specific wx.Locale.
I suggest that you try your code with a recent version of wxPython first.

Here is a shorter example:

import wx

class Main(wx.Frame):
    def __init__(self, *a, **k):
        wx.Frame.__init__(self, *a, **k)
        self.locale = wx.Locale(wx.LANGUAGE_RUSSIAN) # try commenting out this
        p = wx.Panel(self)
        wx.Button(p, wx.ID_CANCEL, pos=(10, 10))

app = wx.App()

This works for me on wxPython 4.0.6 (at least).
Besides, if you are in the business of changing locale in your app, you may want to upgrade to a more recent Python version, since Python 3.8 messed up the Windows locale settings a bit. (However, I don’t think this is the issue with your specific example).

Edit: oh, I didn’t notice at first… “I launch the application through PyCharm”… Never, ever launch your application through your editor, unless you know exactly what you are doing. Editors like to mess up your environment without telling you. Maybe PyCharm sets up your locale for you.