Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -934,16 +934,74 @@ with gr.Blocks(title="Axon Pro — Python AI IDE") as demo:
|
|
| 934 |
find_all_btn.click(do_find_all, find_query, find_results)
|
| 935 |
replace_btn.click(do_replace, [editor, find_query, replace_query, find_case],
|
| 936 |
[editor, find_results, structure_view])
|
|
|
|
| 937 |
|
| 938 |
-
|
| 939 |
-
|
| 940 |
-
|
| 941 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 942 |
|
| 943 |
if __name__ == "__main__":
|
| 944 |
import atexit
|
| 945 |
atexit.register(terminal.cleanup)
|
| 946 |
atexit.register(gui_mgr.stop)
|
| 947 |
atexit.register(vdisplay.cleanup)
|
| 948 |
-
|
| 949 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 934 |
find_all_btn.click(do_find_all, find_query, find_results)
|
| 935 |
replace_btn.click(do_replace, [editor, find_query, replace_query, find_case],
|
| 936 |
[editor, find_results, structure_view])
|
| 937 |
+
# ... [Keep your existing FIND tab code] ...
|
| 938 |
|
| 939 |
+
# ═══ MISSING TAB: GUI DISPLAY ═══
|
| 940 |
+
with gr.Tab("🖥 DISPLAY", id="display-tab"):
|
| 941 |
+
display_image = gr.Image(label="Virtual Display Output", interactive=False, type="filepath")
|
| 942 |
+
with gr.Row():
|
| 943 |
+
capture_btn = gr.Button("📸 CAPTURE SCREEN", variant="primary")
|
| 944 |
+
auto_capture = gr.Checkbox(label="Auto-refresh (2s)")
|
| 945 |
+
# Hidden timer for auto-refresh
|
| 946 |
+
auto_timer = gr.Timer(value=2.0, active=False)
|
| 947 |
+
|
| 948 |
+
# ═══════════════════════════════════════
|
| 949 |
+
# BRIDGE FUNCTIONS (These were missing)
|
| 950 |
+
# ═══════════════════════════════════════
|
| 951 |
+
|
| 952 |
+
# Wrappers for Find/Replace
|
| 953 |
+
def do_find(code, query, case):
|
| 954 |
+
return finder.find_in_file(code, query, case)
|
| 955 |
+
|
| 956 |
+
def do_find_all(query):
|
| 957 |
+
return finder.find_in_all_files(fs.files, query)
|
| 958 |
+
|
| 959 |
+
def do_replace(code, find, replace, case):
|
| 960 |
+
new_code, msg = finder.replace_in_file(code, find, replace, case)
|
| 961 |
+
# We need to update the editor, the results box, AND the structure view
|
| 962 |
+
new_structure = analyzer.analyze(new_code)
|
| 963 |
+
return new_code, msg, new_structure
|
| 964 |
+
|
| 965 |
+
# Wrappers for Display
|
| 966 |
+
def capture_display():
|
| 967 |
+
path = vdisplay.capture()
|
| 968 |
+
if not path:
|
| 969 |
+
return None
|
| 970 |
+
return path
|
| 971 |
+
|
| 972 |
+
def toggle_auto(checkbox_state):
|
| 973 |
+
return gr.Timer(active=checkbox_state)
|
| 974 |
+
|
| 975 |
+
def auto_capture_tick():
|
| 976 |
+
return capture_display()
|
| 977 |
+
|
| 978 |
+
# ═══════════════════════════════════════
|
| 979 |
+
# EVENT WIRING
|
| 980 |
+
# ═══════════════════════════════════════
|
| 981 |
+
|
| 982 |
+
# Find & Replace Events
|
| 983 |
+
find_btn.click(fn=do_find, inputs=[editor, find_query, find_case], outputs=find_results)
|
| 984 |
+
find_all_btn.click(fn=do_find_all, inputs=[find_query], outputs=find_results)
|
| 985 |
+
|
| 986 |
+
replace_btn.click(fn=do_replace,
|
| 987 |
+
inputs=[editor, find_query, replace_query, find_case],
|
| 988 |
+
outputs=[editor, find_results, structure_view])
|
| 989 |
+
|
| 990 |
+
# Display Events
|
| 991 |
+
capture_btn.click(fn=capture_display, inputs=None, outputs=display_image)
|
| 992 |
+
auto_capture.change(fn=toggle_auto, inputs=auto_capture, outputs=auto_timer)
|
| 993 |
+
auto_timer.tick(fn=auto_capture_tick, inputs=None, outputs=display_image)
|
| 994 |
+
|
| 995 |
+
# Note: Ensure you have wired up the other buttons from the previous
|
| 996 |
+
# part of the code (Run, Stop, Complete, etc.) or they won't work either!
|
| 997 |
|
| 998 |
if __name__ == "__main__":
|
| 999 |
import atexit
|
| 1000 |
atexit.register(terminal.cleanup)
|
| 1001 |
atexit.register(gui_mgr.stop)
|
| 1002 |
atexit.register(vdisplay.cleanup)
|
| 1003 |
+
|
| 1004 |
+
# Use queue=True for timers and long running tasks
|
| 1005 |
+
demo.queue().launch(server_name="0.0.0.0", server_port=7860,
|
| 1006 |
+
theme=theme, css=css, ssr_mode=False,
|
| 1007 |
+
allowed_paths=["/tmp"])
|