X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/618638415381a084362deb7feeac16cd3b5c009c..42f8298f6f42d5d63bb3caf65682b7d9d9f8b702:/wxPython/src/_core_ex.py diff --git a/wxPython/src/_core_ex.py b/wxPython/src/_core_ex.py index d9d121fa52..656a54a991 100644 --- a/wxPython/src/_core_ex.py +++ b/wxPython/src/_core_ex.py @@ -19,16 +19,32 @@ __wxPyPtrTypeMap['wxStatusBar95'] = 'wxStatusBar' #---------------------------------------------------------------------------- # Load version numbers from __version__... Ensure that major and minor -# versions are the same for both wxPython and wxWindows. +# versions are the same for both wxPython and wxWidgets. from __version__ import * __version__ = VERSION_STRING -assert MAJOR_VERSION == _core_.MAJOR_VERSION, "wxPython/wxWindows version mismatch" -assert MINOR_VERSION == _core_.MINOR_VERSION, "wxPython/wxWindows version mismatch" +assert MAJOR_VERSION == _core_.MAJOR_VERSION, "wxPython/wxWidgets version mismatch" +assert MINOR_VERSION == _core_.MINOR_VERSION, "wxPython/wxWidgets version mismatch" if RELEASE_VERSION != _core_.RELEASE_VERSION: import warnings - warnings.warn("wxPython/wxWindows release number mismatch") + warnings.warn("wxPython/wxWidgets release number mismatch") + +#---------------------------------------------------------------------------- + +# Set the default string<-->unicode conversion encoding from the +# locale. This encoding is used when string or unicode objects need +# to be converted in order to pass them to wxWidgets. Please be aware +# that the default encoding within the same locale may be slightly +# different on different platforms. For example, please see +# http://www.alanwood.net/demos/charsetdiffs.html for differences +# between the common latin/roman encodings. +import locale +default = locale.getdefaultlocale()[1] +if default: + wx.SetDefaultPyEncoding(default) +del default +del locale #---------------------------------------------------------------------------- @@ -90,7 +106,6 @@ class _wxPyUnbornObject(object): #---------------------------------------------------------------------------- -_wxPyCallAfterId = None def CallAfter(callable, *args, **kw): """ @@ -102,27 +117,25 @@ def CallAfter(callable, *args, **kw): :see: `wx.FutureCall` """ app = wx.GetApp() - assert app, 'No wxApp created yet' + assert app is not None, 'No wx.App created yet' - global _wxPyCallAfterId - if _wxPyCallAfterId is None: - _wxPyCallAfterId = wx.NewEventType() - app.Connect(-1, -1, _wxPyCallAfterId, - lambda event: event.callable(*event.args, **event.kw) ) + if not hasattr(app, "_CallAfterId"): + app._CallAfterId = wx.NewEventType() + app.Connect(-1, -1, app._CallAfterId, + lambda event: event.callable(*event.args, **event.kw) ) evt = wx.PyEvent() - evt.SetEventType(_wxPyCallAfterId) + evt.SetEventType(app._CallAfterId) evt.callable = callable evt.args = args evt.kw = kw wx.PostEvent(app, evt) - #---------------------------------------------------------------------------- class FutureCall: """ - A convenience class for wx.Timer, that calls the given callable + A convenience class for `wx.Timer`, that calls the given callable object once after the given amount of milliseconds, passing any positional or keyword args. The return value of the callable is availbale after it has been run with the `GetResult` method.