import streamlit as st import importlib from uix import lit_packages from uix.pages import lit_home, lit_about, lit_diagnosis from uix.pages import lit_qaConfigCheck #--- alt define sidebar pages m_aryPages = { "Home": lit_home, #--- TODO: update "Diagnosis: One Tile": lit_diagnosis, #"QA: File Check": lit_qaConfigCheck, "About": lit_about } #--- define module-level vars m_aryModNames = lit_packages.packages() m_aryDescr = [] m_aryMods = [] def init(): #--- upper panel with st.sidebar: kstrUrl_image = "bin/images/logo_omdena_saudi.png" st.sidebar.image(kstrUrl_image, width=200) #st.sidebar.markdown('Omdena Saudi - Liver HCC Diagnosis with XAI') #--- init checkboxes strKey = st.sidebar.radio("", list(m_aryPages.keys())) pagSel = m_aryPages[strKey] writePage(pagSel) def init_selectBox(): #--- init module array of page names, and descr init_modDescrAry() # Display the sidebar with a menu of apps kstrMsg = """ __Claims Anomaly Views__ """ with st.sidebar: st.markdown('---') st.markdown(kstrMsg) page = st.selectbox('Select:', m_aryModNames, format_func=fmt_modName) #--- display sidebar footer with st.sidebar: st.markdown('---') st.write('Developed by Chavarria, McKone, Sharma') st.write('Contact at iain.mckone@gmail.com') # Run the chosen app m_aryMods[m_aryModNames.index(page)].run() def init_modDescrAry(): #--- init global array of page names, and descr #--- note: you need to specify global scope for fxns to access module-level variables global m_aryMods global m_aryDescr m_aryMods = [] m_aryDescr = [] for modName in m_aryModNames: modTemp = importlib.import_module('.'+modName,'uix') m_aryMods.append(modTemp) #--- If the module has a description attribute use that in the #--- select box otherwise use the module name try: m_aryDescr.append(modTemp.description) except: m_aryDescr.append(modName) #--- display the app descriptions instead of the module names in the selctbox def fmt_modName(strName): global m_aryModNames global m_aryDescr return m_aryDescr[m_aryModNames.index(strName)] def writePage(uixFile): #--- writes out the page for the selected combo # _reload_module(page) uixFile.run()