@@ -170,17 +170,15 @@ def get_preset_value( self ):
170170
171171 def compute ( self ):
172172 qualified = ''
173- # print"string:",self.eval_string
174173 temp = self .eval_string .strip ( " " ).replace ("Pi" , "math.pi" )
175174 # this loop adds only spaces around the mentioned operators
176175 for i in ( '-' , '+' , '/' , '*' , 'math.pi' , '(' , ')' ):
177176 new = " %s " % i
178177 temp = temp .replace ( i , new )
179178 for i in temp .split ():
180- # print ( "i in compute = ", i )
181179 try :
180+ # convert to decimal dot format
182181 i = str ( locale .atof ( i ) )
183- # print ( "converted i in compute = ", i )
184182 except :
185183 pass
186184 if i .isdigit ():
@@ -194,16 +192,13 @@ def compute( self ):
194192 b = str ( eval ( qualified ) )
195193 except :
196194 b = "Error"
197- print ("Calculator widget error, string:" , self .eval_string , sys .exc_info ()[0 ])
198195 self .eval_string = ''
199- else : self .eval_string = b
200- # if locale.localeconv()["decimal_point" = comma ,
201- # we have to replace the internal dot by a comma,
202- # otherwise it will be interpreted as an thousend separator
203196 try :
204197 b = locale .format_string ( "%f" , float ( b ) ).rstrip ( "0" )
205198 if b [- 1 ] == locale .localeconv ()["decimal_point" ]:
206199 b = b .rstrip ( locale .localeconv ()["decimal_point" ] )
200+ else :
201+ self .eval_string = b
207202 except :
208203 b = "Error"
209204 self .entry .set_text ( b )
0 commit comments