[Tutor] Floating point error in tkinter

Alan Gauld alan.gauld at btinternet.com
Fri Mar 9 20:28:03 CET 2012

On 09/03/12 13:09, Válas Péter wrote:

> flood my screen and it won't work. Dou you think this is a Python bug?

It's probably not a Python bug but a Tcl/Tk bug.
It would be worth asking about it on a Tcl/Tk forum - or maybe even the 
Tkinter list.

>    File "c:\python27\lib\lib-tk\Tkinter.py", line 1444, in yview
>      res = self.tk.call(self._w, 'yview', *args)
> TclError: expected floating-point number but got "0,0033"

Note that this error comes from Tcl not Python.

Tcl/Tk often evaluates strings as a float but may well be expecting a 
decimal period rather than a comma in the string. (It really just uses 
the float as an encoding for two integers!)

Can you hard code the period in your code? Or trap the string and do a 
replace() to convert it before it calls the Tkinter code?

On the other hand it could just be that it expects a literal float and 
not a string representation of the same... With no sight of the original 
Python code it's hard to say. But Tk uses string floats often enough 
that I suspect that it is a Tcl/Tk issue.

Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list