Only accept integers, or only floats up to n number of decimals through a number_input widget? (In my use case, I am not using the value parameter, and I may have any combination of the min / max parameter)
remove the onscreen error message “Warning: NumberInput value below has type float, but format %i displays as integer.” (The previous forum suggestions don’t work)
Using floats for the number_input limits allow entering a float. It will be up to the format kwarg to determine how many decimal places are displayed and up to your post-process to truncate it to that certain amount of decimal places.
number = st.number_input("Float", 0.0, 10.0, "min", 1.0, format="%.4f")
number = round(number, 4)
Thanks @edsaac, I knew that min/max would help to cast the number input. However, in my use case, I don’t know which combination of inputs I will receive from the user for this widget. So, my (common) code starts with None for these parameters, and the db field that the result gets outputted to, will need integers / floats (with a specific decimal count).
Yes, the result can be easily cast into integers / floats (in the subsequent code / widget callback).