-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpay.py
More file actions
109 lines (90 loc) · 3.42 KB
/
pay.py
File metadata and controls
109 lines (90 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from tkinter import *
import tkinter as tk
from PIL import Image, ImageTk
from dbconnect import db
import subprocess
import sys
# Get table number from command line arguments
table_number = sys.argv[1] if len(sys.argv) > 1 else "N/A"
def create_payment_button(window, text, x, y):
return Button(window,
text=text,
font=("Arial", 22, "bold"),
bg="orange",
fg="#333333",
width=15,
height=2,
relief="raised",
borderwidth=3,
cursor="hand2",
activebackground="#f0f0f0")
def handle_payment(method):
print(f"Processing {method} payment...")
# Read table number from current_user.txt
try:
with open("current_user.txt", "r") as f:
user_info = f.read().strip().split(',')
table_number = user_info[2] # Table number is the third element
except:
table_number = "N/A"
root.destroy()
if method == "UPI":
subprocess.Popen(["python", "upi_payment.py"])
elif method == "Card":
subprocess.Popen(["python", "cardpayment.py"])
else:
subprocess.Popen(["python", "order_status.py", table_number])
root = tk.Tk()
root.title("Feasto: Payment Options")
root.state('zoomed')
# Get the screen width and height
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
# Background setup
bg_image = Image.open("images/restobg3.png")
bg_image = bg_image.resize((screen_width, screen_height), Image.LANCZOS)
bg_photo = ImageTk.PhotoImage(bg_image)
canvas = tk.Canvas(root, width=screen_width, height=screen_height)
canvas.pack(fill="both", expand=True)
canvas.create_image(0, 0, image=bg_photo, anchor="nw")
# After canvas creation and before title
# Add user profile button
user_icon_size = 150
user_icon_x = user_icon_size // 2 + 20
user_icon_y = user_icon_size // 2 + 20
# Load and resize the user icon image
try:
user_icon = Image.open("images/user.png").resize((user_icon_size, user_icon_size))
user_photo = ImageTk.PhotoImage(user_icon)
except:
print("User icon image not found, creating placeholder")
user_icon = Image.new("RGB", (user_icon_size, user_icon_size), "gray")
user_photo = ImageTk.PhotoImage(user_icon)
# Create label for the user icon
user_label = tk.Label(root, image=user_photo, cursor="hand2", bg="black")
user_label.image = user_photo
user_label.place(x=20, y=20)
def open_user():
root.destroy()
subprocess.Popen(["python", "user.py", "pay", table_number])
user_label.bind("<Button-1>", lambda event: open_user())
# Title
canvas.create_text(755, 80, text="Select Payment Method",
font=("Arial", 35, "bold"), fill="white")
# Create semi-transparent rectangle
canvas.create_rectangle(250, 150, 1300, 600,
fill="grey",
stipple='gray50')
# Payment method buttons with improved design
upi_btn = create_payment_button(root, "UPI Payment", 0, 0)
upi_btn.configure(command=lambda: handle_payment("UPI"))
upi_btn.place(x=775, y=300, anchor="center")
card_btn = create_payment_button(root, "Card Payment", 0, 0)
card_btn.configure(command=lambda: handle_payment("Card"))
card_btn.place(x=775, y=420, anchor="center")
'''
cash_btn = create_payment_button(root, "Cash Payment", 0, 0)
cash_btn.configure(command=lambda: handle_payment("Cash"))
cash_btn.place(x=775, y=500, anchor="center")
'''
root.mainloop()