-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
52 lines (38 loc) · 1.52 KB
/
Copy pathstreamlit_app.py
File metadata and controls
52 lines (38 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
from pathlib import Path
import streamlit as st
import wx
if 'init' not in st.session_state: st.session_state['init'] = False
if not st.session_state.init:
st.session_state.init = True
st.session_state.data_folder = os.getcwd()
def main():
# Render the readme as markdown using st.markdown.
readme_text = st.markdown(Path("instructions.md").read_text())
# Once we have the dependencies, add a selector for the app mode on the sidebar.
st.sidebar.title("What to do")
app_mode = st.sidebar.selectbox("Choose the app mode",
["Run the app", "Show instructions"])
if app_mode == "Show instructions":
st.sidebar.success('To continue select "Run the app".')
elif app_mode == "Run the app":
readme_text.empty()
run_the_app()
def get_data_folder_frame():
app = wx.App()
clicked = st.button('Where data is located', key="FolderSelectionButton")
folder_path = st.session_state.data_folder
if clicked:
dlg_obj = wx.DirDialog(None, "Choose input directory", "",
wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
if dlg_obj.ShowModal() == wx.ID_OK:
folder_path = dlg_obj.GetPath()
st.session_state.data_folder = folder_path
st.experimental_rerun()
return folder_path
def run_the_app():
st.text('Test directory chooser dialog')
st.text('Data folder: ' + st.session_state.data_folder)
get_data_folder_frame()
if __name__ == "__main__":
main()