halimbahae commited on
Commit
b219ee9
·
verified ·
1 Parent(s): f2f5850

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -46,9 +46,6 @@ book_files = {
46
  def main():
47
  st.title("Hadith Viewer")
48
 
49
- # Display home content by default
50
- display_home()
51
-
52
  st.sidebar.title("Navigation")
53
  st.sidebar.subheader("Actions")
54
  if st.sidebar.button("Home"):
@@ -65,11 +62,7 @@ def main():
65
  csv_df = pd.read_csv(file_url, header=None) # Assuming no header in CSV files
66
 
67
  if csv_df is not None:
68
- # Display dataframe with search, filters, and pagination
69
- if "_mushakkala_mufassala" in selected_file:
70
- csv_df.columns = ["ID", "Hadith", "Explanation"]
71
- else:
72
- csv_df.columns = ["ID", "Hadith"]
73
  display_table(csv_df)
74
 
75
  def display_home():
@@ -78,10 +71,11 @@ def display_home():
78
  st.write("Welcome to the Hadith Viewer! This is a viewer for the Hadith collections. You can select a book from the dropdown menu on the left to view its contents.")
79
 
80
  def display_table(csv_df):
81
- # Increase font size
82
  font_size = st.slider("Adjust Font Size", min_value=10, max_value=30, value=20)
83
- st.write(f"## Table View (Font Size: {font_size}px)")
84
- st.table(csv_df.style.set_table_styles([dict(selector="th",props=[('font-size', f'{font_size}px')])]))
 
 
85
 
86
  if __name__ == "__main__":
87
  main()
 
46
  def main():
47
  st.title("Hadith Viewer")
48
 
 
 
 
49
  st.sidebar.title("Navigation")
50
  st.sidebar.subheader("Actions")
51
  if st.sidebar.button("Home"):
 
62
  csv_df = pd.read_csv(file_url, header=None) # Assuming no header in CSV files
63
 
64
  if csv_df is not None:
65
+ # Display dataframe with search
 
 
 
 
66
  display_table(csv_df)
67
 
68
  def display_home():
 
71
  st.write("Welcome to the Hadith Viewer! This is a viewer for the Hadith collections. You can select a book from the dropdown menu on the left to view its contents.")
72
 
73
  def display_table(csv_df):
 
74
  font_size = st.slider("Adjust Font Size", min_value=10, max_value=30, value=20)
75
+ st.write("### Table View")
76
+ search_query = st.sidebar.text_input("Search", "")
77
+ filtered_df = csv_df[csv_df.apply(lambda row: row.astype(str).str.contains(search_query, case=False).any(), axis=1)]
78
+ st.dataframe(filtered_df.style.set_properties(**{'font-size': f'{font_size}px'}))
79
 
80
  if __name__ == "__main__":
81
  main()