Merge pull request #1912 from wxWidgets/various-tweaks

Various tweaks
This commit is contained in:
Robin Dunn
2021-01-29 15:51:05 -08:00
committed by GitHub
7 changed files with 35 additions and 21 deletions

View File

@@ -11,8 +11,12 @@
**Description of the problem**:
<!-- if possible please include a small runnable application that demonstrates the problem -->
<!-- if possible please include a small runnable application in the details section below that demonstrates the problem -->
<details>
<summary>Code Example (click to expand)</summary>
```python
# Put code sample here
```
</details>

View File

@@ -28,6 +28,13 @@ New and improved in this release:
Python environment used for the build. A dependency has been added to
requirements/devel.txt to help ensure that the correct version is installed.
* Change wx.App.InitLocale to just do `locale.setlocale(locale.LC_ALL, "C")`
to undo what Python (3.8+ on Windows) does. This lets wxWidgets start with an
uninitialized locale as it expects. (#1637)
* Fixed issues related to `time_t` being treated as a 32-bit value on Windows.
(#1910)
4.1.1 "An attitude of gratitude"

View File

@@ -219,6 +219,12 @@ class TestPanel(sp.ScrolledPanel):
self.log.write("got wx.PyTimer event\n")
def ShutdownDemo(self):
for t in ['t1', 't2', 't3', 't4']:
if hasattr(self, t):
print('Stopping:', t)
timer = getattr(self, t)
timer.Stop()
#----------------------------------------------------------------------

View File

@@ -521,33 +521,28 @@ def run():
PyFunctionDef('InitLocale', '(self)',
doc="""\
Try to ensure that the C and Python locale is in sync with the wxWidgets
locale on Windows. If you have troubles from the default behavior of this
method you can override it in a derived class to behave differently.
Please report the problem you encountered.
Starting with version 3.8 on Windows, Python is now setting the locale
to what is defined by the system as the default locale. This causes
problems with wxWidgets which expects to be able to manage the locale
via the wx.Locale class, so the locale will be reset here to be the
default "C" locale settings.
If you have troubles from the default behavior of this method you can
override it in a derived class to behave differently. Please report
the problem you encountered.
""",
body="""\
self.ResetLocale()
if 'wxMSW' in PlatformInfo:
if _sys.platform.startswith('win') and _sys.version_info > (3,8):
import locale
try:
lang, enc = locale.getdefaultlocale()
self._initial_locale = wx.Locale(lang, lang[:2], lang)
locale.setlocale(locale.LC_ALL, lang)
except (ValueError, locale.Error) as ex:
target = wx.LogStderr()
orig = wx.Log.SetActiveTarget(target)
wx.LogError("Unable to set default locale: '{}'".format(ex))
wx.Log.SetActiveTarget(orig)
locale.setlocale(locale.LC_ALL, "C")
"""),
PyFunctionDef('ResetLocale', '(self)',
doc="""\
Release the wx.Locale object created in :meth:`InitLocale`.
This should reset the application's locale to the previous settings.
This method is now a NOP and will be deprecated.
""",
body="""\
self._initial_locale = None
pass
"""),
PyFunctionDef('Get', '()', isStatic=True,

View File

@@ -73,7 +73,7 @@ def run():
td = module.find('wxUIntPtr')
module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxUChar'))
module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxChar'))
module.insertItemAfter(td, etgtools.TypedefDef(type='long', name='time_t'))
module.insertItemAfter(td, etgtools.TypedefDef(type='wxInt64', name='time_t'))
module.insertItemAfter(td, etgtools.TypedefDef(type='long long', name='wxFileOffset'))
module.insertItemAfter(td, etgtools.TypedefDef(type='SIP_SSIZE_T', name='ssize_t'))
module.insertItemAfter(td, etgtools.TypedefDef(type='unsigned char', name='byte', pyInt=True))

View File

@@ -61,6 +61,8 @@ def run():
import os
_localedir = os.path.join(os.path.dirname(__file__), "locale")
if os.path.exists(_localedir):
if isinstance(_localedir, (bytes, bytearray)):
_localedir = _localedir.decode(_sys.getfilesystemencoding())
Locale.AddCatalogLookupPathPrefix(_localedir)
del os
#----------------------------------------------------------------------------

View File

@@ -3761,7 +3761,7 @@ def GetNotebookRoot(panes, notebook_id):
def EscapeDelimiters(s):
"""
Changes ``;`` into ``\`` and ``|`` into ``\|`` in the input string.
Changes ``;`` into ``\\`` and ``|`` into ``|\\`` in the input string.
:param string `s`: the string to be analyzed.