IP Ip

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

INFORMATICS PRACTICES PROJECT

2024-2025

SPORTS EVENT MANAGER


by:
Samyuktha S
Rupesh Skandhan M
0|Page
CERTIFICATE
RECORD OF PROJECT WORK IN INFORMATICS PRACTICES(065)

Certified that this is the bonafide record of project work in

PYTHON done by ………………………………………………………………………………

Reg.No …………………………………… submitted for the Practical examination

held at PSG Public Schools on ……………………………………………. 20……………….

Head of the Department PRINCIPAL

Signature of the Internal Examiner Signature of the External

1|Page
ACKNOWLEDGMENT

It is with pleasure that I find myself penning down these lines to express

my sincere thanks to all those people who helped me a long way in

completing this project.

The harmonious climate in our school provided proper atmosphere for

preparing the project. It was a privilege to have been guided by

Mr. E.H.Sathish kumar

I am also grateful to my classmates who helped me during the

finalization of the project with their constructive criticism and advice.

COIMBATORE

DATE :

2|Page
INDEX

S.NO TOPIC PAGE NO

1 Overview Of Python 4

2 Hardware and Software 6


Requirements

3 Brief Overview of Project 8

4 Need For 9
Computerisation
5 Source Code 10

6 Output 19

7 Bibliography 22

OVERVIEW OF PYTHON

3|Page
Python is a high-level, interpreted, interactive, and object-oriented
scripting language, known for its readability. It frequently uses English
keywords, unlike many other languages that use punctuation, and has
fewer syntactical constructions.

Key Characteristics of Python:


Interpreted: Python is executed at runtime by the interpreter,
eliminating the need for prior compilation. This is similar to languages
like PERL and PHP.

Interactive: You can interact directly with the interpreter at a Python


prompt, allowing for immediate coding and testing.

Object-Oriented: Python supports object-oriented programming,


encapsulating code within objects.

Beginner-Friendly: Python is ideal for beginners, supporting a wide


range of applications from simple text processing to web browsers and
games.

Python Features:
Easy to Learn: With few keywords, a simple structure, and clear syntax,
Python is easy to pick up.

Readable: Python code is clean and easy to read.

Maintainable: Python's source code is straightforward to maintain.

4|Page
Broad Standard Library: Python's extensive library is portable and cross-
platform compatible across UNIX, Windows, and Macintosh.

Interactive Mode: Python supports an interactive mode for real-time


testing and debugging.

Portable: Python runs on various hardware platforms with a consistent


interface.

Extendable: You can add low-level modules to the Python interpreter


to customize and enhance its capabilities.

Database Interfaces: Python provides interfaces to major commercial


databases.

GUI Programming: Python supports GUI applications, which can be


created and ported across multiple systems, including Windows MFC,
Macintosh, and Unix's X Window system.

Scalable: Python offers better structure and support for large programs
compared to shell scripting.

Additional Features:
Supports functional and structured programming methods as well
as object-oriented programming.

Can be used as a scripting language or compiled to byte-code for large


applications.

Provides high-level dynamic data types and supports dynamic type


checking.

Easily integrates with C, C++, COM, ActiveX, CORBA, and Java.

5|Page
HARDWARE & SOFTWARE

REQUIREMENTS

Hardware Requirements:

Processors: Intel Atom® processor or Intel® Core™ i3 processor.


Memory: Minimum 2 GB RAM (4 GB or more recommended for better
performance).

Disk Space: At least 1 GB of free disk space for the Python environment and
project files.

Display: 1024 x 768 resolution monitor (higher resolution


recommended).

Software Requirements:

Operating Systems:
Windows 7 or later
macOS 10.12 (Sierra) or later Linux (any modern distribution)

Python Versions:

Python 2.7.X
Python 3.6.X or later (recommended)

6|Page
Included Development Tools:

Conda: Package management and environment management system.


Conda-env: Tool for creating and managing virtual environments.

Spyder – Python editor


Jupyter Notebook: Web-based interactive computing environment for
creating Jupyter notebooks.

Additional Libraries and Tools:

TKinter: Creating the graphical user interface (GUI).

MySQL Connector: Connecting Python to a MySQL database.

DateTime: Managing date and time operations like match schedules,


deadlines, etc.

SPORTS EVENT MANAGER


7|Page
Brief Overview of Project:

The sports management software allows users to manage athlete registrations


and event participation through a user-friendly GUI built with Tkinter. The interface
lets users input athlete details such as name, class, date of birth, gender, and
admission number. Based on the athlete's date of birth and gender, the system
determines the appropriate event categories and displays available events. Users
can select up to 3 events following certain track and field rules. All athlete data,
including event selections, is saved to a MySQL database, and users can also view
event-wise participant lists
.
Front End: Python using TKinter library for UI purpose
Back End: MYSQL

