-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSTART.py
86 lines (70 loc) · 3.17 KB
/
START.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import tkinter as tk
import csv
from tkinter import messagebox
def load_data(filename):
data = {}
with open(filename, 'r', newline='', encoding='utf-8') as file:
reader = csv.DictReader(file)
for row in reader:
data[row['name']] = {
'ingredients': row['ingredients'],
'diet': row['diet'],
'prep_time': int(row['prep_time']),
'cook_time': int(row['cook_time']),
'flavor_profile': row['flavor_profile'],
'course': row['course'],
'state': row['state'],
'region': row['region']
}
return data
def search_item():
item_name = entry.get().strip()
if item_name in food_data:
details = food_data[item_name]
diet_details = "Veg" if details["diet"] == "vegetarian" else "Non-Veg"
prep_cook_time = details["prep_time"] + details["cook_time"]
if 20 <= prep_cook_time <= 40:
course_details = "Fast Food"
else:
course_details = details["course"]
region_details = "North Indian Dish" if details["region"] in ["North", "West", "East"] else "South Indian Dish"
flavor_details = ""
if details["flavor_profile"] == "-1" :
#print("hi")
flavor_details += "Diabetic Friendly"
if "flour" in details["ingredients"].lower() or "Maida" in details["ingredients"].lower():
flavor_details += ", Baked Item"
# Check for protein-rich ingredients
protein_rich_ingredients = ["beans", "chana", "dal", "paneer", "rice", "lentils"]
if any(ingredient in details["ingredients"].lower() for ingredient in protein_rich_ingredients):
if flavor_details:
flavor_details += ", Protein Rich"
else:
flavor_details = "Protein Rich"
# Combine all details into a single string
if not flavor_details:
all_details = f"{item_name} - {region_details}, {diet_details}, {course_details}, {details['state']}, {details['flavor_profile']}"
elif len(flavor_details.split(", ")) == 1:
all_details = f"{item_name} - {region_details}, {diet_details}, {course_details}, {flavor_details}"
else:
all_details = f"{item_name} - {region_details}, {diet_details}, {course_details}, {flavor_details}"
# Remove unnecessary commas and add appropriate commas
all_details = all_details.replace(", ,", ",").strip(", ")
messagebox.showinfo("Item Details", all_details)
else:
messagebox.showerror("Error", "Item not found in the dataset.")
# Load data from CSV file
data_file = 'DATA.csv'
food_data = load_data(data_file)
# Create Tkinter GUI
root = tk.Tk()
root.title("Food Item Details")
frame = tk.Frame(root)
frame.pack(padx=20, pady=20)
label = tk.Label(frame, text="Enter item name:")
label.grid(row=0, column=0)
entry = tk.Entry(frame)
entry.grid(row=0, column=1)
surf_button = tk.Button(frame, text="Surf Item", command=search_item)
surf_button.grid(row=1, columnspan=2, pady=10)
root.mainloop()