UI Login
This commit is contained in:
parent
164c5a7e8a
commit
da22a9bead
62
main.py
62
main.py
@ -274,4 +274,64 @@ def apply_discounts_and_promo(cart_items, promo_code=None):
|
||||
'promo_code': promo_applied,
|
||||
'promo_discount': round(promo_discount,2),
|
||||
'total': round(total,2)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# wilayah UI (universitas indonesia)
|
||||
|
||||
|
||||
|
||||
class App:
|
||||
def __init__(self, root):
|
||||
self.root = root
|
||||
self.root.title("Cafe App")
|
||||
self.session = None
|
||||
self.img_cache = {}
|
||||
self.setup_ui()
|
||||
|
||||
def setup_ui(self):
|
||||
self.root.geometry("1000x650")
|
||||
self.root.resizable(False, False)
|
||||
self.login_frame()
|
||||
|
||||
|
||||
# windah batubara
|
||||
|
||||
# tampilan login
|
||||
|
||||
def login_frame(self):
|
||||
for w in self.root.winfo_children():
|
||||
w.destroy()
|
||||
frame = ttk.Frame(self.root, padding=20)
|
||||
frame.pack(expand=True)
|
||||
|
||||
ttk.Label(frame, text="LOGIN", font=("Arial", 24)).grid(row=0, column=0, columnspan=2, pady=10)
|
||||
|
||||
ttk.Label(frame, text="Username:").grid(row=1, column=0, sticky='e', pady=5)
|
||||
self.username_var = tk.StringVar()
|
||||
ttk.Entry(frame, textvariable=self.username_var, width=30).grid(row=1, column=1, pady=5)
|
||||
|
||||
ttk.Label(frame, text="Password:").grid(row=2, column=0, sticky='e', pady=5)
|
||||
self.password_var = tk.StringVar()
|
||||
ttk.Entry(frame, textvariable=self.password_var, show="*", width=30).grid(row=2, column=1, pady=5)
|
||||
|
||||
ttk.Button(frame, text="Login", command=self.handle_login).grid(row=3, column=0, columnspan=2, pady=12)
|
||||
ttk.Button(frame, text="Run Demo Tests (seed data)", command=self.run_demo_tests).grid(row=4,column=0,columnspan=2,pady=6)
|
||||
|
||||
def handle_login(self):
|
||||
u = self.username_var.get().strip()
|
||||
p = self.password_var.get().strip()
|
||||
if not u or not p:
|
||||
messagebox.showwarning("Input", "Masukkan username & password")
|
||||
return
|
||||
user = authenticate(u,p)
|
||||
if not user:
|
||||
messagebox.showerror("Gagal", "Username atau password salah")
|
||||
return
|
||||
self.session = user
|
||||
messagebox.showinfo("Sukses", f"Login berhasil sebagai {user['role']}")
|
||||
self.dashboard_frame()
|
||||
Loading…
x
Reference in New Issue
Block a user