How do I convert a number in a LineEdit widget to float?
Say I have:
textfield = QtGui.QLineEdit(self)
And the user inputs 12345.2 in it. I want that to be converted to a float and stored in a variable X. How do I do it?
I tried the code below, it doesn't work.
INPUT = textfield.text
INPUT2 = float(INPUT)
text is the name of the method. You should call it to get the text inside the QLineEdit.
INPUT = textfield.text()
INPUT2 = float(INPUT)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With