cs project file (1)
cs project file (1)
INTERNATIONALSCHOOL
Reg.No:
Develop a user-friendly graphical user interface (GUI) using Tkinter for the fitness
tracker application. Establish Database Connectivity:
Enable users to add new fitness activities with details such as activity type, time spent,
distance covered, and calories burned.
Provide functionality to update existing activities with new information.
Allow users to delete activities from the database.
Input Validation:
Implement input validation to ensure all necessary fields are filled before submitting
the data.
Provide user feedback for missing or incorrect input to prevent errors.
Database Operations:
Execute SQL queries to perform CRUD (Create, Read, Update, Delete) operations on
the fitness tracker database.
Ensure data integrity and prevent SQL injection attacks.
Error Handling:
User Interaction:
Design intuitive buttons and input fields to make the application easy to navigate.
Ensure that all interactions with the database provide immediate feedback to the user.
Data Persistence:
Ensure that all data entered by users is reliably stored in the MySQL database.
Allow retrieval and modification of data as needed for updates and deletions.
Application Modularity:
Structure the code to maintain a clear separation between the GUI and database
logic.
Promote code readability and ease of maintenance through well-defined functions
and comments.
Design the application with scalability in mind to allow for future enhancements, such
as additional fitness metrics or advanced data analysis features.
Keep the code modular to facilitate the integration of new features without major
overhauls.
MODULUES AND FILES USED
Modules
1. tkinter
o Used for creating the graphical user interface (GUI).
2. mysql.connector
o Used for connecting to the MySQL database and executing
SQL queries.
3. tkinter.messagebox
o Used for displaying message boxes to the user for alerts
and confirmations.
4. tkinter.simpledialog
o Used for prompting the user to enter data through simple
dialog boxes.
Files
1. main.py
o This will be the main file that initializes the GUI, handles
user interactions, and integrates all components.
2. db_connection.py
o Contains the logic for establishing a connection with the
MySQL database.
o Handles basic CRUD operations and database interactions.
3. gui.py
o Contains the code for the GUI layout and design using
Tkinter.
o Includes functions for creating and arranging widgets.
4. config.py
o Contains configuration details such as database connection
parameters (host, user, password, database name).
SCOPE
User Interface Development:
Database Integration:
Utilize MySQL as the backend database for storing fitness activity data.
Establish secure and reliable database connectivity using mysql.connector.
Create necessary database schemas and tables to store activity
information.
Core Functionalities:
Input Validation:
Ensure all fields are filled before submitting data to the database.
Implement validation checks to prevent invalid data entries.
Provide user feedback for missing or incorrect inputs.Error Handling:
User Feedback:
Configuration Management:
Extensibility:
TECHNOLOGY REQUIREMENTS
HARDWARE:
SOFTWARE:
• OPERATINGSYSTEM:
Windows7orAbove
• ENVIRONMEN: Visual Studios
• LANGUAGE: Python and SQL
• FRONTEND: Pythonversion3.10
• BACKEND: SQL Workbench
SOURCE CODE
USE fitness_tracker;
);
import tkinter as tk
from tkinter import messagebox, ttk
import mysql.connector
# Database connection
conn = mysql.connector.connect(
host="localhost",
user="your_username",
password="your_password",
database="fitness_tracker"
)
cursor = conn.cursor()
# GUI setup
root = tk.Tk()
root.title("Fitness Tracker")
def refresh_treeview():
for row in tree.get_children():
tree.delete(row)
cursor.execute("SELECT * FROM activities")
for row in cursor.fetchall():
tree.insert("", "end", values=row)
def delete_activity():
selected_item = tree.selection()
if not selected_item:
messagebox.showwarning("Selection Error", "Please select an
activity to delete")
return
item = tree.item(selected_item)
activity_id = item['values'][0]
query = "DELETE FROM activities WHERE id = %s"
cursor.execute(query, (activity_id,))
conn.commit()
messagebox.showinfo("Success", "Activity deleted successfully")
refresh_treeview()
# Buttons
tk.Button(root, text="Add Activity", command=add_activity).grid(row=3,
column=0)
tk.Button(root, text="Delete Activity",
command=delete_activity).grid(row=3, column=1)
1. User-Friendly Interface:
o Designed a straightforward and intuitive GUI that
allows users to easily enter, update, and delete
fitness activity data.
2. Efficient Database Management:
o Utilized MySQL to store, retrieve, and manage
fitness data, ensuring reliable data persistence
and integrity.
3. Comprehensive Functionality:
o Implemented core functionalities including adding
new activities, updating existing records, and
deleting activities, all while providing real-time
feedback to the user.
4. Input Validation and Error Handling:
o Ensured robust input validation to prevent
incorrect data entries and implemented error
handling mechanisms to manage potential issues
gracefully.
5. Modular and Maintainable Code:
o Organized the project into distinct modules,
promoting code readability, maintainability, and
ease of future enhancements.
6. Scalability and Extensibility:
Designed the application with scalability in mind,
o
laying a strong foundation for future feature
additions and improvements.
7. Secure Data Operations:
o Implemented measures to ensure secure data
operations, protecting the application from
common vulnerabilities like SQL injection.
BIBILIOGRAPHY:
www.w3school.com
www.youtube.com/techwithtim
www.openai.com
www.blackboxai.com
www.youtube,com/amitthinks
www.greeksforgreeks.org