# components/locations.py :contentReference[oaicite:2]{index=2} :contentReference[oaicite:3]{index=3} :contentReference[oaicite:4]{index=4} import json import os :contentReference[oaicite:5]{index=5} :contentReference[oaicite:6]{index=6} :contentReference[oaicite:7]{index=7} :contentReference[oaicite:8]{index=8} :contentReference[oaicite:9]{index=9} :contentReference[oaicite:10]{index=10} :contentReference[oaicite:11]{index=11} def location_tab(): :contentReference[oaicite:12]{index=12} :contentReference[oaicite:13]{index=13} :contentReference[oaicite:14]{index=14} :contentReference[oaicite:15]{index=15} :contentReference[oaicite:16]{index=16} :contentReference[oaicite:17]{index=17} :contentReference[oaicite:18]{index=18} value="Forest" ) :contentReference[oaicite:19]{index=19} label="Size", :contentReference[oaicite:20]{index=20} value="Medium" ) :contentReference[oaicite:21]{index=21} :contentReference[oaicite:22]{index=22} :contentReference[oaicite:23]{index=23} value="Moderate" ) :contentReference[oaicite:24]{index=24} label="Theme", :contentReference[oaicite:25]{index=25} value="Mystical" ) :contentReference[oaicite:26]{index=26} :contentReference[oaicite:27]{index=27} export_btn = gr.Button("💾 Save Location to Gallery") export_status = gr.Textbox(label="Export Status") def build_and_generate(name, loc_type, size, danger, theme): data = { "name": name, "location_type": loc_type, "size": size, "danger_level": danger, "theme": theme } return generate_location_image(data, art_style="Concept Art") gen_btn.click( build_and_generate, inputs=[name, loc_type, size, danger, theme], outputs=image_out ) export_btn.click( lambda n, lt, sz, dg, th, img: save_to_gallery( "location", {"name": n, "type": lt, "size": sz, "danger_level": dg, "theme": th}, img ) or "✅ Location saved!", inputs=[name, loc_type, size, danger, theme, image_out], outputs=export_status )