page_utils.py 620 B

12345678910111213141516171819202122232425
  1. import streamlit as st
  2. import os
  3. fingermodel_trans = {
  4. '一般抓握': 'flex',
  5. '柱状抓握': 'cylinder',
  6. '球状抓握': 'ball',
  7. '两指对捏': 'double',
  8. '三指对捏': 'treble'
  9. }
  10. def file_selector(folder_path='.'):
  11. try:
  12. os.mkdir(folder_path)
  13. except FileExistsError:
  14. pass
  15. filenames = os.listdir(folder_path)
  16. filenames = filter(lambda x: x.endwith('.pkl'), filenames)
  17. selected_filename = st.selectbox('Select a file', filenames)
  18. if selected_filename is not None:
  19. return os.path.join(folder_path, selected_filename)
  20. else:
  21. return None