Python: Cooking App P-2
Learning : Python, Data-Base, SQlite
Subject: Writing a Cooking Application
Over view: In Part-1 (Click to Read) we list down the Main-Menus and sub-menus of some options, here we will start writing the codes of each menu. We will start from the Main-Menu.
Now with each menu from the last post, we will see the code and the run-time screen.
[ MAIN MENU ]
1. Add New Meal.
2. Ingredients Manager [will have a sub menu]
3. Add New.
4. Show Recipes.(Meals) [will have a sub menu]
5. Recipes Information.) [ number or Recipes by date, number on tags, number of Ingredients .. ]
6. Data-Base Information.
7. Setting. [will have a sub menu]
9. Exit.
# Main Menu Code def main_menu(): while True : os.system("clear") print('\n ===========[ MAIN MENU ]=============') print(' --------------------------------------') print(' 1. Add New Meal.') print(' 2. Ingredients Manager') print(' 3. Add New') print(' 4. Show Recipes.') print(' 5. Recipes Information.') print(' 6. DataBase Information.') print(' 7. Setting') print(' 9. Exit.') uinput = input('\n Select the required action: ') if uinput == '1' : pass elif uinput =='2' : ingredient_menu() elif uinput =='3' : show_recipes () elif uinput =='4' : pass elif uinput =='5' : pass elif uinput == '6' : pass elif uinput == '7' : setting_menu() elif uinput == '9' : return else: print('\n You need to select from the menu..')
![]() |
![]() |
Second menu to write is “Show Recipes”, the user will use this menu to display and read the Recipes.
[ Show Recipes ]
1. Show All Recipes.
2. Show Recipes By Date.
3. Show Recipes By Ingredients.
4. Show Recipes By Tags.
5. Show Recipes By Name.
9. Exit.
# Show Recipes Menu Code def show_recipes () : while True: os.system("clear") print('\n ===========[ Show Recipes ]=============') print(' --------------------------------------') print(' 1. Show All Recipes.') print(' 2. Show Recipes By Date. ') print(' 3. Show Recipes By Ingredients.') print(' 4. Show Recipes By Tags.') print(' 5. Show Recipes By Name.') print(' 9. Exit') uinp= input('\n Enter your Selection: ') if uinp == '1': pass elif uinp == '2': pass elif uinp == '3': pass elif uinp == '4': pass elif uinp == '5': pass elif uinp =='9': return else: print('\n Please select from the Menu.')
![]() |
![]() |
Third menu we have in our application is “Ingredient Menu”, the user will it to manage the Ingredient list.
[ INGREDIENT MENU ]
1. Show all Ingredient.
2. Add Ingredient.
3. Delete Ingredient.
4. Edit Ingredient.
9. Exit.
# Ingredient Menu Code def ingredient_menu(): while True: os.system("clear") print('\n ===========[ INGREDIENT MENU ]=============') print(' --------------------------------------') print(' 1. Show all Ingredient.') print(' 2. Add Ingredient.') print(' 3. Delete Ingredient. ') print(' 4. Edit Ingredient') print(' 9. Exit') uinp= input('\n Enter your Selection: ') if uinp == '1': pass elif uinp == '2': pass elif uinp == '3': pass elif uinp == '4': pass elif uinp =='9': return else: print('\n Please select from the Menu.')
![]() |
![]() |
Last menu we have is “Setting Menu”, from here we can create the tables and Insert a Dummy-Data.
[ SETTING MENU ]
1. Create the needed Tables.
2. Drop Tables.
3. Insert Dummy Data. (MUST be run after Tables Creation)
9. Exit.
# Setting Menu Code def setting_menu(): while True: os.system("clear") print('\n ===========[ SETTING MENU ]=============') print(' --------------------------------------') print(' 1. Create the needed Tables.') print(' 2. Drop Tables. ') print(' 3. Insert Dummy Data. (MUST be run One-Time after Tables Creation)') print(' 9. Exit') uinp= input('\n Enter your Selection: ') if uinp == '1': pass elif uinp == '2': pass elif uinp == '3': pass elif uinp =='9': return else: print('\n Please select from the Menu.')
![]() |
![]() |
Next Post: In next post we will write the codes for Setting menu so we can run it and from there we can create the Tables and Insert the Dummy Data.
To Download my Python code (.py) files Click-Here
By: Ali Radwani
-
February 9, 2020 at 8:16 amPython: Cooking App P-3 | Ali's Photography Space...