Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,7 +75,9 @@ def create_gradio_interface():
|
|
| 75 |
image_input = gr.Image(type="pil", label="Upload QR Code Image")
|
| 76 |
decode_button = gr.Button("Decode QR Code")
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
| 79 |
|
| 80 |
def read_qr_interface(img):
|
| 81 |
if img is None:
|
|
@@ -88,6 +90,27 @@ def create_gradio_interface():
|
|
| 88 |
outputs=decoded_data,
|
| 89 |
)
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
demo.launch(share=True)
|
| 92 |
|
| 93 |
|
|
|
|
| 75 |
image_input = gr.Image(type="pil", label="Upload QR Code Image")
|
| 76 |
decode_button = gr.Button("Decode QR Code")
|
| 77 |
|
| 78 |
+
with gr.Row():
|
| 79 |
+
decoded_data = gr.Textbox(label="Decoded Data", interactive=True)
|
| 80 |
+
copy_button = gr.Button("Copy to Clipboard")
|
| 81 |
|
| 82 |
def read_qr_interface(img):
|
| 83 |
if img is None:
|
|
|
|
| 90 |
outputs=decoded_data,
|
| 91 |
)
|
| 92 |
|
| 93 |
+
# JavaScript for clipboard functionality
|
| 94 |
+
copy_button.click(
|
| 95 |
+
None,
|
| 96 |
+
inputs=[],
|
| 97 |
+
outputs=[],
|
| 98 |
+
_js="""
|
| 99 |
+
() => {
|
| 100 |
+
const decodedText = document.querySelector('textarea[placeholder="Decoded Data"]');
|
| 101 |
+
if (decodedText) {
|
| 102 |
+
navigator.clipboard.writeText(decodedText.value).then(() => {
|
| 103 |
+
alert('Copied to Clipboard!');
|
| 104 |
+
}).catch(err => {
|
| 105 |
+
console.error('Failed to copy: ', err);
|
| 106 |
+
});
|
| 107 |
+
} else {
|
| 108 |
+
alert('No text to copy!');
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
"""
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
demo.launch(share=True)
|
| 115 |
|
| 116 |
|