* src/Utils.py: provide a locale independant floating point conversion

utility
* src/TextDoc.py: call new gfloat utility instead of float
* src/PaperMenu.py: call new gfloat utility instead of float


svn: r1740
This commit is contained in:
Don Allingham 2003-06-14 17:11:11 +00:00
parent 649a156da5
commit da433a0c5f
3 changed files with 17 additions and 5 deletions

View File

@ -33,6 +33,7 @@ import gtk
import TextDoc import TextDoc
import GrampsCfg import GrampsCfg
import const import const
import Utils
from intl import gettext as _ from intl import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -110,8 +111,8 @@ class PageSizeParser(handler.ContentHandler):
def startElement(self,tag,attrs): def startElement(self,tag,attrs):
if tag == "page": if tag == "page":
name = attrs['name'] name = attrs['name']
height = float(attrs['height']) height = Utils.gfloat(attrs['height'])
width = float(attrs['width']) width = Utils.gfloat(attrs['width'])
self.paper_list.append(TextDoc.PaperStyle(name,height,width)) self.paper_list.append(TextDoc.PaperStyle(name,height,width))
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@ -63,6 +63,7 @@ __version__ = "Revision:$"
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import os import os
import Utils
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -776,9 +777,9 @@ class StyleSheetList:
f.write('underline="%d" ' % font.get_underline()) f.write('underline="%d" ' % font.get_underline())
f.write('color="#%02x%02x%02x"/>\n' % font.get_color()) f.write('color="#%02x%02x%02x"/>\n' % font.get_color())
f.write('<para ') f.write('<para ')
rm = float(p.get_right_margin()) rm = Utils.gfloat(p.get_right_margin())
lm = float(p.get_left_margin()) lm = Utils.gfloat(p.get_left_margin())
fi = float(p.get_first_indent()) fi = Utils.gfloat(p.get_first_indent())
f.write('rmargin="%.3f" ' % rm) f.write('rmargin="%.3f" ' % rm)
f.write('lmargin="%.3f" ' % lm) f.write('lmargin="%.3f" ' % lm)
f.write('first="%.3f" ' % fi) f.write('first="%.3f" ' % fi)

View File

@ -522,6 +522,16 @@ def set_titles(window,title,t,msg=None):
else: else:
window.set_title('%s - GRAMPS' % t) window.set_title('%s - GRAMPS' % t)
def gfloat(val):
try:
return float(val)
except:
try:
return float(val.subst('.',','))
except:
return float(val.subst(',','.'))
return 0.0
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Roman numbers # Roman numbers