bluenevus commited on
Commit
83c24f4
·
verified ·
1 Parent(s): 2e88003

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -52,9 +52,9 @@ app.layout = dbc.Container([
52
  dbc.Button("Split PDF", id='split-button', color="primary", className="mt-3", disabled=True),
53
  dbc.Progress(id='progress-bar', className="my-3"),
54
  html.Div([
55
- dbc.Spinner(id="processing-spinner", color="primary", type="border"),
56
  html.Div(id='processing-status')
57
- ], id='processing-container'),
58
  dbc.Button("Download ZIP", id='download-button', color="success", className="mt-3", disabled=True),
59
  dcc.Download(id="download-zip"),
60
  html.Div(id='log-output', style={'whiteSpace': 'pre-line'}),
@@ -106,6 +106,7 @@ def manage_ranges(add_clicks, remove_clicks, existing_ranges):
106
  Output('processing-status', 'children'),
107
  Output('split-button', 'disabled', allow_duplicate=True),
108
  Output('download-button', 'disabled'),
 
109
  Input('split-button', 'n_clicks'),
110
  State('upload-pdf', 'contents'),
111
  State('upload-pdf', 'filename'),
@@ -128,7 +129,7 @@ def split_pdf(n_clicks, contents, filename, ranges):
128
  thread = Thread(target=process_pdf, args=(contents, filename, ranges))
129
  thread.start()
130
 
131
- return "Processing started...", True, True
132
 
133
  def process_pdf(contents, filename, ranges):
134
  global progress, generated_file, is_processing
@@ -173,18 +174,18 @@ def process_pdf(contents, filename, ranges):
173
  Output('progress-bar', 'value'),
174
  Output('processing-status', 'children', allow_duplicate=True),
175
  Output('download-button', 'disabled', allow_duplicate=True),
176
- Output('processing-spinner', 'children'),
177
  Input('interval-component', 'n_intervals'),
178
  prevent_initial_call=True
179
  )
180
  def update_progress(n):
181
  global progress, is_processing, generated_file
182
  if is_processing:
183
- return progress, f"Processing... {progress:.0f}% complete", True, html.Div()
184
  elif progress == 100 and generated_file is not None:
185
- return 100, "PDF splitting completed. Click 'Download ZIP' to get your files.", False, None
186
  elif progress == -1:
187
- return 0, "Error occurred during PDF splitting. Please try again.", True, None
188
  else:
189
  raise PreventUpdate
190
 
 
52
  dbc.Button("Split PDF", id='split-button', color="primary", className="mt-3", disabled=True),
53
  dbc.Progress(id='progress-bar', className="my-3"),
54
  html.Div([
55
+ dbc.Spinner(html.Div(), id="processing-spinner", color="primary", type="border"),
56
  html.Div(id='processing-status')
57
+ ], id='processing-container', style={'display': 'none'}),
58
  dbc.Button("Download ZIP", id='download-button', color="success", className="mt-3", disabled=True),
59
  dcc.Download(id="download-zip"),
60
  html.Div(id='log-output', style={'whiteSpace': 'pre-line'}),
 
106
  Output('processing-status', 'children'),
107
  Output('split-button', 'disabled', allow_duplicate=True),
108
  Output('download-button', 'disabled'),
109
+ Output('processing-container', 'style'),
110
  Input('split-button', 'n_clicks'),
111
  State('upload-pdf', 'contents'),
112
  State('upload-pdf', 'filename'),
 
129
  thread = Thread(target=process_pdf, args=(contents, filename, ranges))
130
  thread.start()
131
 
132
+ return "Processing started...", True, True, {'display': 'block'}
133
 
134
  def process_pdf(contents, filename, ranges):
135
  global progress, generated_file, is_processing
 
174
  Output('progress-bar', 'value'),
175
  Output('processing-status', 'children', allow_duplicate=True),
176
  Output('download-button', 'disabled', allow_duplicate=True),
177
+ Output('processing-container', 'style', allow_duplicate=True),
178
  Input('interval-component', 'n_intervals'),
179
  prevent_initial_call=True
180
  )
181
  def update_progress(n):
182
  global progress, is_processing, generated_file
183
  if is_processing:
184
+ return progress, f"Processing... {progress:.0f}% complete", True, {'display': 'block'}
185
  elif progress == 100 and generated_file is not None:
186
+ return 100, "PDF splitting completed. Click 'Download ZIP' to get your files.", False, {'display': 'none'}
187
  elif progress == -1:
188
+ return 0, "Error occurred during PDF splitting. Please try again.", True, {'display': 'none'}
189
  else:
190
  raise PreventUpdate
191