Compare commits

..

No commits in common. "e8edfe939ffe72849285f13f3b635dd1568617fd" and "94e45a7aad315f01173c35336a2257d44c056724" have entirely different histories.

View File

@ -5,8 +5,6 @@ import sqlite3
import datetime import datetime
import os import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# ================= DATABASE CONNECT ================= # ================= DATABASE CONNECT =================
def connect(): def connect():
return sqlite3.connect("cafe.db") return sqlite3.connect("cafe.db")
@ -126,26 +124,17 @@ class PembeliMenu:
card.grid_propagate(False) card.grid_propagate(False)
try: try:
if not gambar: filename = os.path.basename(gambar) if gambar else None
raise ValueError("gambar kosong") img_path = os.path.join("aset", filename) if filename else None
if img_path and os.path.exists(img_path):
# gambar dari DB sudah mengandung 'aset/...' img = Image.open(img_path).resize((140, 90))
img_path = os.path.join(BASE_DIR, gambar) photo = ImageTk.PhotoImage(img)
self.images.append(photo)
if not os.path.exists(img_path): tk.Label(card, image=photo).pack(pady=5)
raise FileNotFoundError(img_path) else:
tk.Label(card, text="[No Image]", height=6).pack()
img = Image.open(img_path) except Exception:
img = img.resize((140, 90), Image.Resampling.LANCZOS) tk.Label(card, text="Error Img", height=6).pack()
photo = ImageTk.PhotoImage(img)
self.images.append(photo)
tk.Label(card, image=photo).pack(pady=5)
except Exception as e:
print("IMG ERROR:", e)
tk.Label(card, text="No Image", height=6).pack()
tk.Label(card, text=nama, font=("Arial", 10, "bold"), wraplength=160).pack() tk.Label(card, text=nama, font=("Arial", 10, "bold"), wraplength=160).pack()
tk.Label(card, text=f"Rp {harga:,.0f}").pack(pady=2) tk.Label(card, text=f"Rp {harga:,.0f}").pack(pady=2)