Compare commits
26 Commits
62aee24595
...
formatting
| Author | SHA1 | Date | |
|---|---|---|---|
| a1d7afaad3 | |||
| 4a6bfec571 | |||
| 249723a2e0 | |||
| 28fd5cba5e | |||
| 4a78a01ae3 | |||
| c7faed0597 | |||
| 290bed8198 | |||
| 3af9453260 | |||
| 3f10d8049a | |||
| 8e9d57c5cb | |||
| ff32de4ac0 | |||
| b137fcb0f9 | |||
| dfca9bf2ed | |||
| 027b245075 | |||
| ca3d0f8090 | |||
| 2d5d44cd21 | |||
| 66011974a3 | |||
| 61f1f6a711 | |||
| fec8c05216 | |||
|
|
eb8dcc0f36 | ||
|
|
7347b53bfe | ||
|
|
75cd42ed30 | ||
| 781a7eb89b | |||
| f3467c879c | |||
|
|
95cbd7214d | ||
|
|
cf3ef89fa6 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -164,3 +164,6 @@ storage/
|
||||
|
||||
# Custom
|
||||
ingredients.json
|
||||
checklist.md
|
||||
.vscode/
|
||||
settings.json
|
||||
85
README.md
85
README.md
@@ -1,81 +1,38 @@
|
||||
# Meal Picker app
|
||||
An app made to help keep track of ingredients for meals, and to build markdown
|
||||
checklists for shopping.
|
||||
|
||||
## Files:
|
||||
### .env
|
||||
A file containing the path you want to save the final checklist to. Defaults to current folder.
|
||||
|
||||
### src/json/ingredients.json
|
||||
A file containing the JSON representation of meals and their ingredients. Will be created if one does not exist.
|
||||
|
||||
## Run the app
|
||||
|
||||
### uv
|
||||
### CLI
|
||||
|
||||
Run as a desktop app:
|
||||
Create a virtual environment:
|
||||
|
||||
```
|
||||
uv run flet run
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
Run as a web app:
|
||||
Install required packages:
|
||||
|
||||
```
|
||||
uv run flet run --web
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### Poetry
|
||||
|
||||
Install dependencies from `pyproject.toml`:
|
||||
Run the flet app:
|
||||
|
||||
```
|
||||
poetry install
|
||||
flet run MealSelector.py
|
||||
```
|
||||
OR
|
||||
```
|
||||
flet run MealBuilder.py
|
||||
```
|
||||
|
||||
Run as a desktop app:
|
||||
|
||||
```
|
||||
poetry run flet run
|
||||
```
|
||||
|
||||
Run as a web app:
|
||||
|
||||
```
|
||||
poetry run flet run --web
|
||||
```
|
||||
|
||||
For more details on running the app, refer to the [Getting Started Guide](https://flet.dev/docs/getting-started/).
|
||||
|
||||
## Build the app
|
||||
|
||||
### Android
|
||||
|
||||
```
|
||||
flet build apk -v
|
||||
```
|
||||
|
||||
For more details on building and signing `.apk` or `.aab`, refer to the [Android Packaging Guide](https://flet.dev/docs/publish/android/).
|
||||
|
||||
### iOS
|
||||
|
||||
```
|
||||
flet build ipa -v
|
||||
```
|
||||
|
||||
For more details on building and signing `.ipa`, refer to the [iOS Packaging Guide](https://flet.dev/docs/publish/ios/).
|
||||
|
||||
### macOS
|
||||
|
||||
```
|
||||
flet build macos -v
|
||||
```
|
||||
|
||||
For more details on building macOS package, refer to the [macOS Packaging Guide](https://flet.dev/docs/publish/macos/).
|
||||
|
||||
### Linux
|
||||
|
||||
```
|
||||
flet build linux -v
|
||||
```
|
||||
|
||||
For more details on building Linux package, refer to the [Linux Packaging Guide](https://flet.dev/docs/publish/linux/).
|
||||
|
||||
### Windows
|
||||
|
||||
```
|
||||
flet build windows -v
|
||||
```
|
||||
|
||||
For more details on building Windows package, refer to the [Windows Packaging Guide](https://flet.dev/docs/publish/windows/).
|
||||
For more details, go to the [Flet website](https://flet.dev/)
|
||||
@@ -1,5 +1,5 @@
|
||||
[project]
|
||||
name = "Meal Picker"
|
||||
name = "NoteNook"
|
||||
version = "0.1.0"
|
||||
description = "An app designed to build, store, and select meals for shopping purposes."
|
||||
readme = "README.md"
|
||||
@@ -8,7 +8,7 @@ authors = [
|
||||
{ name = "Nick Kalar", email = "nick@kalar.codes" }
|
||||
]
|
||||
dependencies = [
|
||||
"flet==0.28.3"
|
||||
"flet >=0.70.0.dev0",
|
||||
]
|
||||
|
||||
[tool.flet]
|
||||
@@ -18,7 +18,7 @@ org = "codes.kalar"
|
||||
|
||||
# project display name that is used as an app title on Android and iOS home screens,
|
||||
# shown in window titles and about app dialogs on desktop.
|
||||
product = "shopping"
|
||||
product = "NoteNook"
|
||||
|
||||
# company name to display in about app dialogs
|
||||
company = "Nick Kalar"
|
||||
@@ -29,6 +29,9 @@ copyright = "Copyright (C) 2025 by Nick Kalar"
|
||||
[tool.flet.app]
|
||||
path = "src"
|
||||
|
||||
[tool.flet.macos]
|
||||
entitlement."com.apple.security.files.user-selected.read-write" = true
|
||||
|
||||
[tool.uv]
|
||||
dev-dependencies = [
|
||||
"flet[all]==0.28.3",
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
python-dotenv
|
||||
flet[all]
|
||||
'flet[all]>=0.70.0.dev0'
|
||||
@@ -1,22 +1,58 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
from dotenv import load_dotenv
|
||||
working_directory = Path(__file__).parent
|
||||
|
||||
load_dotenv()
|
||||
|
||||
file_path = os.getenv("file_path")
|
||||
|
||||
def read_json() -> dict:
|
||||
try:
|
||||
with open("./src/json/ingredients.json", "rt") as file:
|
||||
with open(str(working_directory / "settings.json"), "rt") as settings_file:
|
||||
settings = json.load(settings_file)
|
||||
checklist_file_path = settings.get("checklist_storage_path", str(working_directory / "json")) + "/checklists.json"
|
||||
ingredients_file_path = settings.get("meal_storage_path", str(working_directory / "json")) + "/ingredients.json"
|
||||
except Exception as e:
|
||||
print(e)
|
||||
with open(str(working_directory / "settings.json"), "w") as settings_file:
|
||||
settings = {
|
||||
"meal_storage_path": str(working_directory / "json"),
|
||||
"checklist_storage_path": str(working_directory / "json")
|
||||
}
|
||||
json.dump(settings, settings_file, indent=4)
|
||||
checklist_file_path = settings["checklist_storage_path"] + "/checklists.json"
|
||||
ingredients_file_path = settings["meal_storage_path"] + "/ingredients.json"
|
||||
|
||||
def read_ingredient_json() -> dict:
|
||||
try:
|
||||
with open(ingredients_file_path, "rt") as file:
|
||||
return json.load(file)
|
||||
except:
|
||||
print("Could not find or read file.")
|
||||
print("Could not find or read ingredients file.")
|
||||
return {}
|
||||
|
||||
def read_json_file(filename: str) -> dict:
|
||||
try:
|
||||
with open(filename, "rt") as file:
|
||||
return json.load(file)
|
||||
except:
|
||||
print(f"Could not find or read file.\n{filename=}")
|
||||
return {}
|
||||
|
||||
def update_json(meals: dict) -> None:
|
||||
try:
|
||||
with open(ingredients_file_path, "w") as file:
|
||||
json.dump(meals, file, indent=4)
|
||||
except Exception as e:
|
||||
print(f"Unable to write data to file. {e}")
|
||||
|
||||
def update_file(filename: str, content: dict) -> None:
|
||||
try:
|
||||
with open(filename, "w") as file:
|
||||
json.dump(content, file, indent=4)
|
||||
except Exception as e:
|
||||
print(f"Unable to write data to file. {e}")
|
||||
|
||||
def get_selected_meals(meals: dict) -> dict:
|
||||
meal_json = read_json()
|
||||
meal_json = read_ingredient_json()
|
||||
selected_meals = {}
|
||||
if meal_json:
|
||||
for meal in meals:
|
||||
if meal in meal_json:
|
||||
selected_meals[meal] = meal_json[meal]
|
||||
@@ -28,17 +64,14 @@ def combine_ingredients(meals: dict) -> dict:
|
||||
for meal, ingredients in meals.items():
|
||||
for ingredient, detail in ingredients.items():
|
||||
if ingredient in combined_ingredients:
|
||||
combined_ingredients[ingredient]['quantity'] += detail['quantity']
|
||||
combined_ingredients[ingredient]['quantity'] = str(float(combined_ingredients[ingredient]['quantity']) + float(detail['quantity']))
|
||||
else:
|
||||
combined_ingredients[ingredient] = detail
|
||||
return combined_ingredients
|
||||
|
||||
def write_checklist(data: dict) -> None:
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
|
||||
try:
|
||||
with open(file_path, 'w') as checklist:
|
||||
with open(checklist_file_path, 'w') as checklist:
|
||||
for ingredient, details in data.items():
|
||||
s = ingredient + " - " + str(details['quantity'])
|
||||
if details['units'] != None:
|
||||
@@ -49,7 +82,7 @@ def write_checklist(data: dict) -> None:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
meals = read_json()
|
||||
meals = read_ingredient_json()
|
||||
if meals:
|
||||
combined_ingredients = combine_ingredients(meals)
|
||||
write_checklist(combined_ingredients)
|
||||
225
src/MealBuilder.py
Normal file
225
src/MealBuilder.py
Normal file
@@ -0,0 +1,225 @@
|
||||
from FileHandler import read_ingredient_json, update_json
|
||||
|
||||
import flet as ft
|
||||
|
||||
meal_json = read_ingredient_json()
|
||||
|
||||
def get_meal_names():
|
||||
meal_list = list(meal_json.keys())
|
||||
meal_list.sort()
|
||||
return meal_list
|
||||
|
||||
def is_number(s):
|
||||
try:
|
||||
float(s)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
def builder(page):
|
||||
class Meal():
|
||||
|
||||
def get_meal_radios(self):
|
||||
self.meal_radios = []
|
||||
for name in get_meal_names():
|
||||
self.meal_radios.append(
|
||||
ft.Radio(value=name, label=name),
|
||||
)
|
||||
|
||||
def get_meal_radios_group(self):
|
||||
return ft.RadioGroup(
|
||||
content=ft.Column(
|
||||
controls=self.meal_radios,
|
||||
)
|
||||
)
|
||||
|
||||
def update_ingredient(self, e):
|
||||
self.new_ingredient = e.control.value
|
||||
|
||||
def update_quantity(self, e):
|
||||
self.new_quantity = e.control.value
|
||||
|
||||
def update_units(self, e):
|
||||
self.new_units = e.control.value
|
||||
|
||||
def create_ingredient_row(self, ingredient, details):
|
||||
row = []
|
||||
row.append(ft.TextField(label="Ingredient", value=ingredient, on_change=self.update_ingredient, width=300))
|
||||
row.append(ft.TextField(label="Quantity", value=details['quantity'], on_change=self.update_quantity, width=200))
|
||||
row.append(ft.TextField(label="Units (optional)", value=details['units'], on_change=self.update_units, width=200))
|
||||
return row
|
||||
|
||||
def create_new_ingredient_row(self):
|
||||
row = []
|
||||
row.append(ft.TextField(label="Ingredient", value="", width=300))
|
||||
row.append(ft.TextField(label="Quantity", value="", width=200))
|
||||
row.append(ft.TextField(label="Units (optional)", value="", width=200))
|
||||
return row
|
||||
|
||||
def update_ingredients(self, name):
|
||||
pass
|
||||
# Doesn't work yet
|
||||
|
||||
# if not self.new_ingredient or not self.new_quantity or not is_number(self.new_quantity):
|
||||
# page.show_dialog(ft.SnackBar(ft.Text("Please fill in the current ingredient before adding a new one.")))
|
||||
# return
|
||||
|
||||
# ingredient = {
|
||||
# self.new_ingredient:
|
||||
# {
|
||||
# "quantity":float(self.new_quantity),
|
||||
# "units": self.new_units if self.new_units != "" else None
|
||||
# }
|
||||
# }
|
||||
# meal_json[name] = ingredient
|
||||
# update_json(meal_json)
|
||||
# page.update()
|
||||
|
||||
def show_new_meal(self):
|
||||
self.new_meal = {}
|
||||
selector_body.controls = [
|
||||
ft.TextField(label="Meal", value="", autofocus=True, width=720),
|
||||
ft.ListView(controls=[ft.Row(self.create_new_ingredient_row(),
|
||||
alignment=ft.MainAxisAlignment.START,
|
||||
)],
|
||||
expand=True,
|
||||
auto_scroll=False,
|
||||
),
|
||||
ft.Row(controls=[
|
||||
ft.Button(content=ft.Text("Add Ingredient"), on_click=lambda e: self.append_new_ingredient_row(selector_body)),
|
||||
ft.Button(content=ft.Text("Add Meal"), on_click=lambda e: self.add_new_meal(selector_body)),
|
||||
ft.Button(content=ft.Text("Back"), on_click=lambda e: self.show_meal_selection(selector_body, page))
|
||||
]
|
||||
)
|
||||
|
||||
]
|
||||
|
||||
page.title = "Add New Meal"
|
||||
page.update()
|
||||
|
||||
def append_new_ingredient_row(self, selector_body):
|
||||
# Don't add a new row if the last one is blank
|
||||
if selector_body.controls[1].controls[-1].controls[0].value == "" or \
|
||||
selector_body.controls[1].controls[-1].controls[1].value == "":
|
||||
page.show_dialog(ft.SnackBar(ft.Text("Please fill in the current ingredient before adding a new one.")))
|
||||
return
|
||||
|
||||
selector_body.controls[1].controls.append(ft.Row(self.create_new_ingredient_row(),
|
||||
alignment=ft.MainAxisAlignment.SPACE_EVENLY,
|
||||
width=300,
|
||||
height=100,))
|
||||
|
||||
page.update()
|
||||
|
||||
def add_new_meal(self, selector_body):
|
||||
meal = selector_body.controls[0].value
|
||||
ing, qua, uni = [], [], []
|
||||
|
||||
if meal == "" or \
|
||||
selector_body.controls[1].controls.controls[0].value == "" or \
|
||||
selector_body.controls[1].controls.controls[1].value == "":
|
||||
page.show_dialog(ft.SnackBar(ft.Text("Please fill out the meal information.")))
|
||||
return
|
||||
|
||||
for row in selector_body.controls[1].controls:
|
||||
#skip blank row
|
||||
if row.controls[0].value == "" or row.controls[1].value == "":
|
||||
continue
|
||||
ing.append(row.controls[0].value)
|
||||
qua.append(row.controls[1].value)
|
||||
uni.append(row.controls[2].value if row.controls[2].value != "" else None)
|
||||
|
||||
meal_json[meal] = {}
|
||||
for i in range(len(ing)):
|
||||
meal_json[meal][ing[i]] = { 'quantity': qua[i], 'units': uni[i] }
|
||||
|
||||
#write changes to the ingredients.json file
|
||||
update_json(meal_json)
|
||||
self.show_new_meal()
|
||||
|
||||
def show_meal_details(self, selector_body, page):
|
||||
expanded_meal = []
|
||||
|
||||
if (selector_body.controls[0].controls[0].value == None):
|
||||
page.show_dialog(ft.SnackBar(ft.Text("Please select a meal to update.")))
|
||||
return
|
||||
|
||||
meal_name = selector_body.controls[0].controls[0].value
|
||||
|
||||
for details in meal_json[meal_name].items():
|
||||
expanded_meal.append(
|
||||
ft.Row(controls=[
|
||||
self.create_ingredient_row(details[0], details[1]),
|
||||
ft.Button(icon=ft.Icons.DELETE_FOREVER_ROUNDED, color=ft.Colors.RED_500, on_click=lambda e, d=details: expanded_meal.remove(e.control.parent)),
|
||||
],
|
||||
alignment=ft.MainAxisAlignment.SPACE_EVENLY,
|
||||
)
|
||||
)
|
||||
|
||||
selector_body.controls = [
|
||||
ft.TextField(label="Meal", value=meal_name),
|
||||
ft.ListView(
|
||||
controls=expanded_meal,
|
||||
expand=True,
|
||||
spacing=10,
|
||||
padding=10,
|
||||
auto_scroll=False,
|
||||
),
|
||||
ft.Row(controls=[
|
||||
ft.Button(content=ft.Text("Save Changes"), on_click=lambda e: self.update_ingredients(selector_body.controls[0].value)),
|
||||
ft.Button(content=ft.Text("Back"), on_click=lambda e: self.show_meal_selection(selector_body, page)),
|
||||
]
|
||||
)
|
||||
]
|
||||
if page.title == "Create and Edit Meals!":
|
||||
page.title = f"Editing {meal_name}"
|
||||
page.update()
|
||||
|
||||
return selector_body
|
||||
|
||||
def show_meal_selection(self, selector_body, page):
|
||||
self.get_meal_radios()
|
||||
selector_body.controls = [ft.ListView(
|
||||
controls=[
|
||||
self.get_meal_radios_group(),
|
||||
],
|
||||
expand=True,
|
||||
spacing=10,
|
||||
padding=10,
|
||||
auto_scroll=False,
|
||||
),
|
||||
ft.Row(
|
||||
controls=[
|
||||
ft.Button(content=ft.Text("Update Meal"),
|
||||
on_click=lambda e: self.show_meal_details(selector_body, page)),
|
||||
ft.Button(content=ft.Text("Add Meal"), on_click=lambda e: self.show_new_meal())
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
if page.title != "Create and Edit Meals!":
|
||||
page.title = f"Create and Edit Meals!"
|
||||
page.update()
|
||||
|
||||
return selector_body
|
||||
|
||||
|
||||
|
||||
meal = Meal()
|
||||
page.title = "Create and Edit Meals!"
|
||||
|
||||
selector_body = ft.Column(
|
||||
controls = [],
|
||||
height = 700,
|
||||
expand = False,
|
||||
)
|
||||
|
||||
page.controls[0].content = meal.show_meal_selection(selector_body, page)
|
||||
page.update()
|
||||
|
||||
# TODO add functionality to add ingredients to a meal
|
||||
# TODO (Possible) add functionality to delete meals and/or ingredients
|
||||
|
||||
if __name__ == "__main__":
|
||||
ft.app(builder)
|
||||
@@ -1,8 +1,9 @@
|
||||
from FileHandler import read_json, combine_ingredients, write_checklist
|
||||
from FileHandler import read_ingredient_json, combine_ingredients, write_checklist
|
||||
|
||||
import flet as ft
|
||||
|
||||
selected_meals = {}
|
||||
meal_json = read_json()
|
||||
meal_json = read_ingredient_json()
|
||||
|
||||
def selector(page: ft.Page):
|
||||
def update_meal_selection(event):
|
||||
@@ -12,18 +13,27 @@ def selector(page: ft.Page):
|
||||
selected_meals.pop(meal.label)
|
||||
else:
|
||||
selected_meals[meal.label] = meal_json[meal.label]
|
||||
print(selected_meals)
|
||||
if selected_meals == {}:
|
||||
page.show_dialog(ft.SnackBar(ft.Text("Please select at least one meal.")))
|
||||
return
|
||||
|
||||
write_checklist(combine_ingredients(selected_meals))
|
||||
|
||||
|
||||
page.title = "Select Some Meals"
|
||||
meal_list = []
|
||||
for name, _ in meal_json.items():
|
||||
meal_list.append(ft.Checkbox(label=name))
|
||||
meal_list.append(ft.Checkbox(
|
||||
label = name,
|
||||
active_color = '#6da0cd',
|
||||
|
||||
submit_button = ft.ElevatedButton(text="Make Shopping List", on_click=update_meal_selection)
|
||||
)
|
||||
)
|
||||
|
||||
page.add(
|
||||
submit_button = ft.Button(content=ft.Text("Make Shopping List"), on_click=update_meal_selection)
|
||||
|
||||
page.controls[0].content = ft.Column(
|
||||
controls = [
|
||||
ft.ListView(
|
||||
controls=meal_list,
|
||||
expand=True,
|
||||
@@ -31,6 +41,11 @@ def selector(page: ft.Page):
|
||||
padding=10,
|
||||
),
|
||||
submit_button,
|
||||
],
|
||||
height = 700,
|
||||
expand = False,
|
||||
)
|
||||
page.update()
|
||||
|
||||
if __name__ == "__main__":
|
||||
ft.app(selector)
|
||||
64
src/Settings.py
Normal file
64
src/Settings.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import json
|
||||
import flet as ft
|
||||
from pathlib import Path
|
||||
from FileHandler import update_file, read_json_file
|
||||
|
||||
working_directory = Path(__file__).parent / 'settings.json'
|
||||
|
||||
def settings(page):
|
||||
file_picker = ft.FilePicker()
|
||||
page.services.append(file_picker)
|
||||
|
||||
def toggle_dark_mode(e):
|
||||
if dark_mode_switch.value:
|
||||
page.theme_mode = ft.ThemeMode.DARK
|
||||
else:
|
||||
page.theme_mode = ft.ThemeMode.LIGHT
|
||||
page.update()
|
||||
|
||||
async def set_meal_file_path(e):
|
||||
meal_directory_path.value = await file_picker.get_directory_path()
|
||||
if meal_directory_path.value:
|
||||
settings_data["meal_storage_path"] = meal_directory_path.value
|
||||
update_file(working_directory, settings_data)
|
||||
|
||||
async def set_checklist_file_path(e):
|
||||
checklist_directory_path.value = await file_picker.get_directory_path()
|
||||
if checklist_directory_path.value:
|
||||
settings_data["checklist_storage_path"] = checklist_directory_path.value
|
||||
update_file(working_directory, settings_data)
|
||||
|
||||
dark_mode_switch = ft.Switch(
|
||||
label="Dark Mode",
|
||||
value=False,
|
||||
on_change=toggle_dark_mode
|
||||
)
|
||||
|
||||
settings_data = read_json_file(working_directory)
|
||||
|
||||
page.title = "Settings"
|
||||
|
||||
page.controls[0].content = ft.Column(
|
||||
controls=[
|
||||
dark_mode_switch,
|
||||
ft.Row(controls=[
|
||||
ft.Button(
|
||||
"Set Meal Storage Path",
|
||||
icon=ft.Icons.FOLDER_OPEN,
|
||||
on_click=set_meal_file_path
|
||||
),
|
||||
meal_directory_path := ft.Text(settings_data.get("meal_storage_path", "Not Set")),
|
||||
],),
|
||||
ft.Row(controls=[
|
||||
ft.Button(
|
||||
"Set Checklist Storage Path",
|
||||
icon=ft.Icons.FOLDER_OPEN,
|
||||
on_click=set_checklist_file_path
|
||||
),
|
||||
checklist_directory_path := ft.Text(settings_data.get("checklist_storage_path", "Not Set")),
|
||||
]),
|
||||
],
|
||||
height=700,
|
||||
expand=False,
|
||||
)
|
||||
page.update()
|
||||
BIN
src/assets/hamburger.png
Normal file
BIN
src/assets/hamburger.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
31
src/main.py
31
src/main.py
@@ -1,26 +1,17 @@
|
||||
import flet as ft
|
||||
from MealSelector import selector
|
||||
from models.MenuBar import create_menubar
|
||||
|
||||
|
||||
def main(page: ft.Page):
|
||||
counter = ft.Text("0", size=50, data=0)
|
||||
page.window.width = 750
|
||||
page.window.height = 900
|
||||
page.window.top = 10
|
||||
page.appbar = create_menubar(page)
|
||||
page.bgcolor = '#013328'
|
||||
|
||||
def increment_click(e):
|
||||
counter.data += 1
|
||||
counter.value = str(counter.data)
|
||||
counter.update()
|
||||
page.add(ft.Pagelet(content=ft.Text(), expand=True, bgcolor='#013328'))
|
||||
selector(page)
|
||||
|
||||
page.floating_action_button = ft.FloatingActionButton(
|
||||
icon=ft.Icons.ADD, on_click=increment_click
|
||||
)
|
||||
page.add(
|
||||
ft.SafeArea(
|
||||
ft.Container(
|
||||
counter,
|
||||
alignment=ft.alignment.center,
|
||||
),
|
||||
expand=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
ft.app(main)
|
||||
if __name__ == "__main__":
|
||||
ft.run(main)
|
||||
23
src/models/MenuBar.py
Normal file
23
src/models/MenuBar.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import flet as ft
|
||||
from MealBuilder import builder
|
||||
from MealSelector import selector
|
||||
from Settings import settings
|
||||
|
||||
def create_menubar(page: ft.Page):
|
||||
menu = ft.AppBar(
|
||||
title=ft.Text("NoteNook"),
|
||||
bgcolor='#CC8B65',
|
||||
center_title=False,
|
||||
actions=[
|
||||
ft.PopupMenuButton(
|
||||
items=[
|
||||
ft.PopupMenuItem(content=ft.Text("Meal Selector"), on_click=lambda e: selector(page)),
|
||||
ft.PopupMenuItem(content=ft.Text("Meal Builder"), on_click=lambda e: builder(page)),
|
||||
ft.PopupMenuItem(content=ft.Text("Settings"), on_click=lambda e: settings(page)),
|
||||
],
|
||||
icon = ft.Icons.FASTFOOD_OUTLINED,
|
||||
icon_color = '#E3DCD2'
|
||||
)
|
||||
]
|
||||
)
|
||||
return menu
|
||||
Reference in New Issue
Block a user