Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Tkinter Spinbox with float

Tags:

python

tkinter

Is there a way to get a float value (like 1.91, 1.92 and so on) using the tkinter Spinbox Widget in Python 3.x?

Thanks in advance

like image 539
forumfresser Avatar asked Sep 29 '13 13:09

forumfresser


1 Answers

Use the format and the increment options. Format takes a string format value; use something like %.2f for a floating point number truncated to two decimal places.

The increment option specifies the increment value; the default is 1.0.

Now, using get() on a Spinbox returns an instance of str. Typecast it to float to get a floating-point value.

like image 73
vinit_ivar Avatar answered Sep 22 '22 18:09

vinit_ivar