Skip to content

Commit 8faa450

Browse files
committed
Gladevcp calculator_widget: Fix remnant locale handling
Ignore locale in functions 'get_value()' and 'set_value' when using 'use_localization' = False (default)
1 parent 781023e commit 8faa450

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

lib/python/gladevcp/calculatorwidget.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,14 @@ def set_font( self, font ):
147147
def set_value( self, value ):
148148
val = value
149149
try:
150-
val = str( locale.format_string( "%f", float( val ) ).rstrip( "0" ) )
151-
if val[-1] == locale.localeconv()["decimal_point"]:
152-
val = val.rstrip( locale.localeconv()["decimal_point"] )
150+
if self.use_localization:
151+
val = str( locale.format_string( "%f", float( val ) ).rstrip( "0" ) )
152+
if val[-1] == locale.localeconv()["decimal_point"]:
153+
val = val.rstrip( locale.localeconv()["decimal_point"] )
154+
else:
155+
val = str(float( val )).rstrip( "0" )
156+
if val[-1] == ".":
157+
val = val.rstrip(".")
153158
except:
154159
value = "Error"
155160
self.delete()
@@ -160,11 +165,12 @@ def get_value( self ):
160165
self.compute()
161166
try:
162167
value = self.entry.get_text()
163-
return locale.atof( value )
168+
if self.use_localization:
169+
return locale.atof( value )
170+
else:
171+
return float(value)
164172
except:
165173
return None
166-
# print( "value in get value = ", value )
167-
# print( "converted value in get value = ", locale.atof( value ) )
168174

169175
def get_preset_value( self ):
170176
return self.preset_value

0 commit comments

Comments
 (0)