viklofg commited on
Commit
a5bb67d
·
1 Parent(s): b789f36

Move Show changes toggle

Browse files

Move the "Show changes" toggle closer to the output (from sidebar to below output)

Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -78,13 +78,11 @@ with st.sidebar:
78
  on_change=clean_inputs)
79
  n_candidates = overlap2candidates[overlap]
80
 
81
- st.subheader('Output')
82
- show_changes = st.toggle('Show changes')
83
-
84
 
85
  def handle_input(input_, id_):
86
  """Generate and display output"""
87
 
 
88
  with st.container(border=True):
89
  st.caption('Output')
90
 
@@ -95,10 +93,17 @@ def handle_input(input_, id_):
95
  output = post_ocr.process(input_, n_candidates)
96
  st.session_state.outputs[id_] = output
97
 
98
- # Display output
99
- output = st.session_state.outputs[id_]
100
- if output is not None:
101
- st.write(post_ocr.diff(input_, output) if show_changes else output)
 
 
 
 
 
 
 
102
 
103
 
104
  # Manual entry tab
 
78
  on_change=clean_inputs)
79
  n_candidates = overlap2candidates[overlap]
80
 
 
 
 
81
 
82
  def handle_input(input_, id_):
83
  """Generate and display output"""
84
 
85
+ # Put everything output-related in a bordered container
86
  with st.container(border=True):
87
  st.caption('Output')
88
 
 
93
  output = post_ocr.process(input_, n_candidates)
94
  st.session_state.outputs[id_] = output
95
 
96
+ # This container is needed to display the `show changes` toggle
97
+ # after the output text
98
+ container = st.container()
99
+ st.divider()
100
+ show_changes = st.toggle('Show changes', key=f'show_changes_{id_}')
101
+
102
+ with container:
103
+ # Display output
104
+ output = st.session_state.outputs[id_]
105
+ if output is not None:
106
+ st.write(post_ocr.diff(input_, output) if show_changes else output)
107
 
108
 
109
  # Manual entry tab