Python-Menu/order_screen.py
2025-12-07 18:19:21 +07:00

38 lines
1.3 KiB
Python

import tkinter as tk
from tkinter import ttk, messagebox
from database import connect
class PembeliMenu(tk.Frame):
def __init__(self, parent, controller):
super().__init__(parent)
self.controller = controller
self.pack(fill="both", expand=True)
tk.Label(self, text="MENU CAFE", font=("Arial", 18, "bold")).pack(pady=20)
self.tree = ttk.Treeview(self, columns=("nama","kategori","harga","stok"), show="headings")
self.tree.heading("nama", text="Nama")
self.tree.heading("kategori", text="Kategori")
self.tree.heading("harga", text="Harga")
self.tree.heading("stok", text="Stok")
self.tree.pack(fill="both", expand=True)
tk.Button(self, text="Pesan", command=self.pesan).pack(pady=10)
self.load_menu()
def load_menu(self):
db = connect()
cur = db.cursor()
cur.execute("SELECT nama, kategori, harga, stok FROM menu")
for row in cur.fetchall():
self.tree.insert("", tk.END, values=row)
db.close()
def pesan(self):
item = self.tree.selection()
if not item:
messagebox.showwarning("Pilih Item", "Pilih menu yang ingin dipesan")
return
messagebox.showinfo("Pesanan", "Menu berhasil ditambahkan ke pesanan!")