Problem with number input

Hi. I’m developing an app that takes a number input from a user. But sometimes when user click ‘+’ or ‘-’ button input field resets on default value (see on gif).
Запись активности на экране 2020-06-16 в 23.44.01
I use this code:

    target = self.pred_slot2.number_input(
        'HFT Target', min_value=0.0, max_value=0.5, value=0.3, step=0.01, format=None, key=None)
    if self.pred_slot3.button('Optimize '):
        self.current_model.optimise(target, pred, pred_opt)

where self.pred_slot2 - is st.empty() what saved before.

I understand what the value may changing to default after the button press. But if i clear understand - value don’t changed to default then user uses ‘+’ or ‘-’ button.
Can I avoid this some way? Am I doing something wrong?

2 Likes

Hi @levich, welcome to the Streamlit community!

Can you provide more of a code snippet so that we can try to debug? I see what you are saying in the gif, but without knowing how all of the code is interacting, it’s hard to say what the issue might be.

Best,
Randy

I also have this same issue:

# --- Latitude, Longitude --- 
c1, c2, c3 = st.beta_columns(3)

latitude = c1.number_input('latitude', value=latitude)
longitude = c1.number_input('longitude', value=longitude)

What is interesting for me is that if I use st.number_input it works as expected. I also have other number inputs using the column style layout that work completely normally.

Hi @kurt-rhee

I have the same issue when I’m using a Decimal numbers (e.g. value=0.1).
Whenever I’m using integers (e.g. value = 1), it’s working as expected.

Also, it’s only not working for me when using st.beta_columns

To me, this looks like a bug, but maybe one of the developers can have a deeper look :slight_smile:

Best, Alex

2 Likes

Hey Alex,

Glad to hear it’s not just me. I created an issue here if you want to follow it.

1 Like

This issue has been fixed for 0.69. Thanks for waiting and trying out our horizontal layouts!

1 Like