Skip to content

Commit

Permalink
fix: format
Browse files Browse the repository at this point in the history
  • Loading branch information
Byaidu committed Nov 23, 2024
1 parent f623fc5 commit 51a363b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions pdf2zh/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ def progress_bar(t: tqdm.tqdm):
# color: #165DFF !important;
# }
""",
head='''
head=(
"""
<script src="https://www.google.com/recaptcha/api.js?render=explicit" async defer></script>
<script type="text/javascript">
var onVerify = function(token) {
Expand All @@ -237,7 +238,10 @@ def progress_bar(t: tqdm.tqdm):
el.dispatchEvent(new Event('input'));
};
</script>
''' if flag_demo else ""
"""
if flag_demo
else ""
),
) as demo:
gr.Markdown(
"# [PDFMathTranslate @ Github](https://github.com/Byaidu/PDFMathTranslate)"
Expand Down Expand Up @@ -353,8 +357,10 @@ def on_select_service(value, evt: gr.EventData):
output_file_dual = gr.File(
label="Download Translation (Dual)", visible=False
)
recaptcha_response = gr.Textbox(label="reCAPTCHA Response", elem_id='verify', visible=False)
recaptcha_box=gr.HTML(f'<div id="recaptcha-box"></div>')
recaptcha_response = gr.Textbox(
label="reCAPTCHA Response", elem_id="verify", visible=False
)
recaptcha_box = gr.HTML(f'<div id="recaptcha-box"></div>')
translate_btn = gr.Button("Translate", variant="primary")
tech_details_tog = gr.Markdown(
details_wrapper(envs_status),
Expand All @@ -371,7 +377,8 @@ def on_select_service(value, evt: gr.EventData):
upload_file,
inputs=[file_input, service],
outputs=[file_input, preview],
js=f"""
js=(
f"""
(a,b)=>{{
try{{
grecaptcha.render('recaptcha-box',{{
Expand All @@ -381,7 +388,10 @@ def on_select_service(value, evt: gr.EventData):
}}catch(error){{}}
return [a];
}}
""" if flag_demo else ""
"""
if flag_demo
else ""
),
)

translate_btn.click(
Expand All @@ -395,7 +405,7 @@ def on_select_service(value, evt: gr.EventData):
output_file_dual,
output_title,
],
).then(lambda:None,js="()=>{grecaptcha.reset()}" if flag_demo else "")
).then(lambda: None, js="()=>{grecaptcha.reset()}" if flag_demo else "")


def setup_gui(share=False):
Expand Down

0 comments on commit 51a363b

Please sign in to comment.