com3dian commited on
Commit
312b574
·
verified ·
1 Parent(s): de3ac88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -76,6 +76,9 @@ st.subheader('Upload paper in pdf format')
76
  with open('slides_text.pkl', 'rb') as file:
77
  summ_text = pickle.load(file)
78
 
 
 
 
79
  # Function to render HTML content
80
  def render_html(text):
81
  # Split text by periods
@@ -98,10 +101,12 @@ def turn_page(direction):
98
  st.session_state.page_index += 1
99
  elif direction == "prev" and st.session_state.page_index > 0:
100
  st.session_state.page_index -= 1
 
101
 
 
102
  def update_text():
103
  st.session_state.current_text = st.session_state.text_area_value
104
-
105
 
106
  # Display page turner controls
107
  col1, col2, col3 = st.columns([1, 2, 1])
@@ -113,13 +118,7 @@ with col2:
113
  st.write(f"Page {st.session_state.page_index + 1} of {len(summ_text)}")
114
 
115
  # Display editable text box
116
- text = st.text_area("Edit Text", summ_text[st.session_state.page_index], height=200, on_change=update_text)
117
 
118
  # Display HTML box
119
- st.markdown(render_html(text), unsafe_allow_html=True)
120
-
121
- # Update list with edited text
122
- summ_text[st.session_state.page_index] = st.session_state.current_text
123
-
124
-
125
-
 
76
  with open('slides_text.pkl', 'rb') as file:
77
  summ_text = pickle.load(file)
78
 
79
+ # Example summary text list (replace with your actual list)
80
+ summ_text = ["First page text.", "Second page text.", "Third page text."]
81
+
82
  # Function to render HTML content
83
  def render_html(text):
84
  # Split text by periods
 
101
  st.session_state.page_index += 1
102
  elif direction == "prev" and st.session_state.page_index > 0:
103
  st.session_state.page_index -= 1
104
+ st.session_state.current_text = summ_text[st.session_state.page_index]
105
 
106
+ # Function to update the current text based on text_area changes
107
  def update_text():
108
  st.session_state.current_text = st.session_state.text_area_value
109
+ summ_text[st.session_state.page_index] = st.session_state.current_text
110
 
111
  # Display page turner controls
112
  col1, col2, col3 = st.columns([1, 2, 1])
 
118
  st.write(f"Page {st.session_state.page_index + 1} of {len(summ_text)}")
119
 
120
  # Display editable text box
121
+ text = st.text_area("Edit Text", st.session_state.current_text, height=200, key="text_area_value", on_change=update_text)
122
 
123
  # Display HTML box
124
+ st.markdown(render_html(st.session_state.current_text), unsafe_allow_html=True)