Merge branch 'main' of https://git-eng.ukwms.ac.id/5803025001/Python-Menu
This commit is contained in:
commit
17bdf516b3
@ -5,6 +5,8 @@ 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")
|
||||||
@ -124,17 +126,26 @@ class PembeliMenu:
|
|||||||
card.grid_propagate(False)
|
card.grid_propagate(False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
filename = os.path.basename(gambar) if gambar else None
|
if not gambar:
|
||||||
img_path = os.path.join("aset", filename) if filename else None
|
raise ValueError("gambar kosong")
|
||||||
if img_path and os.path.exists(img_path):
|
|
||||||
img = Image.open(img_path).resize((140, 90))
|
# 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)
|
photo = ImageTk.PhotoImage(img)
|
||||||
|
|
||||||
self.images.append(photo)
|
self.images.append(photo)
|
||||||
tk.Label(card, image=photo).pack(pady=5)
|
tk.Label(card, image=photo).pack(pady=5)
|
||||||
else:
|
|
||||||
tk.Label(card, text="[No Image]", height=6).pack()
|
except Exception as e:
|
||||||
except Exception:
|
print("IMG ERROR:", e)
|
||||||
tk.Label(card, text="Error Img", height=6).pack()
|
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)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user