Exemplo n.º 1
0
def main():
    menu()
    categories = requests.get_categories()
    areas = requests.get_areas()

    while True:
        print()
        command = input("Command: ")

        if command == "1":
            print()
            get_categories(categories)
        elif command == "2":
            category = input("Enter a category: ")
            print()
            get_meals_by_category(category)
        elif command == "3":
            name = input("Enter Meal Name: ")
            print()
            get_meal_by_name(name)
        elif command == "4":
            get_random_meal()
        elif command == "5":
            get_areas(areas)
        elif command == "6":
            area = input("Enter an area: ")
            print()
            get_meals_by_area(area)
        elif command == "0":
            break
        else:
            print("Please enter a number from 0 to 6.")

    end()
Exemplo n.º 2
0
def main():
    show_title()
    display_menu()
    categories = requests.get_categories()
    areas = requests.get_area()
    while True:
        command = input("Command: ")
        if command == "1":
            list_categories(categories)
        elif command == "2":
            search_meal_by_category(categories)
        elif command == "3":
            search_meal_by_name()
        elif command == "4":
            random_meal(categories)
        elif command == "5":
            list_area(areas)
        elif command == "6":
            search_meal_by_area(areas)
        elif command == "7":
            display_menu()
        elif command == "0":
            print()
            print("Thank you for dining with us!")
            break
        else:
            print("Not a valid command. Please try again")
Exemplo n.º 3
0
def main():
    # This method controls the flow of the program

    #Show the title and menu to screen
    show_title()
    show_menu()

    # Get the list of categories
    categories = requests.get_categories()
    areas = requests.get_areas()

    # Get the user menu selection
    while True:
        command = input("Command: ")
        if command == "1":
            list_categories(categories)
        elif command == "2":
            search_meal_by_category(categories)
        elif command == "3":
            search_meal_by_name()
        elif command == "4":
            list_areas(areas)
        elif command == "5":
            search_meal_by_area(areas)
        elif command == "0":
            print("Cya!")
            break
        else:
            print("Not a valid command. Please try again.\n")
Exemplo n.º 4
0
def main():
    show_title()
    categories = requests.get_categories()
    # start of gui
    root = tk.Tk()
    canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH)
    canvas.pack()
    bg_image = tk.PhotoImage(file='background.png')
    bg_label = tk.Label(root, image=bg_image)
    bg_label.place(
        relwidth=1,
        relheight=1,
    )
    frame1 = tk.Frame(root, bg='#7B7472', bd=5)
    frame1.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.1)
    frame2 = tk.Frame(root, bg='#7B7472', bd=4)
    frame2.place(relx=0.1, rely=0.23, relwidth=0.8, relheight=0.65)
    recipe_label = tk.Label(frame2, bg='#E7F6B3', text='')
    recipe_label.place(relheight=1, relwidth=1)

    button1 = tk.Button(
        frame1,
        text="Categories",
        command=lambda: list_categories(categories, recipe_label))
    button1.place(relx=0.47, relheight=1, relwidth=0.1)
    button2 = tk.Button(
        frame1,
        text="Search Meal",
        command=lambda: search_meal_by_name(entry.get(), recipe_label))
    button2.place(relx=0.58, relheight=1, relwidth=0.12)
    button3 = tk.Button(frame1,
                        text="Expand",
                        command=lambda: search_meal_by_category(
                            categories, entry.get(), recipe_label))
    button3.place(relx=0.71, relheight=1, relwidth=0.1)
    button4 = tk.Button(
        frame1,
        text="Area Search",
        command=lambda: search_meals_by_area(entry.get(), recipe_label))
    button4.place(relx=0.82, relheight=1, relwidth=0.12)
    entry = tk.Entry(frame1, bg='#E7F6B3', font='times 20')
    entry.place(relx=0, relheight=1, relwidth=0.45)

    root.mainloop()