8|Page
NEED FOR COMPUTERISATION

The need for computerization of sports management software arises from the
increasing complexity and scale of modern sports organizations, tournaments, and
athlete management. Here are some key reasons why computerization is essential:

1. Efficient Data Management: Sports organizations handle vast amounts of


data, including player statistics, schedules, team records, and event details.
Manual data handling is prone to errors, time-consuming, and inefficient.
Computerized systems can store, retrieve, and manage this data seamlessly,
ensuring accuracy and easy access.

2. Enhanced Communication and Collaboration: Computerized sports


management software enables centralized communication between teams,
players, coaches, officials, and organizers. It can notify participants of changes
in schedules, locations, or other important updates instantly, ensuring smooth
coordination.

3. Streamlined Scheduling and Event Planning: Managing schedules for


teams, tournaments, and practice sessions is a critical aspect of sports
management. A computerized system allows for automated scheduling, real-
time updates, and conflict avoidance, saving time and ensuring all
stakeholders are informed.

In summary, computerizing sports management software optimizes the


operations of sports organizations, enhancing efficiency, communication, and
data management, ultimately leading to better performance

SOURCE CODE
9|Page
MYSQL:
Create database sports_db;

Python:
import tkinter as tk
from tkinter import ttk, messagebox
import mysql.connector
from datetime import datetime

app = tk.Tk()
app.title("Sports Management Software")
app.attributes('-fullscreen', True)

# Font settings
font_settings = ("Arial", 16)

# Create style for ttk widgets


style = ttk.Style()
style.configure('TLabel', font=font_settings)
style.configure('TButton', font=font_settings)
style.configure('TRadiobutton', font=font_settings)
style.configure('TCombobox', font=font_settings)

# Left Pane for constant elements


left_pane = tk.Frame(app)
left_pane.pack(side=tk.LEFT, fill=tk.Y)

# Event Wise Students List Button


event_list_button = tk.Button(left_pane, text="Event Wise Students List", command=lambda: open_category_selection(),
font=font_settings)
event_list_button.pack(pady=10)

# Back Button
back_button = tk.Button(left_pane, text="Back", command=lambda: back_to_main(), font=font_settings)
back_button.pack(pady=10)

# Exit Button
exit_button = tk.Button(left_pane, text="Exit", command=app.destroy, font=font_settings)
exit_button.pack(pady=10)

10 | P a g e
# Main frame for the initial page
main_frame = tk.Frame(app)
main_frame.pack(expand=True)

# Error label
error_label = tk.Label(main_frame, text="", font=font_settings, fg="red")
error_label.grid(row=8, column=0, columnspan=2, pady=10)

