Streamlit selectbox keeps refreshing page

Hello everyone!!
I am developing a small thing, using streamlit and netwrokx to find the shortest path of a given matrix from a single point or from point x to y.
But I have small problem, which is:
I have placed a st.selectbox, which will allow me to select oone of the different path that has been found. What I want to do is that I can select the path X1, for example, and show me on a beta_column the path and the length of it and on another beta_column the plot of the network.
But every time I select something form the selectbox, it keeps refreshing.
Any ideas on how to solve this?

Here is the code (attention, language for describing is in Italian):

## Visualizzazione matrice

with left_column1:

    st.header('Matrice Quadrata Creata:')

    matrice_array

with right_column1: 

    st.header('Visualizzazione del grafo:')

## Define fucntion for creating a list of numbers

def lista_numeri(inizio,fine):

    return np.arange(inizio,fine,1)

    

##### Creaizone Input per calcolo #######################################################

st.sidebar.header('Calcolo percorso:')

st.sidebar.write('Calcolo del percorso piΓΉ corto, Nx nodo di partenza e Ny nodo di arrivo. I nodi della matrice corrispondono agli indici della colonna.')

selezione = st.sidebar.radio("Seleziona tipo di calcolo",('Da Nx a tutti piΓΉ vicini','Da Nx a Ny'))

if selezione == 'Da Nx a tutti piΓΉ vicini':

    nodo_partenza=np.int(st.sidebar.number_input('Scrivere nodo di partenza (Numero intero):'))

    bottone_calcolo = st.sidebar.button('Calcola percorso', key=1)

    if bottone_calcolo:

        grafo_matrice = nx.from_numpy_matrix(matrice_array, create_using=nx.Graph)

        percorso = nx.single_source_dijkstra_path(grafo_matrice, nodo_partenza, weight='weight')

        lunghezza = nx.single_source_dijkstra_path_length(grafo_matrice, nodo_partenza, weight='weight')

        indici_lista = lista_numeri(0,len(percorso))

        selezione_percorso = st.sidebar.selectbox('Seleziona percorso', indici_lista)

        with left_column2:

            st.header('Percorso selezionato:')

            st.write('Qui si visualizza i vari nodi del percorso selezionato') 

            percorso

            st.header('Tempo percorso selezionato:')

            st.write('Qui si visualizza il tempo richiesto del percorso selezionato')

            lunghezza