Exemplo n.º 5
0
def main():
    """
        This method controls the flow of the program
    """

    # Show the title and menu to screen
    show_title()
    show_menu()

    # Get the list of categories
    categories = requests.get_categories()

    # Get the list of areas
    areas = requests.get_areas()

    # Get the user menu selection
    while True:
        command = input("Command: ")

        if command == "1":
            list_categories(categories)
        elif command == "2":
            search_meal_by_category(categories)
        elif command == "3":
            search_meal_by_name()
        elif command == "4":
            print("A random meal was selected just for you!")
            display_random_recipe()
        elif command == "5":
            list_areas(areas)
        elif command == "6":
            search_meal_by_area(areas)
        elif command == "7":
            show_menu()
        elif command == "0":
            print("Thank you for dining with us!")
            break
        else:
            print("Not a valid command. Please try again.\n")
Exemplo n.º 6
0
    def setup_ui(self):

        # Create and add the label widgets to the screen
        recipe_lbl = Label(self, text="Recipes:")
        recipe_lbl.grid(sticky=W, pady=10, padx=(10, 0))

        categories_lbl = Label(self, text="Categories:")
        categories_lbl.grid(row=2, sticky=W, pady=(10, 0), padx=(10, 0))

        directions_lbl = Label(self, text="Directions:")
        directions_lbl.grid(row=0, column=2, sticky=W, padx=10, pady=10)

        # Get the categories from the site
        category_list = requests.get_categories()

        # Create the display category list
        display_category_list = ["Select:"]
        for item in category_list:
            display_category_list.append(item.get_category())

        # Create the default value to be displayed for the category list
        default_category = StringVar(self)
        default_category.set(display_category_list[0])

        # Create style to update the OptionMenu's look
        self.set_style()

        # Create the Options Menu widget for displaying the categories
        categories_dropdown = ttk.OptionMenu(self,
                                             default_category,
                                             *display_category_list,
                                             command=self.load_meals,
                                             style="raised.TMenubutton")
        categories_dropdown.grid(row=3, pady=5, padx=(10, 0))
        categories_dropdown.config(width=20)

        # Configure and add the listbox widget to display the recipe names
        self.meal_list_listbox.configure(exportselection=False)
        self.meal_list_listbox.bind("<<ListboxSelect>>", self.load_meal)
        self.meal_list_listbox.grid(row=1, padx=(10, 0), sticky="nw")

        # Create and attach a vertical scrollbar to the recipe listbox widget
        recipe_list_scrollbar = Scrollbar(self,
                                          command=self.meal_list_listbox.yview)
        recipe_list_scrollbar.grid(row=1, column=1, sticky="nsew")
        self.meal_list_listbox["yscrollcommand"] = recipe_list_scrollbar.set

        # Add and configure the textbox to display the recipe directions
        self.directions_text.grid(row=1,
                                  column=2,
                                  columnspan=2,
                                  rowspan=4,
                                  padx=(10, 0),
                                  pady=(0, 10),
                                  sticky=(N, S, E, W))
        self.directions_text.config(wrap="word")

        # Create and attach a vertical scrollbar to the recipe directions widget
        directions_scrollbar = Scrollbar(self,
                                         command=self.directions_text.yview)
        directions_scrollbar.grid(row=1,
                                  column=4,
                                  sticky="nsew",
                                  rowspan=4,
                                  padx=(0, 10),
                                  pady=(0, 10))
        self.directions_text["yscrollcommand"] = directions_scrollbar.set

        # Create and add an exit button
        exit_button = Button(self, text="Exit", command=self.parent.destroy)
        exit_button.grid(row=5, column=3, pady=(0, 10), padx=10, columnspan=2)

        # Set the row and column to expand when user adjusts the screen size
        self.columnconfigure(2, weight=1)
        self.rowconfigure(4, weight=1)
Exemplo n.º 7
0
def get_categories():
    # Get the list of categories
    categories = requests.get_categories()
    return categories