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 1 |
+
import gradio as gr
|
| 2 |
+
from typing import List, Literal, Optional
|
| 3 |
+
from pydantic import BaseModel, Field
|
| 4 |
+
import json
|
| 5 |
+
|
| 6 |
+
# Your Pydantic models (copied from your code)
|
| 7 |
+
class Reception(BaseModel):
|
| 8 |
+
l_shape_sofa: bool = False
|
| 9 |
+
three_seaters_sofa: bool = False
|
| 10 |
+
two_seaters_sofa: bool = False
|
| 11 |
+
chairs: bool = False
|
| 12 |
+
notes: Optional[str] = None
|
| 13 |
+
|
| 14 |
+
class LivingRoom(BaseModel):
|
| 15 |
+
tv_unit: bool = False
|
| 16 |
+
l_shape_sofa: bool = False
|
| 17 |
+
recliner: bool = False
|
| 18 |
+
notes: Optional[str] = None
|
| 19 |
+
|
| 20 |
+
class Dining(BaseModel):
|
| 21 |
+
table_6_chairs: bool = False
|
| 22 |
+
table_8_chairs: bool = False
|
| 23 |
+
table_10_chairs: bool = False
|
| 24 |
+
buffet: bool = False
|
| 25 |
+
bench: bool = False
|
| 26 |
+
notes: Optional[str] = None
|
| 27 |
+
|
| 28 |
+
class Kitchenette(BaseModel):
|
| 29 |
+
microwave: bool = False
|
| 30 |
+
mini_bar : bool =False
|
| 31 |
+
basin : bool =False
|
| 32 |
+
notes: Optional[str] = None
|
| 33 |
+
|
| 34 |
+
class Kitchen(BaseModel):
|
| 35 |
+
oven: bool = False
|
| 36 |
+
stove: bool = False
|
| 37 |
+
fridge_double: Optional[bool] = False
|
| 38 |
+
fridge_single: Optional[bool] = False
|
| 39 |
+
fridge_dispenser: Optional[bool] = False
|
| 40 |
+
deep_freeze_horizontal: Optional[bool] = False
|
| 41 |
+
deep_freeze_vertical: Optional[bool] = False
|
| 42 |
+
water_dispenser :bool = False
|
| 43 |
+
basin_ุญูุถ_ุญูุชูู: Optional[bool] = False
|
| 44 |
+
basin_ุญูุถ_ุญูุฉ_ูุงุญุฏุฉ_ูุจูุฑุฉ: Optional[bool] = False
|
| 45 |
+
basin_ุญูุถ_ุญูุถ_ุฒุงููุฉ: Optional[bool] = False
|
| 46 |
+
basin_ุญูุถ_ุญูุถ_ุตุบูุฑ_cm55: Optional[bool] = False
|
| 47 |
+
dish_washer_45cm: Optional[bool] = False
|
| 48 |
+
dish_washer_60cm: Optional[bool] = False
|
| 49 |
+
washing_machine_laundry:bool =False
|
| 50 |
+
cooker_ventilation_hood: Optional[bool] = False
|
| 51 |
+
cooker_ventilation_ุดูุงุท_ุณููู: Optional[bool] = False
|
| 52 |
+
cooker_size_60cm: Optional[bool] = False
|
| 53 |
+
cooker_size_90cm: Optional[bool] = False
|
| 54 |
+
oven_size_60cm: Optional[bool] = False
|
| 55 |
+
oven_size_90cm: Optional[bool] = False
|
| 56 |
+
microwave : bool = False
|
| 57 |
+
pantry: bool=False
|
| 58 |
+
bar : bool=False
|
| 59 |
+
island:bool=False
|
| 60 |
+
breakfast_nook:bool =False
|
| 61 |
+
ุฏููุงุจ_ูุธุงูุฉ:bool=False
|
| 62 |
+
notes: Optional[str] = None
|
| 63 |
+
|
| 64 |
+
class MasterBedroom(BaseModel):
|
| 65 |
+
bed_size_1_6: Optional[bool] = False
|
| 66 |
+
bed_size_1_8: Optional[bool] = False
|
| 67 |
+
bed_size_2: Optional[bool] = False
|
| 68 |
+
bed_size_2_2: Optional[bool] = False
|
| 69 |
+
bedside_table_0: Optional[bool] = False
|
| 70 |
+
bedside_table_1: Optional[bool] = False
|
| 71 |
+
bedside_table_2: Optional[bool] = False
|
| 72 |
+
tv_unit: bool = False
|
| 73 |
+
vanity_dresser: bool = False
|
| 74 |
+
with_chair: bool = False
|
| 75 |
+
standing_mirror: bool = False
|
| 76 |
+
inside_room: bool = False
|
| 77 |
+
inside_dressing: bool = False
|
| 78 |
+
inside_dressing_note: Optional[str] = None
|
| 79 |
+
notes: Optional[str] = None
|
| 80 |
+
|
| 81 |
+
class MasterToilet(BaseModel):
|
| 82 |
+
bathtub: bool = False
|
| 83 |
+
bathtub_note: Optional[str] = None
|
| 84 |
+
shower_built_in: bool = False
|
| 85 |
+
shower_note: Optional[str] = None
|
| 86 |
+
standard: bool = False
|
| 87 |
+
jacuzzi: bool = False
|
| 88 |
+
built_in_seat: bool = False
|
| 89 |
+
ุญูุถ_ุณุงูุท_ุฑุฎุงู
ุฉ: bool = False
|
| 90 |
+
ูุญุฏุฉ_ุญูุถ_ู
ุณุชูู: bool = False
|
| 91 |
+
wall_niches: bool = False
|
| 92 |
+
bathroom_storage: bool = False
|
| 93 |
+
notes: Optional[str] = None
|
| 94 |
+
|
| 95 |
+
class Bed(BaseModel):
|
| 96 |
+
type_main: Optional[bool] = False
|
| 97 |
+
type_bunk: Optional[bool] = False
|
| 98 |
+
type_sofa: Optional[bool] = False
|
| 99 |
+
size_1: Optional[bool] = False
|
| 100 |
+
size_1_2: Optional[bool] = False
|
| 101 |
+
size_1_4: Optional[bool] = False
|
| 102 |
+
window_seat:bool =False
|
| 103 |
+
bedside_table_0: Optional[bool] = False
|
| 104 |
+
bedside_table_1: Optional[bool] = False
|
| 105 |
+
bedside_table_2: Optional[bool] = False
|
| 106 |
+
notes: Optional[str] = None
|
| 107 |
+
|
| 108 |
+
class VanityDresser(BaseModel):
|
| 109 |
+
with_chair:bool =False
|
| 110 |
+
standing_mirror:bool=False
|
| 111 |
+
inside_room:bool=False
|
| 112 |
+
inside_dressing:bool=False
|
| 113 |
+
notes: Optional[str] = None
|
| 114 |
+
|
| 115 |
+
class Bedroom1(BaseModel):
|
| 116 |
+
beds: List[Bed] = []
|
| 117 |
+
dressing_walk_in: Optional[bool] = False
|
| 118 |
+
dressing_wardrobe: Optional[bool] = False
|
| 119 |
+
van_dresser:VanityDresser=VanityDresser()
|
| 120 |
+
table:bool=False
|
| 121 |
+
tv_unit:bool=False
|
| 122 |
+
notes: Optional[str] = None
|
| 123 |
+
|
| 124 |
+
class Bedroom2(BaseModel):
|
| 125 |
+
beds: List[Bed]=[]
|
| 126 |
+
dressing_walk_in: Optional[bool] = False
|
| 127 |
+
dressing_wardrobe: Optional[bool] = False
|
| 128 |
+
van_dresser:VanityDresser=VanityDresser()
|
| 129 |
+
table:bool=False
|
| 130 |
+
tv_unit:bool=False
|
| 131 |
+
notes: Optional[str] = None
|
| 132 |
+
|
| 133 |
+
class SharedToilet(BaseModel):
|
| 134 |
+
bathtub: bool = False
|
| 135 |
+
bathtub_note: Optional[str] = None
|
| 136 |
+
shower_built_in: bool = False
|
| 137 |
+
shower_note: Optional[str] = None
|
| 138 |
+
standard: bool = False
|
| 139 |
+
jacuzzi: bool = False
|
| 140 |
+
built_in_seat: bool = False
|
| 141 |
+
ุญูุถ_ุณุงูุท_ุฑุฎุงู
ุฉ: bool = False
|
| 142 |
+
ูุญุฏุฉ_ุญูุถ_ู
ุณุชูู: bool = False
|
| 143 |
+
wall_niches: bool = False
|
| 144 |
+
bathroom_storage: bool = False
|
| 145 |
+
ุบุณุงูุฉ_ุงูุซูุงุจ_ูู
ุฌู:bool=False
|
| 146 |
+
notes: Optional[str] = None
|
| 147 |
+
|
| 148 |
+
class GuestBedroom(BaseModel):
|
| 149 |
+
bed:Bed=Bed()
|
| 150 |
+
wardrobe:bool=False
|
| 151 |
+
bathroom_storage:bool=False
|
| 152 |
+
tv_unit:bool=False
|
| 153 |
+
chair:bool=False
|
| 154 |
+
notes: Optional[str] = None
|
| 155 |
+
|
| 156 |
+
class PrayingRoom(BaseModel):
|
| 157 |
+
mehrab:bool=False
|
| 158 |
+
library:bool=False
|
| 159 |
+
notes: Optional[str] = None
|
| 160 |
+
|
| 161 |
+
class Office(BaseModel):
|
| 162 |
+
library:bool=False
|
| 163 |
+
tv_unit:bool=False
|
| 164 |
+
sofa:bool=False
|
| 165 |
+
sofa_bed:bool=False
|
| 166 |
+
coffee_corner:bool=False
|
| 167 |
+
closet:bool=False
|
| 168 |
+
notes: Optional[str] = None
|
| 169 |
+
|
| 170 |
+
class GeneralRequirementsNotes(BaseModel):
|
| 171 |
+
general_notes: Optional[str] = None
|
| 172 |
+
|
| 173 |
+
class Names(BaseModel):
|
| 174 |
+
mr:str=""
|
| 175 |
+
mrs:str=""
|
| 176 |
+
|
| 177 |
+
class UserFormData(BaseModel):
|
| 178 |
+
reception: Reception = Reception()
|
| 179 |
+
living_room: LivingRoom = LivingRoom()
|
| 180 |
+
dining: Dining = Dining()
|
| 181 |
+
kitchenette: Kitchenette = Kitchenette()
|
| 182 |
+
kitchen: Kitchen = Kitchen()
|
| 183 |
+
master_bedroom: MasterBedroom = MasterBedroom()
|
| 184 |
+
master_toilet: MasterToilet = MasterToilet()
|
| 185 |
+
bedroom1: Bedroom1 = Bedroom1()
|
| 186 |
+
bedroom2: Bedroom2 = Bedroom2()
|
| 187 |
+
shared_toilet: SharedToilet = SharedToilet()
|
| 188 |
+
guest_bedroom: GuestBedroom = GuestBedroom()
|
| 189 |
+
praying_room: PrayingRoom = PrayingRoom()
|
| 190 |
+
office: Office = Office()
|
| 191 |
+
general_requirements_notes: GeneralRequirementsNotes = GeneralRequirementsNotes()
|
| 192 |
+
names: Names = Names()
|
| 193 |
+
|
| 194 |
+
class InteriorDesignState(BaseModel):
|
| 195 |
+
user_form: UserFormData
|
| 196 |
+
design_brief: Optional[str] = None
|
| 197 |
+
design_instructions: Optional[str] = None
|
| 198 |
+
|
| 199 |
+
# Global state to track beds
|
| 200 |
+
bedroom1_beds = []
|
| 201 |
+
bedroom2_beds = []
|
| 202 |
+
|
| 203 |
+
def create_bed_inputs(bed_id, bedroom_type):
|
| 204 |
+
"""Create input components for a single bed"""
|
| 205 |
+
prefix = f"{bedroom_type}_bed_{bed_id}"
|
| 206 |
+
|
| 207 |
+
with gr.Group():
|
| 208 |
+
gr.Markdown(f"### Bed {bed_id}")
|
| 209 |
+
|
| 210 |
+
with gr.Row():
|
| 211 |
+
with gr.Column():
|
| 212 |
+
gr.Markdown("**Bed Type:**")
|
| 213 |
+
type_main = gr.Checkbox(label="Main Bed", elem_id=f"{prefix}_type_main")
|
| 214 |
+
type_bunk = gr.Checkbox(label="Bunk Bed", elem_id=f"{prefix}_type_bunk")
|
| 215 |
+
type_sofa = gr.Checkbox(label="Sofa Bed", elem_id=f"{prefix}_type_sofa")
|
| 216 |
+
|
| 217 |
+
gr.Markdown("**Bed Size:**")
|
| 218 |
+
size_1 = gr.Checkbox(label="Size 1m", elem_id=f"{prefix}_size_1")
|
| 219 |
+
size_1_2 = gr.Checkbox(label="Size 1.2m", elem_id=f"{prefix}_size_1_2")
|
| 220 |
+
size_1_4 = gr.Checkbox(label="Size 1.4m", elem_id=f"{prefix}_size_1_4")
|
| 221 |
+
|
| 222 |
+
with gr.Column():
|
| 223 |
+
gr.Markdown("**Accessories:**")
|
| 224 |
+
window_seat = gr.Checkbox(label="Window Seat", elem_id=f"{prefix}_window_seat")
|
| 225 |
+
|
| 226 |
+
gr.Markdown("**Bedside Tables:**")
|
| 227 |
+
bedside_table_0 = gr.Checkbox(label="0 Tables", elem_id=f"{prefix}_bedside_table_0")
|
| 228 |
+
bedside_table_1 = gr.Checkbox(label="1 Table", elem_id=f"{prefix}_bedside_table_1")
|
| 229 |
+
bedside_table_2 = gr.Checkbox(label="2 Tables", elem_id=f"{prefix}_bedside_table_2")
|
| 230 |
+
|
| 231 |
+
notes = gr.Textbox(label="Bed Notes", lines=2, elem_id=f"{prefix}_notes")
|
| 232 |
+
|
| 233 |
+
return {
|
| 234 |
+
'type_main': type_main,
|
| 235 |
+
'type_bunk': type_bunk,
|
| 236 |
+
'type_sofa': type_sofa,
|
| 237 |
+
'size_1': size_1,
|
| 238 |
+
'size_1_2': size_1_2,
|
| 239 |
+
'size_1_4': size_1_4,
|
| 240 |
+
'window_seat': window_seat,
|
| 241 |
+
'bedside_table_0': bedside_table_0,
|
| 242 |
+
'bedside_table_1': bedside_table_1,
|
| 243 |
+
'bedside_table_2': bedside_table_2,
|
| 244 |
+
'notes': notes
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
def add_bed_bedroom1():
|
| 248 |
+
global bedroom1_beds
|
| 249 |
+
if len(bedroom1_beds) < 5:
|
| 250 |
+
bed_id = len(bedroom1_beds) + 1
|
| 251 |
+
bed_inputs = create_bed_inputs(bed_id, "bedroom1")
|
| 252 |
+
bedroom1_beds.append(bed_inputs)
|
| 253 |
+
return gr.update(visible=True)
|
| 254 |
+
return gr.update()
|
| 255 |
+
|
| 256 |
+
def add_bed_bedroom2():
|
| 257 |
+
global bedroom2_beds
|
| 258 |
+
if len(bedroom2_beds) < 5:
|
| 259 |
+
bed_id = len(bedroom2_beds) + 1
|
| 260 |
+
bed_inputs = create_bed_inputs(bed_id, "bedroom2")
|
| 261 |
+
bedroom2_beds.append(bed_inputs)
|
| 262 |
+
return gr.update(visible=True)
|
| 263 |
+
return gr.update()
|
| 264 |
+
|
| 265 |
+
def process_form_data(*args):
|
| 266 |
+
"""Process all form data and create UserFormData model"""
|
| 267 |
+
try:
|
| 268 |
+
# This is a simplified version - you'll need to map all the arguments
|
| 269 |
+
# to the correct dictionary structure
|
| 270 |
+
|
| 271 |
+
# For now, let's create a basic structure
|
| 272 |
+
collected_data = {
|
| 273 |
+
"names": {
|
| 274 |
+
"mr": args[0] if args[0] else "",
|
| 275 |
+
"mrs": args[1] if args[1] else ""
|
| 276 |
+
},
|
| 277 |
+
"reception": {
|
| 278 |
+
"l_shape_sofa": args[2] if len(args) > 2 else False,
|
| 279 |
+
"three_seaters_sofa": args[3] if len(args) > 3 else False,
|
| 280 |
+
"two_seaters_sofa": args[4] if len(args) > 4 else False,
|
| 281 |
+
"chairs": args[5] if len(args) > 5 else False,
|
| 282 |
+
"notes": args[6] if len(args) > 6 and args[6] else None
|
| 283 |
+
},
|
| 284 |
+
# Add more sections as needed...
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
# Create the model
|
| 288 |
+
form = UserFormData(**collected_data)
|
| 289 |
+
json_output = form.model_dump_json(indent=2, ensure_ascii=False)
|
| 290 |
+
|
| 291 |
+
return f"โ
Form processed successfully!\n\n{json_output}"
|
| 292 |
+
|
| 293 |
+
except Exception as e:
|
| 294 |
+
return f"โ Error processing form: {str(e)}"
|
| 295 |
+
|
| 296 |
+
# Create the main Gradio interface
|
| 297 |
+
with gr.Blocks(title="Interior Design Form", theme=gr.themes.Soft()) as app:
|
| 298 |
+
gr.Markdown("# ๐ Interior Design Requirements Form")
|
| 299 |
+
|
| 300 |
+
# Names Section (at the top)
|
| 301 |
+
with gr.Group():
|
| 302 |
+
gr.Markdown("## ๐ฅ Client Information")
|
| 303 |
+
with gr.Row():
|
| 304 |
+
mr_name = gr.Textbox(label="Mr.", placeholder="Enter husband's name")
|
| 305 |
+
mrs_name = gr.Textbox(label="Mrs.", placeholder="Enter wife's name")
|
| 306 |
+
|
| 307 |
+
# Reception Section
|
| 308 |
+
with gr.Accordion("๐๏ธ Reception", open=False):
|
| 309 |
+
with gr.Row():
|
| 310 |
+
with gr.Column():
|
| 311 |
+
reception_l_shape = gr.Checkbox(label="L-Shape Sofa")
|
| 312 |
+
reception_three_seaters = gr.Checkbox(label="Three Seaters Sofa")
|
| 313 |
+
with gr.Column():
|
| 314 |
+
reception_two_seaters = gr.Checkbox(label="Two Seaters Sofa")
|
| 315 |
+
reception_chairs = gr.Checkbox(label="Chairs")
|
| 316 |
+
reception_notes = gr.Textbox(label="Reception Notes", lines=3)
|
| 317 |
+
|
| 318 |
+
# Living Room Section
|
| 319 |
+
with gr.Accordion("๐บ Living Room", open=False):
|
| 320 |
+
with gr.Row():
|
| 321 |
+
living_tv_unit = gr.Checkbox(label="TV Unit")
|
| 322 |
+
living_l_shape = gr.Checkbox(label="L-Shape Sofa")
|
| 323 |
+
living_recliner = gr.Checkbox(label="Recliner")
|
| 324 |
+
living_notes = gr.Textbox(label="Living Room Notes", lines=3)
|
| 325 |
+
|
| 326 |
+
# Dining Section
|
| 327 |
+
with gr.Accordion("๐ฝ๏ธ Dining", open=False):
|
| 328 |
+
with gr.Row():
|
| 329 |
+
with gr.Column():
|
| 330 |
+
dining_table_6 = gr.Checkbox(label="Table 6 Chairs")
|
| 331 |
+
dining_table_8 = gr.Checkbox(label="Table 8 Chairs")
|
| 332 |
+
with gr.Column():
|
| 333 |
+
dining_table_10 = gr.Checkbox(label="Table 10 Chairs")
|
| 334 |
+
dining_buffet = gr.Checkbox(label="Buffet")
|
| 335 |
+
dining_bench = gr.Checkbox(label="Bench")
|
| 336 |
+
dining_notes = gr.Textbox(label="Dining Notes", lines=3)
|
| 337 |
+
|
| 338 |
+
# Kitchenette Section
|
| 339 |
+
with gr.Accordion("โ Kitchenette", open=False):
|
| 340 |
+
with gr.Row():
|
| 341 |
+
kitchenette_microwave = gr.Checkbox(label="Microwave")
|
| 342 |
+
kitchenette_mini_bar = gr.Checkbox(label="Mini Bar")
|
| 343 |
+
kitchenette_basin = gr.Checkbox(label="Basin")
|
| 344 |
+
kitchenette_notes = gr.Textbox(label="Kitchenette Notes", lines=3)
|
| 345 |
+
|
| 346 |
+
# Kitchen Section (simplified - you can expand this)
|
| 347 |
+
with gr.Accordion("๐ณ Kitchen", open=False):
|
| 348 |
+
with gr.Row():
|
| 349 |
+
with gr.Column():
|
| 350 |
+
gr.Markdown("**Basic Appliances:**")
|
| 351 |
+
kitchen_oven = gr.Checkbox(label="Oven")
|
| 352 |
+
kitchen_stove = gr.Checkbox(label="Stove")
|
| 353 |
+
kitchen_microwave = gr.Checkbox(label="Microwave")
|
| 354 |
+
kitchen_water_dispenser = gr.Checkbox(label="Water Dispenser")
|
| 355 |
+
|
| 356 |
+
gr.Markdown("**Refrigeration:**")
|
| 357 |
+
kitchen_fridge_double = gr.Checkbox(label="Double Fridge")
|
| 358 |
+
kitchen_fridge_single = gr.Checkbox(label="Single Fridge")
|
| 359 |
+
kitchen_fridge_dispenser = gr.Checkbox(label="Fridge with Dispenser")
|
| 360 |
+
|
| 361 |
+
with gr.Column():
|
| 362 |
+
gr.Markdown("**Storage & Features:**")
|
| 363 |
+
kitchen_pantry = gr.Checkbox(label="Pantry")
|
| 364 |
+
kitchen_bar = gr.Checkbox(label="Bar")
|
| 365 |
+
kitchen_island = gr.Checkbox(label="Island")
|
| 366 |
+
kitchen_breakfast_nook = gr.Checkbox(label="Breakfast Nook")
|
| 367 |
+
kitchen_ุฏููุงุจ_ูุธุงูุฉ = gr.Checkbox(label="ุฏููุงุจ ูุธุงูุฉ")
|
| 368 |
+
|
| 369 |
+
kitchen_notes = gr.Textbox(label="Kitchen Notes", lines=3)
|
| 370 |
+
|
| 371 |
+
# Master Bedroom Section
|
| 372 |
+
with gr.Accordion("๐๏ธ Master Bedroom", open=False):
|
| 373 |
+
with gr.Row():
|
| 374 |
+
with gr.Column():
|
| 375 |
+
gr.Markdown("**Bed Sizes:**")
|
| 376 |
+
master_bed_1_6 = gr.Checkbox(label="Bed Size 1.6m")
|
| 377 |
+
master_bed_1_8 = gr.Checkbox(label="Bed Size 1.8m")
|
| 378 |
+
master_bed_2 = gr.Checkbox(label="Bed Size 2m")
|
| 379 |
+
master_bed_2_2 = gr.Checkbox(label="Bed Size 2.2m")
|
| 380 |
+
|
| 381 |
+
gr.Markdown("**Bedside Tables:**")
|
| 382 |
+
master_bedside_0 = gr.Checkbox(label="0 Tables")
|
| 383 |
+
master_bedside_1 = gr.Checkbox(label="1 Table")
|
| 384 |
+
master_bedside_2 = gr.Checkbox(label="2 Tables")
|
| 385 |
+
|
| 386 |
+
with gr.Column():
|
| 387 |
+
gr.Markdown("**Furniture:**")
|
| 388 |
+
master_tv_unit = gr.Checkbox(label="TV Unit")
|
| 389 |
+
master_vanity_dresser = gr.Checkbox(label="Vanity Dresser")
|
| 390 |
+
master_with_chair = gr.Checkbox(label="With Chair")
|
| 391 |
+
master_standing_mirror = gr.Checkbox(label="Standing Mirror")
|
| 392 |
+
master_inside_room = gr.Checkbox(label="Inside Room")
|
| 393 |
+
master_inside_dressing = gr.Checkbox(label="Inside Dressing")
|
| 394 |
+
|
| 395 |
+
master_inside_dressing_note = gr.Textbox(label="Inside Dressing Note", lines=2)
|
| 396 |
+
master_notes = gr.Textbox(label="Master Bedroom Notes", lines=3)
|
| 397 |
+
|
| 398 |
+
# Bedroom1 Section with Dynamic Beds
|
| 399 |
+
with gr.Accordion("๐๏ธ Bedroom 1", open=False):
|
| 400 |
+
with gr.Column():
|
| 401 |
+
# Bedroom1 beds container
|
| 402 |
+
bedroom1_beds_container = gr.Column()
|
| 403 |
+
|
| 404 |
+
# Initialize with one bed
|
| 405 |
+
with bedroom1_beds_container:
|
| 406 |
+
bed1_inputs = create_bed_inputs(1, "bedroom1")
|
| 407 |
+
bedroom1_beds.append(bed1_inputs)
|
| 408 |
+
|
| 409 |
+
# Add bed button
|
| 410 |
+
with gr.Row():
|
| 411 |
+
add_bed1_btn = gr.Button("โ Add Bed", size="sm")
|
| 412 |
+
gr.Markdown(f"(Max 5 beds)")
|
| 413 |
+
|
| 414 |
+
# Other bedroom1 features
|
| 415 |
+
with gr.Row():
|
| 416 |
+
with gr.Column():
|
| 417 |
+
bedroom1_dressing_walk_in = gr.Checkbox(label="Walk-in Dressing")
|
| 418 |
+
bedroom1_dressing_wardrobe = gr.Checkbox(label="Wardrobe")
|
| 419 |
+
bedroom1_table = gr.Checkbox(label="Table")
|
| 420 |
+
bedroom1_tv_unit = gr.Checkbox(label="TV Unit")
|
| 421 |
+
|
| 422 |
+
with gr.Column():
|
| 423 |
+
gr.Markdown("**Vanity Dresser:**")
|
| 424 |
+
bedroom1_van_with_chair = gr.Checkbox(label="With Chair")
|
| 425 |
+
bedroom1_van_standing_mirror = gr.Checkbox(label="Standing Mirror")
|
| 426 |
+
bedroom1_van_inside_room = gr.Checkbox(label="Inside Room")
|
| 427 |
+
bedroom1_van_inside_dressing = gr.Checkbox(label="Inside Dressing")
|
| 428 |
+
bedroom1_van_notes = gr.Textbox(label="Vanity Notes", lines=2)
|
| 429 |
+
|
| 430 |
+
bedroom1_notes = gr.Textbox(label="Bedroom1 Notes", lines=3)
|
| 431 |
+
|
| 432 |
+
# Add more sections as needed (Bedroom2, Bathrooms, etc.)
|
| 433 |
+
with gr.Accordion("๐๏ธ Bedroom 2", open=False):
|
| 434 |
+
gr.Markdown("*Similar to Bedroom 1 - Add dynamic beds here*")
|
| 435 |
+
|
| 436 |
+
with gr.Accordion("๐ฟ Master Toilet", open=False):
|
| 437 |
+
gr.Markdown("*Add Master Toilet fields here*")
|
| 438 |
+
|
| 439 |
+
with gr.Accordion("๐ฟ Shared Toilet", open=False):
|
| 440 |
+
gr.Markdown("*Add Shared Toilet fields here*")
|
| 441 |
+
|
| 442 |
+
with gr.Accordion("๐๏ธ Guest Bedroom", open=False):
|
| 443 |
+
gr.Markdown("*Add Guest Bedroom fields here*")
|
| 444 |
+
|
| 445 |
+
with gr.Accordion("๐ Praying Room", open=False):
|
| 446 |
+
with gr.Row():
|
| 447 |
+
praying_mehrab = gr.Checkbox(label="Mehrab")
|
| 448 |
+
praying_library = gr.Checkbox(label="Library")
|
| 449 |
+
praying_notes = gr.Textbox(label="Praying Room Notes", lines=3)
|
| 450 |
+
|
| 451 |
+
with gr.Accordion("๐ผ Office", open=False):
|
| 452 |
+
with gr.Row():
|
| 453 |
+
with gr.Column():
|
| 454 |
+
office_library = gr.Checkbox(label="Library")
|
| 455 |
+
office_tv_unit = gr.Checkbox(label="TV Unit")
|
| 456 |
+
office_sofa = gr.Checkbox(label="Sofa")
|
| 457 |
+
with gr.Column():
|
| 458 |
+
office_sofa_bed = gr.Checkbox(label="Sofa Bed")
|
| 459 |
+
office_coffee_corner = gr.Checkbox(label="Coffee Corner")
|
| 460 |
+
office_closet = gr.Checkbox(label="Closet")
|
| 461 |
+
office_notes = gr.Textbox(label="Office Notes", lines=3)
|
| 462 |
+
|
| 463 |
+
with gr.Accordion("๐ General Requirements", open=False):
|
| 464 |
+
general_notes = gr.Textbox(label="General Requirements Notes", lines=5)
|
| 465 |
+
|
| 466 |
+
# Process Button and Output
|
| 467 |
+
with gr.Row():
|
| 468 |
+
process_btn = gr.Button("๐ Process Form Data", variant="primary", size="lg")
|
| 469 |
+
|
| 470 |
+
# Output Section
|
| 471 |
+
with gr.Group():
|
| 472 |
+
gr.Markdown("## ๐ Generated JSON Output")
|
| 473 |
+
json_output = gr.Textbox(
|
| 474 |
+
label="Form Data JSON",
|
| 475 |
+
lines=20,
|
| 476 |
+
max_lines=30,
|
| 477 |
+
show_copy_button=True
|
| 478 |
+
)
|
| 479 |
+
|
| 480 |
+
# Connect the process button (simplified version)
|
| 481 |
+
process_btn.click(
|
| 482 |
+
fn=process_form_data,
|
| 483 |
+
inputs=[
|
| 484 |
+
mr_name, mrs_name,
|
| 485 |
+
reception_l_shape, reception_three_seaters, reception_two_seaters,
|
| 486 |
+
reception_chairs, reception_notes
|
| 487 |
+
# Add all other inputs here
|
| 488 |
+
],
|
| 489 |
+
outputs=json_output
|
| 490 |
+
)
|
| 491 |
+
|
| 492 |
+
# Add bed buttons functionality
|
| 493 |
+
# add_bed1_btn.click(fn=add_bed_bedroom1, outputs=[])
|
| 494 |
+
|
| 495 |
+
if __name__ == "__main__":
|
| 496 |
+
app.launch(
|
| 497 |
+
share=False,
|
| 498 |
+
server_name="0.0.0.0",
|
| 499 |
+
server_port=7860,
|
| 500 |
+
show_error=True
|
| 501 |
+
)
|