11import tkinter as tk
22from tkinter import messagebox
3- from PIL import Image , ImageTk
43import sys
54import os
65sys .path .append (os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' )))
1110SECTION_BG = "#550a0a"
1211BTN_RED = "#AA3333"
1312TEXT_WHITE = "#FFFFFF"
14- HIGHLIGHT_COLOR = "#884444" # Color for selected item
13+ HIGHLIGHT_COLOR = "#884444"
1514
1615class POSDashboard (tk .Toplevel ):
1716 def __init__ (self , parent = None ):
@@ -24,11 +23,9 @@ def __init__(self, parent=None):
2423 self .menu_items = load_menu_items ()
2524 self .menu_data = {}
2625 self .organize_menu_data ()
27-
28- # Track selected item for removal
2926 self .selected_product_id = None
3027
31- self . bg_image_original = None
28+ # --- Background (Static PNG) ---
3229 self .bg_photo = None
3330 self .bg_label = tk .Label (self , bg = BG_COLOR )
3431 self .bg_label .place (x = 0 , y = 0 , relwidth = 1 , relheight = 1 )
@@ -55,26 +52,17 @@ def __init__(self, parent=None):
5552 self .frame_checkout .pack (side = "right" , fill = "y" , padx = (5 , 20 ), pady = 20 )
5653 self .frame_checkout .pack_propagate (False )
5754 self .build_checkout_section ()
58- self . bind ( "<Configure>" , self . resize_background )
55+
5956
6057 def load_background (self ):
61- bg_path = "assets/BG.jpg"
58+ bg_path = ( "assets/BG.png" )
6259 if os .path .exists (bg_path ):
6360 try :
64- self .bg_image_original = Image .open (bg_path )
65- self .resize_background (None )
66- except Exception as e :
67- print (f"Error loading background: { e } " )
68-
69- def resize_background (self , event ):
70- if self .bg_image_original :
71- w = self .winfo_width ()
72- h = self .winfo_height ()
73- if w > 0 and h > 0 :
74- resized = self .bg_image_original .resize ((w , h ), Image .Resampling .LANCZOS )
75- self .bg_photo = ImageTk .PhotoImage (resized )
61+ self .bg_photo = tk .PhotoImage (file = bg_path )
7662 self .bg_label .config (image = self .bg_photo )
7763 self .bg_label .lower ()
64+ except Exception as e :
65+ print (f"Error loading background: { e } " )
7866
7967 def organize_menu_data (self ):
8068 self .menu_data = {}
@@ -156,9 +144,8 @@ def add_item_to_order(self, item):
156144 self .refresh_order_display ()
157145
158146 def select_item (self , product_id ):
159- """Selects an item in the order list"""
160147 if self .selected_product_id == product_id :
161- self .selected_product_id = None # Deselect if clicked again
148+ self .selected_product_id = None
162149 else :
163150 self .selected_product_id = product_id
164151 self .refresh_order_display ()
@@ -169,7 +156,6 @@ def remove_selected_item(self):
169156 return
170157
171158 self .current_order .remove_item (self .selected_product_id )
172- # Check if the item is completely gone from the order, if so, clear selection
173159 still_exists = any (i .product_id == self .selected_product_id for i in self .current_order .items )
174160 if not still_exists :
175161 self .selected_product_id = None
@@ -209,7 +195,6 @@ def submit_order_to_kitchen(self):
209195 self .refresh_order_display ()
210196
211197 def build_order_section (self ):
212- # -- Table Number Input --
213198 table_frame = tk .Frame (self .frame_order , bg = SECTION_BG )
214199 table_frame .pack (fill = "x" , pady = (0 , 10 ))
215200
@@ -219,7 +204,6 @@ def build_order_section(self):
219204
220205 tk .Label (self .frame_order , text = "CURRENT ORDER" , font = ("Segoe UI" , 14 , "bold" ), bg = SECTION_BG , fg = "white" ).pack (pady = (0 , 10 ))
221206
222- # Header with Fixed Alignment
223207 hdr = tk .Frame (self .frame_order , bg = SECTION_BG )
224208 hdr .pack (fill = "x" )
225209
@@ -242,13 +226,11 @@ def refresh_order_display(self):
242226 widget .destroy ()
243227
244228 for item in self .current_order .items :
245- # Determine background color based on selection
246229 bg_color = HIGHLIGHT_COLOR if item .product_id == self .selected_product_id else SECTION_BG
247230
248231 row = tk .Frame (self .order_list_frame , bg = bg_color )
249232 row .pack (fill = "x" , pady = 2 )
250233
251- # Make the row clickable
252234 row .bind ("<Button-1>" , lambda e , pid = item .product_id : self .select_item (pid ))
253235
254236 txt_left = f"{ item .quantity } x { item .name } "
@@ -260,7 +242,6 @@ def refresh_order_display(self):
260242 lbl_right = tk .Label (row , text = txt_right , bg = bg_color , fg = "white" , font = ("Segoe UI" , 11 ))
261243 lbl_right .pack (side = "right" , padx = 20 )
262244
263- # Make labels transparent to clicks (pass event to row)
264245 lbl_left .bind ("<Button-1>" , lambda e , pid = item .product_id : self .select_item (pid ))
265246 lbl_right .bind ("<Button-1>" , lambda e , pid = item .product_id : self .select_item (pid ))
266247
@@ -275,7 +256,6 @@ def update_totals(self):
275256 self .lbl_tax_val .config (text = f"${ tax :.2f} " )
276257 self .lbl_total_val .config (text = f"${ total :.2f} " )
277258
278- # --- Checkout Section ---
279259 def build_checkout_section (self ):
280260 tk .Label (self .frame_checkout , text = "CHECKOUT" , font = ("Segoe UI" , 14 , "bold" ), bg = SECTION_BG , fg = "white" ).pack (pady = (0 , 20 ))
281261
@@ -286,25 +266,19 @@ def build_checkout_section(self):
286266
287267 self .lbl_total_val = self .add_total_row ("Total:" , "$0.00" , 22 , bold = True )
288268
289- # Buttons
290-
291- # 1. Send to Kitchen (Bottom)
292269 btn_send = tk .Button (self .frame_checkout , text = "SEND TO\n KITCHEN" , bg = "#CC3333" , fg = "white" ,
293270 font = ("Segoe UI" , 16 , "bold" ), relief = "flat" , height = 3 , cursor = "hand2" ,
294271 command = self .submit_order_to_kitchen )
295272 btn_send .pack (side = "bottom" , fill = "x" , pady = (10 , 0 ))
296273
297- # 2. Control Buttons Container (Above Send)
298274 ctrl_frame = tk .Frame (self .frame_checkout , bg = SECTION_BG )
299275 ctrl_frame .pack (side = "bottom" , fill = "x" , pady = (0 , 10 ))
300276
301- # Cancel Order
302277 btn_cancel = tk .Button (ctrl_frame , text = "CANCEL ORDER" , bg = "#FF5555" , fg = "white" ,
303278 font = ("Segoe UI" , 10 , "bold" ), relief = "flat" , height = 2 , cursor = "hand2" ,
304279 command = self .cancel_order )
305280 btn_cancel .pack (side = "left" , fill = "x" , expand = True , padx = (0 , 5 ))
306281
307- # Remove Item
308282 btn_remove = tk .Button (ctrl_frame , text = "REMOVE ITEM" , bg = "#FF8800" , fg = "white" ,
309283 font = ("Segoe UI" , 10 , "bold" ), relief = "flat" , height = 2 , cursor = "hand2" ,
310284 command = self .remove_selected_item )
0 commit comments