Compare commits
2 Commits
94e45a7aad
...
e8edfe939f
| Author | SHA1 | Date | |
|---|---|---|---|
| e8edfe939f | |||
| 17bdf516b3 |
@ -5,6 +5,8 @@ import sqlite3
|
||||
import datetime
|
||||
import os
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# ================= DATABASE CONNECT =================
|
||||
def connect():
|
||||
return sqlite3.connect("cafe.db")
|
||||
@ -124,17 +126,26 @@ class PembeliMenu:
|
||||
card.grid_propagate(False)
|
||||
|
||||
try:
|
||||
filename = os.path.basename(gambar) if gambar else None
|
||||
img_path = os.path.join("aset", filename) if filename else None
|
||||
if img_path and os.path.exists(img_path):
|
||||
img = Image.open(img_path).resize((140, 90))
|
||||
photo = ImageTk.PhotoImage(img)
|
||||
self.images.append(photo)
|
||||
tk.Label(card, image=photo).pack(pady=5)
|
||||
else:
|
||||
tk.Label(card, text="[No Image]", height=6).pack()
|
||||
except Exception:
|
||||
tk.Label(card, text="Error Img", height=6).pack()
|
||||
if not gambar:
|
||||
raise ValueError("gambar kosong")
|
||||
|
||||
# gambar dari DB sudah mengandung 'aset/...'
|
||||
img_path = os.path.join(BASE_DIR, gambar)
|
||||
|
||||
if not os.path.exists(img_path):
|
||||
raise FileNotFoundError(img_path)
|
||||
|
||||
img = Image.open(img_path)
|
||||
img = img.resize((140, 90), Image.Resampling.LANCZOS)
|
||||
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=f"Rp {harga:,.0f}").pack(pady=2)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user