File size: 2,443 Bytes
86062d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from PIL import Image, ImageDraw, ImageFont
import os

def create_test_ui_image():
    """Create a simple test UI image with buttons and text"""
    # Create a new image with white background
    width, height = 800, 600
    image = Image.new('RGB', (width, height), color='white')
    draw = ImageDraw.Draw(image)
    
    # Try to load a font, use default if not available
    try:
        font = ImageFont.truetype("arial.ttf", 20)
        small_font = ImageFont.truetype("arial.ttf", 16)
    except IOError:
        font = ImageFont.load_default()
        small_font = ImageFont.load_default()
    
    # Draw a header
    draw.rectangle([(0, 0), (width, 60)], fill='#4285F4')
    draw.text((20, 15), "Test UI Application", fill='white', font=font)
    
    # Draw a sidebar
    draw.rectangle([(0, 60), (200, height)], fill='#F1F1F1')
    
    # Draw menu items in sidebar
    menu_items = ["Home", "Profile", "Settings", "Help", "Logout"]
    for i, item in enumerate(menu_items):
        y = 100 + i * 50
        # Highlight one item
        if item == "Settings":
            draw.rectangle([(10, y-10), (190, y+30)], fill='#E1E1E1')
        draw.text((20, y), item, fill='black', font=font)
    
    # Draw main content area
    draw.text((220, 80), "Welcome to the Test UI", fill='black', font=font)
    
    # Draw a form
    draw.text((220, 150), "Please enter your information:", fill='black', font=font)
    
    # Draw form fields
    fields = ["Name", "Email", "Phone"]
    for i, field in enumerate(fields):
        y = 200 + i * 60
        draw.text((220, y), f"{field}:", fill='black', font=font)
        draw.rectangle([(320, y-5), (700, y+25)], outline='black')
    
    # Draw buttons
    draw.rectangle([(220, 400), (320, 440)], fill='#4285F4')
    draw.text((240, 410), "Submit", fill='white', font=font)
    
    draw.rectangle([(340, 400), (440, 440)], fill='#9E9E9E')
    draw.text((360, 410), "Cancel", fill='white', font=font)
    
    # Draw a checkbox
    draw.rectangle([(220, 470), (240, 490)], outline='black')
    draw.text((250, 470), "Remember me", fill='black', font=small_font)
    
    # Save the image
    os.makedirs("static", exist_ok=True)
    image_path = "static/test_ui.png"
    image.save(image_path)
    print(f"Test UI image created at {image_path}")
    return image_path

if __name__ == "__main__":
    create_test_ui_image()