[PyQt] Decimal separator Problem

Linos info at linos.es
Tue Nov 13 16:10:22 GMT 2007


Hello,
	i have a problem with the decimal separator in float numbers, i detect the problem in a QDoubleSpinBox (the
decimal separator should be "." but it is ",") and i think it is failing in other objects. My locale in
"es_ES", if i use "locale" command in bash i get this:

LANG=es_ES
LC_CTYPE="es_ES"
LC_NUMERIC="es_ES"
LC_TIME="es_ES"
LC_COLLATE="es_ES"
LC_MONETARY="es_ES"
LC_MESSAGES="es_ES"
LC_PAPER="es_ES"
LC_NAME="es_ES"
LC_ADDRESS="es_ES"
LC_TELEPHONE="es_ES"
LC_MEASUREMENT="es_ES"
LC_IDENTIFICATION="es_ES"
LC_ALL=es_ES

i have added this code to the __init__ of a dialog.

print QString("%L1").arg(10.54)

locale = QLocale()
country = locale.country()
language = locale.language()
print locale.countryToString(country)
print locale.languageToString(language)
print QString("10,25").toDouble()[0]

and i get this output:

10,54
Spain
Spanish
10.25

The first localized arg isnt good and the last toDouble it is good printed because python convert it to a
float and python dont have the problem with the locale. The strange about this it is i have the same problem
if i exec in a windows machine, what can be the problem?

Best Regards,
Miguel Angel.


More information about the PyQt mailing list