File size: 1,774 Bytes
bed1072
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# utils.py - Additional utility functions (not currently used but available for extension)

def export_todos(filename: str = "todos_backup.json"):
    """Export todos to a backup file"""
    import json
    from datetime import datetime
    from app import load_todos
    
    todos = load_todos()
    backup_data = {
        "exported_at": datetime.now().isoformat(),
        "todos": todos
    }
    
    try:
        with open(filename, 'w') as f:
            json.dump(backup_data, f, indent=2)
        return f"βœ… Todos exported to {filename}"
    except Exception as e:
        return f"❌ Export failed: {str(e)}"

def import_todos(filename: str):
    """Import todos from a backup file"""
    import json
    from app import save_todos
    
    try:
        with open(filename, 'r') as f:
            data = json.load(f)
            todos = data.get("todos", [])
            save_todos(todos)
        return f"βœ… Imported {len(todos)} todos"
    except Exception as e:
        return f"❌ Import failed: {str(e)}"
This Gradio Todo App features:

βœ… **Core Functionality**
- Add todos with priority levels (1-3)
- Toggle completion status
- Delete individual todos
- Clear all completed todos
- Persistent storage (JSON file)

βœ… **Modern UI**
- Clean, responsive Blocks layout
- Emojis and visual priority indicators
- Real-time updates
- Status messages
- Professional theming

βœ… **User Experience**
- Intuitive priority slider
- Helpful placeholders and labels
- Auto-clear input after adding
- Sorted display (priority + ID)
- Loading initial state

βœ… **Production Ready**
- Error handling
- File persistence across sessions
- Proper state management
- Export/import utilities (in utils.py)

Simply run `python app.py` and your Todo app is live! πŸ“±βœ¨