[wxPython] locale problem

Hi wxPythonics,

there _are_ issues with xwPython and locales, which can be
boiled down to:

Python 2.0 (#1, May 16 2001, 00:02:45)
[GCC 2.95.3 20010315 (SuSE)] on linux2
Type "copyright", "credits" or "license" for more information.

import wxPython.wx
import random

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.0/random.py", line 85, in ?
    verify('NV_MAGICCONST', 1.71552776992141)
  File "/usr/lib/python2.0/random.py", line 78, in verify
    raise ValueError, \
ValueError: computed value for NV_MAGICCONST deviates too much (computed
2,82843, expected 1)

print wxPython.wx.__version__

2.3.1

This happens, because my LANG is defined de_DE@euro. Needless to say,
that my start scripts need to export LC_NUMERIC=C at least and some
grid demos crash without these provisions.

Well, there's some interference between python and GTK.
The question is: how can GTK make python fail localewise?

Thanks for listening
Hans-Peter

This happens, because my LANG is defined de_DE@euro. Needless to say,
that my start scripts need to export LC_NUMERIC=C at least and some
grid demos crash without these provisions.

Well, there's some interference between python and GTK.
The question is: how can GTK make python fail localewise?

The following is in the current CVS version of wx.py, you should be able to
add it to your copy as well:

···

#----------------------------------------------------------------------
# wxGTK sets the locale when initialized. Doing this at the Python
# level should set it up to match what GTK is doing at the C level.
try:
    import locale
    locale.setlocale(locale.LC_ALL, "")
except:
    pass

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

Bingo. Fixed! One's again you made the point. Thanks exa times, Robin.

Will perform further locale tests soon.

To the inclined audience:
What's the current favorite gettext utilities?
Could anybody show me some (unix) Makefile templates?

ExathankstoRobinly yours,
Hans-Peter

···

On Thursday, 20. September 2001 19:43, Robin Dunn wrote:

> This happens, because my LANG is defined de_DE@euro. Needless to say,
> that my start scripts need to export LC_NUMERIC=C at least and some
> grid demos crash without these provisions.
>
> Well, there's some interference between python and GTK.
> The question is: how can GTK make python fail localewise?

The following is in the current CVS version of wx.py, you should be able to
add it to your copy as well:

#----------------------------------------------------------------------
# wxGTK sets the locale when initialized. Doing this at the Python
# level should set it up to match what GTK is doing at the C level.
try:
    import locale
    locale.setlocale(locale.LC_ALL, "")
except:
    pass