neerajkalyank commited on
Commit
2e62ddb
1 Parent(s): b8d540d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -70,13 +70,21 @@ with gr.Blocks() as app:
70
  pincode = gr.Number(label="Pincode", value=None, elem_id="pincode_field")
71
  register_button = gr.Button("Register Patient")
72
  registration_output = gr.Textbox(label="Registration Output")
73
- copy_button = gr.Button("Copy Patient ID")
74
  hidden_patient_id = gr.Textbox(visible=False) # Hidden field to store the patient ID
75
 
76
  register_button.click(registration_interface, [name, father_name, age, phone, address, pincode], [registration_output, hidden_patient_id])
77
-
78
- # Add JavaScript to copy the patient ID
79
- copy_button.click(None, [], None, _js="(x) => navigator.clipboard.writeText(x)", inputs=[hidden_patient_id])
 
 
 
 
 
 
 
 
 
80
 
81
  # Custom CSS styling
82
  app.css = """
 
70
  pincode = gr.Number(label="Pincode", value=None, elem_id="pincode_field")
71
  register_button = gr.Button("Register Patient")
72
  registration_output = gr.Textbox(label="Registration Output")
 
73
  hidden_patient_id = gr.Textbox(visible=False) # Hidden field to store the patient ID
74
 
75
  register_button.click(registration_interface, [name, father_name, age, phone, address, pincode], [registration_output, hidden_patient_id])
76
+
77
+ # Custom HTML for Copy ID Button
78
+ copy_id_html = """
79
+ <button onclick="copyPatientID()" style="background-color: #3b74f2; color: white; padding: 10px; border-radius: 5px; border: none; cursor: pointer;">Copy Patient ID</button>
80
+ <script>
81
+ function copyPatientID() {
82
+ navigator.clipboard.writeText(document.querySelector('#hidden_patient_id textarea').value);
83
+ alert('Patient ID copied to clipboard');
84
+ }
85
+ </script>
86
+ """
87
+ gr.HTML(copy_id_html)
88
 
89
  # Custom CSS styling
90
  app.css = """