FLAT is a production-ready template for building desktop applications with Flet. Built on the proven UI architecture from OHM (Oral History Manager), it provides a professional starting point with essential features like persistent settings, logging, function management, and help documentation.
- Persistent Settings: Automatic saving/loading of window position, directories, and user preferences
- Professional Logging: Timestamped log files in
~/FLAT-data/logfiles/with real-time display - Function Management: Icon-enhanced dropdown with usage tracking and workflow ordering
- Help Mode: Built-in markdown help viewer for each function with copy-to-clipboard
- Smart Directory Management: Collapsible directories section to maximize screen space
- File Selection: Dedicated file picker with persistence (separate from directories)
- Status & Log Output: Professional status display with copy/paste and log management
- Proven UI Layout: Based on OHM's battle-tested interface design
- Function 0 ⚙️: App Settings - Configure application settings with encrypted storage
- Function 1 📁: List all files in a directory
- Function 2 📊: Count files by extension type
- Function 3 💻: Display system information
These examples demonstrate the function pattern and can be replaced with your own functionality.
-
Clone or copy this template
cd /path/to/your/projects cp -r FLAT my-new-app cd my-new-app
-
Run the application
# macOS/Linux ./run.sh # Windows run.bat
The run scripts automatically:
- Create a Python virtual environment
- Install dependencies
- Launch the application
- Python 3.8+
- Flet 0.25.2 (installed automatically by run scripts)
No other dependencies required for the base template.
FLAT/
├── app.py # Main application (715 lines - streamlined!)
├── run.sh # macOS/Linux launcher
├── run.bat # Windows launcher
├── build_dmg.sh # macOS installer builder
├── build_windows_zip.sh # Windows package builder
├── python_requirements.txt # Python dependencies
├── .gitignore # Git exclusions
├── LICENSE # MIT License
├── CHANGELOG.md # Version history
├── QUICKSTART.md # Quick reference guide
├── FUNCTION_1_LIST_FILES.md # Help docs for Function 1
├── FUNCTION_2_COUNT_FILES.md # Help docs for Function 2
├── FUNCTION_3_SYSTEM_INFO.md # Help docs for Function 3
└── README.md # This file
When you run the application, these are created automatically:
~/FLAT-data/
├── logfiles/ # Application logs
│ └── flat_YYYYMMDD_HHMMSS.log
└── persistent.json # Saved settings and state
Update these items throughout the codebase:
page.titleinapp.py- Data directory name (
FLAT-data→YourApp-data) - Window title and header text
- Script headers in
run.shandrun.bat - README title and descriptions
To add a new function, follow the OHM-proven pattern:
a) Create the function handler in app.py:
def on_function_4_your_feature(e):
"""Function 4: Your custom feature description."""
storage.record_function_usage("Function 4")
# Access current directory if needed
if not current_directory or not current_directory.exists():
update_status("Error: Please select an input directory first", is_error=True)
return
# Your implementation here
# ... do work ...
update_status("Your feature completed successfully")
add_log_message("Function 4 completed")
logger.info("Function 4: Completed")b) Add to the active_functions list:
active_functions = [
"function_1_list_files",
"function_2_count_files",
"function_3_system_info",
"function_4_your_feature", # Add this
]c) Register in the functions dictionary:
functions = {
# ... existing functions ...
"function_4_your_feature": {
"label": "4: Your Custom Feature",
"icon": "🎯", # Pick an emoji icon
"handler": on_function_4_your_feature,
"help_file": "FUNCTION_4_YOUR_FEATURE.md"
},
}d) Create help documentation:
Create FUNCTION_4_YOUR_FEATURE.md with markdown documentation. The template automatically:
- Shows help in a dialog when Help Mode is enabled
- Provides copy-to-clipboard functionality
- Displays the function's icon and label
If your functions need additional Python packages:
-
Add them to
python_requirements.txt:flet==0.25.2 flet-desktop==0.25.2 your-package>=1.0.0 -
Import them in
app.py:try: import your_package YOUR_PACKAGE_AVAILABLE = True except ImportError: YOUR_PACKAGE_AVAILABLE = False
-
Check availability before use:
if not YOUR_PACKAGE_AVAILABLE: show_status("Error: your-package not installed", is_error=True) return
The layout is defined in the page.add() section at the bottom of app.py. The structure uses Flet containers and rows:
page.add(
ft.Container(
content=ft.Column([
# Your UI components here
]),
padding=30,
)
)Add your own UI elements:
ft.TextField()- Text input fieldsft.Dropdown()- Dropdown menusft.Checkbox()- Checkboxesft.ElevatedButton()- Buttonsft.Text()- Labels and textft.Row()andft.Column()- Layout containers
See Flet documentation for all available controls.
To save additional settings:
# Save a custom setting
storage.set_ui_state("my_custom_field", "value")
# Load a custom setting
value = storage.get_ui_state("my_custom_field", default="default_value")All settings are automatically saved to ~/FLAT-data/persistent.json.
Once you've built your own functions, clean up the examples:
- Delete function handlers from
app.py:on_function_1_list_files,on_function_2_count_files,on_function_3_system_info - Delete help files:
FUNCTION_1_LIST_FILES.md,FUNCTION_2_COUNT_FILES.md,FUNCTION_3_SYSTEM_INFO.md - Remove entries from
active_functionslist andfunctionsdictionary - Update the title and description to match your application
Note: Function 0 (App Settings) provides core configuration management and may be useful to keep and customize rather than remove. If you don't need it, also remove on_function_0_app_settings and FUNCTION_0_APP_SETTINGS.md.
FLAT uses OHM's proven layout structure:
- Collapsible Directories Section: Saves vertical space once directories are set
- File Selection: Always visible for quick file changes between operations
- Functions Dropdown: Icon-enhanced with emoji indicators
- Status Output: Multi-line with copy-to-clipboard
- Log Output: Timestamped entries with copy and clear functionality
- Help Mode: Toggle to view function documentation instead of executing
This layout has been refined through real-world use in production applications.
Create a distributable DMG file:
bash build_dmg.sh 1.0This creates YourApp_v1.0.dmg with:
- Self-contained app bundle
- Automatic dependency installation on first launch
- No code signing (users must right-click → Open on first launch)
Create a distributable ZIP package:
bash build_windows_zip.sh 1.0This creates YourApp_v1.0_Windows.zip with:
- All source files
run.batlauncher- Automatic dependency installation on first launch
Recipients need Python 3 installed (one-time setup).
All application activity is logged to:
~/FLAT-data/logfiles/flat_YYYYMMDD_HHMMSS.log
Use the logger in your functions:
logger.info("Information message")
logger.warning("Warning message")
logger.error("Error message")
logger.debug("Debug message")Console output shows only errors; all levels are written to log files.
Help files use GitHub Flavored Markdown and support:
- Headers (
#,##,###) - Lists (ordered and unordered)
- Code blocks with syntax highlighting
- Tables
- Links
- Bold and italic text
Create help documentation for each function to guide users.
- OHM - Oral History Manager: Audio processing workflow for digital archives
- (Add your own app here!)
After modifying app.py, just rerun:
./run.sh # or run.bat on WindowsThe virtual environment and dependencies are cached, so subsequent runs are fast.
- Check log files in
~/FLAT-data/logfiles/for errors - Console shows error-level messages immediately
- Use
logger.debug()for detailed troubleshooting
Initialize a git repository for your new app:
git init
git add .
git commit -m "Initial commit based on FLAT template"The included .gitignore excludes:
- Virtual environments (
.venv/) - Python cache (
__pycache__/) - Log files
- Build artifacts
- Documentation: https://flet.dev/docs/
- Controls Gallery: https://flet.dev/docs/controls
- GitHub: https://github.com/flet-dev/flet
- Discord: https://discord.gg/dzWXP8SHG8
MIT License - See LICENSE or LICENSE.md for full details.
Copyright (c) 2026 Digital.Grinnell / FLAT Contributors
Free to use, modify, and distribute. Attribution appreciated but not required.
Contributions are welcome! Please feel free to:
- Report bugs or issues
- Suggest new features or improvements
- Submit pull requests
- Share applications you've built with FLAT
FLAT was created by extracting and generalizing the proven UI framework from OHM (Oral History Manager). It provides a professional starting point for Flet desktop applications, eliminating the need to reinvent common patterns like settings persistence, logging, function management, and help systems.
The template's architecture has been refined through real-world production use, ensuring reliability and maintainability.
Repository: https://github.com/Digital-Grinnell/FLAT
Built with ❤️ using Flet by the Digital.Grinnell team.