wxPython, GTK, LC_NUMERIC and Python 2.4

A good long while back, someone posted a localisation problem with wxPython, GTK and a locale with a decimal separator other than '.'. (after initialising wxPython, Python itself stopped being able to parse floats correctly)

The fix for this has been incorporated into Python 2.4 - GTK can be set to use a LC_NUMERIC locale other than 'C', and Python will continue to interpret float literals correctly (i.e. using '.', rather than whatever separator the C library is using). (See http://www.python.org/peps/pep-0331.html for some of the gory details)

The only work around I am aware of for Python 2.3 and earlier is to persuade GTK to leave LC_NUMERIC alone. The downside to that is that the UI will then expect the decimal point for non-monetary values to be '.', regardless of the user's locale settings.

However, I never managed to reproduce this problem myself (never having managed to persuade my computer to switch to a non-'.' locale), and was wondering if there was anyone on here who could check whether this now worked properly with GTK, wxPython and Python 2.4. (Given that the original reporter of this problem seemed to pop up and promptly disappear, I don't know if Robin looked into working around it for earlier Pythons).

Cheers,
Nick.

Nick Coghlan wrote:

However, I never managed to reproduce this problem myself (never having managed to persuade my computer to switch to a non-'.' locale), and was wondering if there was anyone on here who could check whether this now worked properly with GTK, wxPython and Python 2.4. (Given that the original reporter of this problem seemed to pop up and promptly disappear, I don't know if Robin looked into working around it for earlier Pythons).

I added the following after wx and GTK has been initialized:

#ifdef __WXGTK__
         setlocale(LC_NUMERIC, "C");
#endif

I guess I should also test the PYTHON_API_VERSION or something to see if it's being built for Python 2.4.

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!