Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -59,19 +59,22 @@ def create_gradio_interface():
|
|
59 |
description="Upload an image with a QR code to decode the embedded data.",
|
60 |
)
|
61 |
|
|
|
|
|
|
|
62 |
with gr.Blocks() as demo:
|
63 |
gr.Markdown("## QR Code Tool: Generate and Decode with Ease")
|
64 |
with gr.Tab("Generate QR Code"):
|
65 |
-
generate_interface
|
66 |
with gr.Tab("Read QR Code"):
|
67 |
with gr.Row():
|
68 |
qr_text = gr.Textbox(label="Decoded Data") # Single box for decoded data
|
69 |
copy_button = gr.Button("Copy to Clipboard")
|
70 |
-
read_interface
|
71 |
copy_button.click(
|
72 |
-
fn=
|
73 |
inputs=qr_text,
|
74 |
-
outputs=
|
75 |
)
|
76 |
|
77 |
demo.launch(share=True)
|
|
|
59 |
description="Upload an image with a QR code to decode the embedded data.",
|
60 |
)
|
61 |
|
62 |
+
def copy_to_clipboard(text):
|
63 |
+
return gr.Javascript(f"navigator.clipboard.writeText('{text}');")
|
64 |
+
|
65 |
with gr.Blocks() as demo:
|
66 |
gr.Markdown("## QR Code Tool: Generate and Decode with Ease")
|
67 |
with gr.Tab("Generate QR Code"):
|
68 |
+
generate_interface
|
69 |
with gr.Tab("Read QR Code"):
|
70 |
with gr.Row():
|
71 |
qr_text = gr.Textbox(label="Decoded Data") # Single box for decoded data
|
72 |
copy_button = gr.Button("Copy to Clipboard")
|
73 |
+
read_interface
|
74 |
copy_button.click(
|
75 |
+
fn=copy_to_clipboard,
|
76 |
inputs=qr_text,
|
77 |
+
outputs=None,
|
78 |
)
|
79 |
|
80 |
demo.launch(share=True)
|