# Database setup
def setup_database():
try:
conn = mysql.connector.connect(
host='localhost',
user='root',
password='123456',
database='sports_db'
)
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS athletes (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
athlete_class VARCHAR(255),
dob DATE,
admission_no VARCHAR(255),
gender VARCHAR(10),
category VARCHAR(50),
events TEXT
)''')
conn.commit()
except mysql.connector.Error as err:
show_error(str(err))
finally:
if conn.is_connected():
cursor.close()
conn.close()

# Function to go back to the main page


def back_to_main():
main_frame.pack(expand=True) # Show the main frame
clear_category_selection() # Clear the category selection frame if it exists

# Clear category selection frame elements

11 | P a g e
def clear_category_selection():
for widget in app.winfo_children():
if isinstance(widget, tk.Frame) and widget != left_pane and widget != main_frame:
widget.destroy()

# Function to determine category based on DOB


def determine_category(dob):
try:
dob = datetime.strptime(dob, '%Y-%m-%d')
age = (datetime.now() - dob).days // 365
if age < 12:
return 'Under 12'
elif age < 14:
return 'Under 14'
elif age < 17:
return 'Under 17'
elif age < 19:
return 'Under 19'
elif dob.year == 2008: # Exception for athletes born in 2008
return ['Under 17', 'Under 19']
else:
return None
except ValueError:
show_error("DOB must be in YYYY-MM-DD format.")
return None

# Function to get events based on gender and category


def get_events(gender, category):
events = []
if category in ['Under 12', 'Under 14']:
events = ['100mt', '200mt', '400mt', 'shot put', 'long jump', 'high jump', 'relay']
elif category == 'Under 17':
events = ['100mt', '200mt', '400mt', '1500mt', 'shot put', 'long jump', 'high jump', 'javelin', 'discus throw', 'relay']
if gender == 'Male':
events.append('triple jump')
elif category == 'Under 19':
events = ['100mt', '200mt', '400mt', '1500mt', 'shot put', 'long jump', 'high jump', 'javelin', 'discus throw', 'relay']
if gender == 'Male':
events.append('triple jump')
return events

# Function to save athlete data to the database


def save_athlete():

12 | P a g e
name = name_entry.get()
athlete_class = class_entry.get()
dob = dob_entry.get()
admission_no = admission_entry.get()
gender = gender_var.get()
category = category_combobox.get()

calculated_category = determine_category(dob)

if calculated_category is None:
return

# Validate selected category


if isinstance(calculated_category, list): # For 2008 case
if category not in calculated_category:
show_error(f"Selected category '{category}' is not valid for DOB {dob}.")
return
elif category != calculated_category:
show_error(f"Selected category '{category}' does not match the calculated category '{calculated_category}'.")
return

selected_events = [event_listbox.get(event) for event in event_listbox.curselection()]

if not selected_events:
show_error("Please select at least 1 event.")
return

# Relay event exception logic


if "relay" in selected_events:
selected_events.remove("relay")
relay_selected = True
else:
relay_selected = False

track_count = sum(1 for event in selected_events if 'mt' in event)


field_count = sum(1 for event in selected_events if 'put' in event or 'jump' in event)

# Ensure the total selected events respect the maximum constraint


if len(selected_events) > 3:
show_error("You can only select up to 3 events (2 Track and 1 Field, or 2 Field and 1 Track).")
return

# Enforce the 2 Track and 1 Field or 1 Track and 2 Field constraint (for maximum limit)

13 | P a g e
if not ((track_count <= 2 and field_count <= 2) and (track_count + field_count <= 3)):
show_error("You must select either 2 Track and 1 Field or 2 Field and 1 Track, with a maximum of 3 events.")
return

if relay_selected:
selected_events.append("relay") # Add relay back to the list of selected events

events_string = ', '.join(selected_events)

try:
conn = mysql.connector.connect(
host='localhost',
user='root',
password='123456',
database='sports_db'
)
cursor = conn.cursor()
cursor.execute('INSERT INTO athletes (name, athlete_class, dob, admission_no, gender, category, events) VALUES (%s,
%s, %s, %s, %s, %s, %s)',
(name, athlete_class, dob, admission_no, gender, category, events_string))
conn.commit()

# Display success message box after saving athlete data


messagebox.showinfo("Success", "The records have been saved successfully!")
except mysql.connector.Error as err:
show_error(str(err))
finally:
if conn.is_connected():
cursor.close()
conn.close()

reset_fields()

# Function to reset the input fields and clear the error message
def reset_fields():
name_entry.delete(0, tk.END)
class_entry.delete(0, tk.END)
dob_entry.delete(0, tk.END)
admission_entry.delete(0, tk.END)
gender_var.set(None)
category_combobox.set('Select Category')
event_listbox.delete(0, tk.END)
clear_error() # Clears the error message when fields are reset

14 | P a g e
# Function to display error or success messages in the window
def show_error(message, is_error=True):
error_label.config(text=message, fg="red" if is_error else "green")

# Function to clear error message


def clear_error():
error_label.config(text="")

# Function to populate events based on gender and category


def populate_events(event=None):
dob = dob_entry.get()
gender = gender_var.get()

if dob and gender:


category = determine_category(dob)
if category:
if isinstance(category, list): # For 2008 case
category_combobox['values'] = category
category_combobox.set('Select Category')
else:
category_combobox.set(category) # Set the combobox to the determined category

events = get_events(gender, category if isinstance(category, str) else category_combobox.get())


event_listbox.delete(0, tk.END)
for event in events:
event_listbox.insert(tk.END, event)

# Function to open the category selection frame


def open_category_selection():
main_frame.pack_forget() # Hide the main frame

# Create a new frame for category selection


category_frame = tk.Frame(app)
category_frame.pack(expand=True)

tk.Label(category_frame, text="Select Category", font=("Arial", 20)).pack(pady=10)

# Category Combobox
category_combobox = ttk.Combobox(category_frame, values=['Under 12', 'Under 14', 'Under 17', 'Under 19'], state="readonly")
category_combobox.pack(pady=10)

# Button to confirm category selection


confirm_button = tk.Button(category_frame, text="Confirm", font=("Arial", 14), command=lambda:
display_event_buttons(category_combobox.get(), category_frame))

15 | P a g e
confirm_button.pack(pady=10)

# Function to display event buttons for the selected category


def display_event_buttons(selected_category, parent_frame):
for widget in parent_frame.winfo_children():
widget.destroy()

tk.Label(parent_frame, text=f"Events for {selected_category}", font=("Arial", 20)).pack(pady=10)

# Get events based on the selected category


gender = gender_var.get() # Assuming gender is selected somewhere else
events = get_events(gender, selected_category)

# Create buttons for each event


for event in events:
event_button = tk.Button(parent_frame, text=event, font=("Arial", 14), command=lambda e=event: display_participants(e,
selected_category, parent_frame))
event_button.pack(pady=5)

# Back button to return to category selection


back_button = tk.Button(parent_frame, text="Back to Category Selection", font=("Arial", 14), command=lambda:
[parent_frame.pack_forget(), open_category_selection()])
back_button.pack(pady=10)

# Function to get participants for a specific event


def get_participants_for_event(event_name):
try:
conn = mysql.connector.connect(
host='localhost',
user='root',
password='123456',
database='sports_db'
)
cursor = conn.cursor()
cursor.execute("SELECT name FROM athletes WHERE FIND_IN_SET(%s, events)", (event_name,))
rows = cursor.fetchall()

participants = [row[0] for row in rows] # Extract names from the fetched rows
return participants
except mysql.connector.Error as err:
show_error(str(err))
return []
finally:
if conn.is_connected():

16 | P a g e
cursor.close()
conn.close()

# Function to display participants for a selected event in a Treeview


def display_participants(event_name, category, parent_frame):
for widget in parent_frame.winfo_children():
widget.destroy()

tk.Label(parent_frame, text=f"Participants for {event_name} in {category}", font=("Arial", 20)).pack(pady=10)

# Create a Treeview for participants


tree = ttk.Treeview(parent_frame, columns=('Name'), show='headings', height=15)
tree.heading('Name', text='Name')
tree.pack(pady=20)

# Get participants for the selected event


participants = get_participants_for_event(event_name)

for participant in participants:


tree.insert('', 'end', values=(participant,))

# Back button to return to the event list


back_button = tk.Button(parent_frame, text="Back to Event List", font=("Arial", 14), command=lambda:
[parent_frame.pack_forget(), display_event_buttons(category, parent_frame)])
back_button.pack(pady=10)

# Initialize the application


setup_database()

# Create the GUI layout for athlete registration


tk.Label(main_frame, text="Athlete Registration", font=("Arial", 24)).grid(row=0, column=0, columnspan=2, pady=20)

# Athlete Name
tk.Label(main_frame, text="Name:").grid(row=1, column=0, padx=10, pady=10)
name_entry = tk.Entry(main_frame)
name_entry.grid(row=1, column=1)

# Athlete Class
tk.Label(main_frame, text="Class:").grid(row=2, column=0, padx=10, pady=10)
class_entry = tk.Entry(main_frame)
class_entry.grid(row=2, column=1)

# DOB
tk.Label(main_frame, text="DOB (YYYY-MM-DD):").grid(row=3, column=0, padx=10, pady=10)

17 | P a g e
dob_entry = tk.Entry(main_frame)
dob_entry.grid(row=3, column=1)

# Admission No
tk.Label(main_frame, text="Admission No:").grid(row=4, column=0, padx=10, pady=10)
admission_entry = tk.Entry(main_frame)
admission_entry.grid(row=4, column=1)

# Gender Selection
tk.Label(main_frame, text="Gender:").grid(row=5, column=0, padx=10, pady=10)
gender_var = tk.StringVar()
male_radio = tk.Radiobutton(main_frame, text="Male", variable=gender_var, value="Male", command=populate_events)
male_radio.grid(row=5, column=1, sticky=tk.W)
female_radio = tk.Radiobutton(main_frame, text="Female", variable=gender_var, value="Female", command=populate_events)
female_radio.grid(row=5, column=1)

# Category Selection
tk.Label(main_frame, text="Category:").grid(row=6, column=0, padx=10, pady=10)
category_combobox = ttk.Combobox(main_frame, values=['Under 12', 'Under 14', 'Under 17', 'Under 19'], state="readonly")
category_combobox.grid(row=6, column=1)

# Event Listbox
tk.Label(main_frame, text="Select Events:").grid(row=7, column=0, padx=10, pady=10)
event_listbox = tk.Listbox(main_frame, selectmode=tk.MULTIPLE)
event_listbox.grid(row=7, column=1)

# Save Button
save_button = tk.Button(main_frame, text="Save Athlete", command=save_athlete)
save_button.grid(row=8, column=0, columnspan=2, pady=10)

# Start the application


app.mainloop()

18 | P a g e
OUTPUT

First page UI:


 For registration of athletes
 All necessary details in the right side and left for other pages navigation

 Confirmation message for data entry without any errors

19 | P a g e
Second page UI:
 For viewing the event wise student list
 Category selection for event wise student list

 Choosing events for the list of student

20 | P a g e
 Student list is displayed according to the event selected by athletes

MYSQL table :
 MYSQL table where the details of athletes are stored

21 | P a g e
Bibliography

 https://www.geeksforgeeks.org/
 https://www.google.com/

22 | P a g e

You might also like