DVH-Analytics icon indicating copy to clipboard operation
DVH-Analytics copied to clipboard

wxLocale on Windows

Open bozhikovstanislav opened this issue 3 years ago • 0 comments

Hi I have some way of solving the Locale issues for windows please review the code.

May Be it is OK for Windows but it works

class MainApp(wx.App): def OnInit(self): locale = wx.Locale(wx.LANGUAGE_ENGLISH) initialize_directories() if is_windows(): from dvha.tools.windows_reg_edit import ( set_ie_emulation_level, set_ie_lockdown_level, )

        set_ie_emulation_level()
        set_ie_lockdown_level()

    self.SetAppName("DVH Analytics")
    self.frame = DVHAMainFrame(None, wx.ID_ANY, "")
    set_frame_icon(self.frame)
    self.SetTopWindow(self.frame)
    self.frame.Show()
    return True

def OnExit(self):
    self.frame.options.save()
    for window in wx.GetTopLevelWindows():
        wx.CallAfter(window.Close)
    return super().OnExit()

# May cause crash, another solution needed?
def InitLocale(self):
    # https://docs.wxpython.org/MigrationGuide.html#possible-locale-mismatch-on-windows
    if is_windows():
        try:
            self.ResetLocale()
        except Exception as e:
            logger.warning(str(e))
            try:
                **self.locale=wx.Locale(wx.LANGUAGE_ENGLISH)**
            except Exception as e:
                logger.warning(str(e))
        return
    super().InitLocale()

bozhikovstanislav avatar Dec 14 '21 08:12 bozhikovstanislav