Using tkinter to get file path in streamlit

What I want to do is use a file dialog to get the path for a file (or folder). I have tried to do this using tkinter (see simple code below). When I run this and click on the button to show the file dialog, no dialog appears. Any idea what I am doing wrong here?

import streamlit as st
from tkinter import filedialog as fd

# Dialogue box for input text file selection
if st.button('Select process flow .txt file'):
    input_path = fd.askopenfilename()
    if input_path is not None:
        file = input_path

    st.write(file)

Your code works for me, but it appears below the browser window. You may need to minimize the browser and other windows in order to see the dialog.

Are you running the app and the browser in the same computer?

You’re right, it does work but the dialog is behind the window without focus so not obvious it is there…I guess I can probably fix that.

Yes, the app and browser are running on the same machine.