-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
127 lines (102 loc) · 4.87 KB
/
main.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import pandas as pd
import customtkinter as tk
from gui import *
from data_processing import Data
if __name__ == "__main__":
DATA = Data('recipe_db.xlsx')
NUMBER_OF_PORTIONS = 0
# Define window resolution and app name
root = tk.CTk()
root.geometry("1050x510")
root.title("Shopping List Assembler")
# Configuartion of apps grid
for col in range(8):
root.columnconfigure(col, weight=1)
for row in range(20):
root.rowconfigure(row, weight=1)
settings = {
'breakfast' : {
'item_list' : DATA.get_breakfast_list(),
'button_color' : '#3C565B' #teal
},
'intermeal' : {
'item_list' : DATA.get_intermeal_list(),
'button_color' : '#483C32' #oak brown
},
'lunch_main' : {
'item_list' : DATA.get_lunch_main_list(),
'button_color' : '#5E5A80' #pale purple
},
'lunch_filler' : {
'item_list' : DATA.get_lunch_filler_list(),
'button_color' : '#5E5A80' #pale purple
},
'lunch_salad' : {
'item_list' : DATA.get_lunch_salad_list(),
'button_color' : '#5E5A80' #pale purple
},
'dinner' : {
'item_list' : DATA.get_dinner_list(),
'button_color' : '#7F462C' #sepia
},
}
# Build main table
option_menu_objects = {}
week_frame = build_week_frame_table(root,
option_menu_objects,
settings)
week_frame.grid(row=0, column=0, columnspan=8, rowspan=5, padx=10, sticky='nwes')
# Create 'Clear' button
clear_options_button = tk.CTkButton(root,
text="Clear choices",
command=lambda: clear_options_event(option_menu_objects, number_of_portions_menu, textbox),
fg_color='#A93226')
clear_options_button.grid(row=5, column=0, sticky='wesn', padx=10)
# 'Reload Data' button
reload_data_button = tk.CTkButton(root,
text="Reload Data",
command= lambda: DATA.reload_data())
reload_data_button.grid(row=5, column=1, sticky='wesn')
# Texbox prompt
textbox = tk.CTkTextbox(root, corner_radius=0, font=('Consolas', 11))
textbox.configure(state='normal',
text_color='white')
textbox.grid(row=6, column=4, columnspan=4, rowspan=13, sticky='nwe', padx=10)
# Create button generating shopping list
generate_shopping_list_button = tk.CTkButton(root,
text="Generate shopping list",
command=lambda: generate_results_event(data=DATA.data,
option_menu_objects=option_menu_objects,
number_of_portions=NUMBER_OF_PORTIONS,
to_excel=False,
textbox=textbox
),
corner_radius=0 )
generate_shopping_list_button.grid(row=5, column=4, columnspan=4, padx=10, sticky='wes')
# 'Save to excel' button
save_to_excel_button = tk.CTkButton(root,
text="Save to Excel",
command= lambda: generate_results_event(data=DATA.data,
option_menu_objects=option_menu_objects,
to_excel=True),
fg_color='#10793F')
save_to_excel_button.grid(row=19, column=4, padx=10, pady=10, sticky='nw')
# Number of portions menu
def portions_menu_callback(choice):
global NUMBER_OF_PORTIONS
NUMBER_OF_PORTIONS = int(choice)
number_of_portions_label = tk.CTkLabel(root, text='Number of portions:', font=("Arial", 14))
number_of_portions_label.grid(row=6, column=0, sticky='wesn', padx=10)
number_of_portions_menu = tk.CTkOptionMenu(
root,
values= [str(n) for n in range(1,6)],
command=portions_menu_callback,
variable=tk.StringVar(),
corner_radius=0,
anchor='center',
dynamic_resizing=False,
font=('Arial', 14)
)
number_of_portions_menu.set('Choose number of portions')
number_of_portions_menu.grid(row=6, column=1, sticky='we')
root.mainloop()