From f4cc1ff18af73a3c221a7dec7b629981bf3456a9 Mon Sep 17 00:00:00 2001 From: Rongxin Date: Thu, 19 Dec 2024 18:55:15 +0800 Subject: [PATCH] feat (gui): lang choices --- pdf2zh/gui.py | 53 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/pdf2zh/gui.py b/pdf2zh/gui.py index 2f6bacf5..853ee71e 100644 --- a/pdf2zh/gui.py +++ b/pdf2zh/gui.py @@ -372,6 +372,10 @@ def progress_bar(t: tqdm.tqdm): } .env-success { color: #559900 !important; + } + .lang-row { + border: none !important; + } .logo { border: transparent; @@ -666,9 +670,21 @@ def cancel_options(): # First Tab: Local Document with gr.Blocks() as tab_main: + with gr.Row(elem_classes=["lang-row"]): + gui_li = gr.Dropdown( + label="Translate from", + choices=["Auto", "English"], + value=env_lo.value, + interactive=True, + ) + gui_lo = gr.Dropdown( + label="To", + choices=["Chinese", "English"], + value=env_lo.value, + interactive=True, + ) with gr.Row(elem_classes=["preview-row"]): preview = PDF( - label="Translated", visible=False, height=1200, elem_classes=["preview-block"], @@ -789,20 +805,20 @@ def on_file_upload_translate(file, first_page_only): with gr.Blocks(visible=True, elem_classes=["options-modal"]) as tab_option: with gr.Row(): with gr.Column(): - gr.Markdown("### Translation") - with gr.Group(): - gui_li = gr.Dropdown( - label="Source", - choices=["Chinese", "English"], - value=env_lo.value, - interactive=True, - ) - gui_lo = gr.Dropdown( - label="Target", - choices=["Chinese", "English"], - value=env_lo.value, - interactive=True, - ) + # gr.Markdown("### Translation") + # with gr.Group(): + # gui_li = gr.Dropdown( + # label="Source", + # choices=["Chinese", "English"], + # value=env_lo.value, + # interactive=True, + # ) + # gui_lo = gr.Dropdown( + # label="Target", + # choices=["Chinese", "English"], + # value=env_lo.value, + # interactive=True, + # ) gr.Markdown("### Service") gui_service = gr.Dropdown( label="Provider", @@ -895,7 +911,12 @@ def on_file_upload_translate(file, first_page_only): [tab_main, tab_url, tab_option], ["Local Document", "Online Document", "Advanced Options"], ) - gr.Markdown(tech_details_string, elem_classes=["secondary-text"]) + gr.Markdown( + """The file will be translated into Chinese. + More languages supported in [advanced options](https://github.com/Byaidu/PDFMathTranslate/issues).""", + elem_classes=["info-text"], + ) + # gr.Markdown(tech_details_string, elem_classes=["secondary-text"]) # state = gr.State({"session_id": None})