paulcalzada commited on
Commit
3e36436
·
verified ·
1 Parent(s): f36be73

Update app.py

Browse files

copy button debugging

Files changed (1) hide show
  1. app.py +17 -18
app.py CHANGED
@@ -85,15 +85,23 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)") as demo:
85
  run_btn = gr.Button("Generate Verilog", variant="primary")
86
  with gr.Column(scale=3):
87
  gr.Markdown("**Output**")
88
- with gr.Row():
89
- out_code = gr.Textbox(
90
- label="Generated Verilog (copy-ready)",
91
- lines=28,
92
- interactive=False,
93
- placeholder="// Your Verilog code will appear here"
94
- )
95
- # The copy button is added here
96
- copy_button = gr.Button("📋", scale=0)
 
 
 
 
 
 
 
 
97
 
98
  with gr.Tab("Retrieved Items (names + scores)"):
99
  retrieved_list = gr.Textbox(
@@ -110,15 +118,6 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)") as demo:
110
  outputs=[out_code, retrieved_list, retrieved_raw]
111
  )
112
 
113
- # Use the `on()` method for the copy functionality
114
- copy_button.on(
115
- "click",
116
- None,
117
- _js="(text) => navigator.clipboard.writeText(text)",
118
- inputs=[out_code]
119
- )
120
-
121
-
122
  if __name__ == "__main__":
123
  if 'agent_module' in locals():
124
  demo.launch()
 
85
  run_btn = gr.Button("Generate Verilog", variant="primary")
86
  with gr.Column(scale=3):
87
  gr.Markdown("**Output**")
88
+ out_code = gr.Textbox(
89
+ label="Generated Verilog (click to select and copy)", # Added copy hint here
90
+ lines=28,
91
+ interactive=False,
92
+ placeholder="// Your Verilog code will appear here",
93
+ # This small JavaScript snippet is added directly to the Textbox.
94
+ # When a user clicks, it selects all the text, making it easy to copy.
95
+ elem_js="""
96
+ (el) => {
97
+ el.addEventListener('click', () => {
98
+ if (el.setSelectionRange) {
99
+ el.setSelectionRange(0, el.value.length);
100
+ }
101
+ });
102
+ }
103
+ """
104
+ )
105
 
106
  with gr.Tab("Retrieved Items (names + scores)"):
107
  retrieved_list = gr.Textbox(
 
118
  outputs=[out_code, retrieved_list, retrieved_raw]
119
  )
120
 
 
 
 
 
 
 
 
 
 
121
  if __name__ == "__main__":
122
  if 'agent_module' in locals():
123
  demo.launch()