This repository provides a template for building Python applications with Flet, designed for simplicity, modularity, and customization. The template includes essential features like navigation bar activation, custom footer integration, and system tray icon functionality using Pystray. It's structured to help you start quickly while keeping the code clean and maintainable.
- Enable or disable a custom navigation bar.
- Enable or disable a custom footer.
- Add a system tray icon with Pystray for running the app in the background.
- Includes a context menu with customizable options, such as opening the app and exiting.
- Built-in routing system with separate files for each page.
- Simple navigation between different app pages using Flet’s
Router
.
- The project is divided into separate files for each feature and function:
- Pages folder
- Navigation bar
- Footer
- Page router
- Ensures that the code is easy to maintain, scale, and reuse.
git clone https://github.com/diegopereiracruz/flet_template
cd flet_template
Ensure you have Python 3.8+ installed. Then, run:
pip install flet pystray PIL
Execute the main script to start the application:
python3 main.py
Here's an overview of the template structure:
flet_template/
├── app
│ ├── assets # Medias folder (images, icons, etc)
│ │ └── tray_icon
│ ├── pages # Pages folder
│ │ └── home.py
│ ├── system
│ │ └── FletRouter.py # Routing system
│ └── ui
│ ├── footer.py # Custom footer bar
│ └── navigation.py # Custom navigation bar
└── main.py # Entry point of the app
In the main.py
file, you can toggle some features by modifying some variables:
enable_tray = False
enable_navbar = False
enable_footer = False
- Create the page file in
app/pages/
. e.g.,app/pages/settings.py
- In
app/system/FletRouter.py
import the page. e.g.,from app.pages.settings import settings_page
- Put the path of the page inside
self.routes = {...}
. e.g.,"/settings": settings_page(page),
This project is licensed under the MIT License.
Feel free to use, modify, and distribute this template for your own projects!
Contributions are welcome! If you encounter any issues or have suggestions, feel free to open an issue or submit a pull request.
Special thanks to the Flet and Pystray communities for their excellent tools that power this template.
Enjoy coding with Flet! 🚀