-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestaurantMenuEditor.py
More file actions
40 lines (30 loc) · 921 Bytes
/
RestaurantMenuEditor.py
File metadata and controls
40 lines (30 loc) · 921 Bytes
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
import csv
from tkinter import *
from tkinter import messagebox
def write_to_csv():
item = item_entry.get()
price = price_entry.get()
# Prepare the data for the CSV
data = [[item, price]]
# Write the data to a CSV file
with open('menu.csv', 'a', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerows(data)
# Clear the entry fields once submit button has been clicked
item_entry.delete(0, END)
price_entry.delete(0, END)
messagebox.showinfo("Success", "Menu Updated!")
# main window
root = Tk()
# entry fields
Label(root, text="Enter Food Name:").pack()
item_entry = Entry(root)
item_entry.pack()
Label(root, text="Enter Food Price:").pack()
price_entry = Entry(root)
price_entry.pack()
# submit button
submit_button = Button(root, text="Submit", command=write_to_csv)
submit_button.pack()
# Start the main loop
root.mainloop()