I'm writing a program where I've to select 15 values out of 6 radio buttons each, and each value that should be returned is a floating point value. On using Tkinter Radiobutton:
r155 = Radiobutton(master,text=" ",variable=j, value=1.10)
It returns the value after ignoring the values after decimal point, here j.get() returns 1.
Similarly, for:
r144 = Radiobutton(master,text=" ",variable=i, value=0.91)
i.get() return 0. Is it possible to get floating point numbers?
Yes, your variables can take floating point values. However, for that, you need to define i
and j
to be DoubleVar
s rather than IntVar
s
Even though it is not shown, I believe that somewhere earlier than your radio button definitions you have the lines:
i = IntVar()
j = IntVar()
These must be changed to:
i = DoubleVar()
j = DoubleVar()
respectively.
Also, note that if your radio buttons belong to the same group, they should use the same variable (i.e., the argument variable=i
should be used for both buttons):