Home
Home
cart = []
class videogame:
def __init__(self, root):
self.root = root
self.root.title("Neel Games Store")
self.root.geometry("1550x840+0+0")
self.root.state("zoomed")
self.root.resizable(0, 0)
self.main()
@staticmethod
def connect_to_db():
return mysql.connector.connect(
host="localhost",
user="root",
password="Neel_123",
database="mydata"
)
def place_order(self):
db = self.connect_to_db()
cursor = db.cursor()
try:
for item in cart:
cursor.execute(
"INSERT INTO cart_item (game_name, price) VALUES (%s, %s)",
(item['name'], item['price'])
)
db.commit()
messagebox.showinfo("Order", "Order placed successfully!")
cart.clear() # Clear the cart after placing the order
except Exception as e:
db.rollback()
messagebox.showerror("Error", f"Failed to place order: {str(e)}")
finally:
cursor.close()
db.close()
def view_cart(self):
cartFrame = Frame(self.root, width=1230, height=840, bg="#333333")
cartFrame.place(x=300, y=0)
y_position = 120
total = 0
y_position += 50
total += item["price"]
def main(self):
main_frame = Frame(self.root, width=300, height=840, bg="#1C1C1C")
main_frame.place(x=0, y=0)
games = [
{"name": "Resident Evil 8", "price": 2399, "image": "C:/Users/NEEL
PATEL/OneDrive/Desktop/project images/story_game_img6.jpg", "x": 50, "y": 130},
{"name": "A Plague Tale: Requiem", "price": 2299, "image":
"C:/Users/NEEL PATEL/OneDrive/Desktop/project images/story_game_img2.jpg", "x":
410, "y": 130},
{"name": "Red Dead Redemption 2", "price": 3199, "image":
"C:/Users/NEEL PATEL/OneDrive/Desktop/project images/rpg_game_img4.jpg", "x": 780,
"y":130}
]
def open_browser(self):
browser(self.root)
def open_feedback(self):
Feedback(self.root)
def open_login(self):
login_page(self.root)
def open_library(self):
library(self.root)
if __name__ == "__main__":
root = Tk()
obj = videogame(root)
root.mainloop()