- When the user currently searches something, it searches a list, i was wondering if i could use a database or a library as a more 'efficent' way to search than a list, but i don't know how i could do this.
-I plan to have the cookbook import a description of the recipe and then ask the user if they want to continue(I can do) but i don't know how to import something depending on something else e.g. the user selects a milkshake, how do i import milkshake.py without physically programming import milkshake.py i tried using stuff like a variable".py" but that didn't work. I am using easygui.choicebox to show the search results.
-Also with the search at the moment the search has to be exact to the recipe in the list. Is there a way they can mispell a recipe or write in a keyword and get a bunch of suggestions as to what they might of ment?
Here is my code:
import easygui, sys def searchRes(search, recipes): if search in recipes: easygui.choicebox(msg ="Select a recipe", choices = (search, "")) elif search not in recipes: easygui.msgbox("The recipe was not found!") seaExi = easygui.boolbox("Would you like to search again or Exit?", choices =("Search again", "Exit")) if seaExi == 0: sys.exit() elif seaExi == 1: search() def recomend(quickRec): easygui.choicebox("have a look at today's recomendations!", title = "Easy Menu", choices =(quickRec)) def search(): search = easygui.enterbox("Enter recipe to search for it: ") searchRes(search, recipes) recipes = ['hamburgers', 'chicken kievs', 'milkshake', 'banana milkshake'] quickRec = ['hamburgers', 'chicken kievs', 'milkshake', 'banana milkshake'] easygui.msgbox("Welcome to Easy Menu", title='Easy Menu', image='easymenu_logo.gif') searRec = easygui.boolbox("Would you like to search for a recipe or look at some recomendations?", choices =("Search", "view recomendations")) if searRec == 1: search() searchRes(search, recipes) elif searRec == 0: recomend(quickRec)
I was planning to have the recipes as a separate program altogether or in a .txt file (.txt file might be easier(i guess i could use a module for that))
but also if anyone can shed some light on what would be best for that area, that would be great!
Thank you in advance
p.s. any suggestions are greatly welcomed. Also if you need anything else just let me know thanks.