Overview
The application allows the user to:
Insert a new game
Update an existing game
Delete a game by its number
Search for games by name
Display all games
Clear input fields
Modules Used
Module Purpose
[Link] Connect and interact with the MySQL database
tkinter Create GUI components
[Link] Use themed widgets like modern-looking buttons
messagebox Show popup messages for errors, success, etc.
DATABASE CONNECTION
python
CopyEdit
def create_connection():
Tries to connect to a MySQL database called project_26 using user root and
password Aditya@2008.
If the connection fails, it shows an error message.
UTILITY FUNCTIONS
clear_entries()
Clears all input fields (Game Number, Name, Price, Rating).
show_message(title, message, kind)
Displays a popup message. Uses info, warning, or error.
DATABASE OPERATIONS
insert_game()
Reads input values.
Validates numeric inputs.
Inserts a new game record into the Game table.
Shows success or error message.
Refreshes the game list.
delete_game()
Deletes the game with the specified Game Number.
Shows success or "not found" message.
Refreshes list.
search_game()
Searches for games that contain the given name.
Displays them in the listbox.
update_game()
Updates a game's name, price, and rating based on its number.
Shows appropriate message and refreshes the list.
show_games()
Fetches all games from the database.
Displays them in a formatted way inside the listbox.
format_display(row)
Formats a game record for display in the listbox:
Example:
yaml
CopyEdit
G_No: 1 | Name: Minecraft | Price: ₹1500 | Rating: 9/10
GUI SETUP
Tkinter Window
Fixed size (700x600), white background.
Title: "🎮 Game Shop Manager"
Input Fields
Labels and entry fields for:
o Game Number
o Game Name
o Price
o Rating
Buttons (Styled)
Buttons created with colors and styles using [Link].
Each button tied to a function (insert_game, update_game, etc.)
Listbox with Scrollbar
Displays the game records.
Uses a Courier New monospaced font for alignment.
Vertical scrollbar linked to the listbox.
DATABASE TABLE (Expected)
The code assumes a MySQL table like:
sql
CopyEdit
CREATE TABLE Game (
G_No INT PRIMARY KEY,
G_Name VARCHAR(100),
Price INT,
Rating INT
);
Flow When App Runs
1. Connects to DB.
2. Loads all games (show_games()).
3. User can interact with the UI using buttons.
4. Listbox shows live updates based on actions.