X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/611190df3bf40deb1b2728ca0ed3d052c3f3bb08..56a52e909411904736e41258c39f306d218d84d5:/wxPython/src/_core_ex.py diff --git a/wxPython/src/_core_ex.py b/wxPython/src/_core_ex.py index 5d1dcd409d..702e04f6ee 100644 --- a/wxPython/src/_core_ex.py +++ b/wxPython/src/_core_ex.py @@ -32,6 +32,16 @@ if RELEASE_VERSION != _core_.RELEASE_VERSION: #---------------------------------------------------------------------------- +# Set the default string conversion encoding from the locale +import locale +default = locale.getdefaultlocale()[1] +if default: + wx.SetDefaultPyEncoding(default) +del default +del locale + +#---------------------------------------------------------------------------- + class PyDeadObjectError(AttributeError): pass @@ -90,7 +100,6 @@ class _wxPyUnbornObject(object): #---------------------------------------------------------------------------- -_wxPyCallAfterId = None def CallAfter(callable, *args, **kw): """ @@ -104,25 +113,23 @@ def CallAfter(callable, *args, **kw): app = wx.GetApp() 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.