In this article, we will create Event Management System Project in Python with source code. Using this event management system, one can easily maintain ticket bookings for different events. This is a GUI project and we have created different files and modules to organize the different functions used in this system.
Features of Event Management System Project in Python
- The app will open, and there will be six buttons- Book Ticket, Create Event, View Tickets, View Events, Cancel Ticket, and Quit.
- Auto-generated ticket and event ID
- Database connectivity using SQLite
- GUI features using tkinter
- Exception Handling
- Simple UI
Code for Event Management System Project in Python
There are 9 different files to organize the code and keep codes shorter. You need to keep all files in one folder only. We have used the functions and modules approach for a better understanding of the code and structure of the Event management system.
1. main.py
This is the driver file of our Event Management System Project in Python. This works as the center files where all the GUI files and modules meet to work as a single application.
from tkinter import * from Book import Book from CreateEvent import CreateEvent from ViewTickets import ViewTickets from ViewEvents import ViewEvents from CancelTicket import CancelTicket top = Tk() top.geometry('415x450') top.title('Event Management: CopyAssignment') Button(top, text='Book Ticket', bg='green', fg='white', width=12, font=('Arial', 18), command=lambda: Book()).grid(row=0, column=0, padx=25, pady=30) Button(top, text='Create Event', bg='green', fg='white', width=12, font=('Arial', 18), command=lambda:CreateEvent()).grid(row=0, column=1) Button(top, text='View Tickets', bg='green', fg='white', width=12, font=('Arial', 18), command=lambda:ViewTickets()).grid(row=1, pady=20, column=0) Button(top, text='View Events', bg='green', fg='white', width=12, font=('Arial', 18), command=lambda:ViewEvents()).grid(row=1, column=1) Button(top, text='Cancel Ticket', bg='green', fg='white', width=12, font=('Arial', 18), command=lambda: CancelTicket()).grid(row=2, pady=25, column=0) Button(top, text='Quit App', bg='green', fg='white', width=12, font=('Arial', 18), command=lambda: top.destroy()).grid(row=2, column=1) Label(top, text='Thank you for choosing\nCopyAssignment', font=('Arial', 24)).grid(row=3, column=0, columnspan=2) top.mainloop()
2. Message.py
This is a 3-line code file that is used to show messages to the user. This is called in Book.py, CreateEvent.py, and CancelTicket.py.
from tkinter import messagebox def show_message(title, message): messagebox.showerror(title, message)
3. GenerateNewCode.py
This is a 5-line simple code to generate and return an 8-line random password which we have used as a ticket id or event id.
import random import string def random_id(): letters = string.ascii_lowercase return ''.join(random.choice(letters) for i in range(8))
4. DataBase.py
As the name suggests this module is used to handle the database for the whole application. Our Event Management System Project in Python is a simple representation of a CRUD app in Python because we do all 4 tasks i.e. Create, Read, Update, and Delete operations. In our app, we have created one database and 2 tables. We have fetched the database and deleted it as well. The update is not so tough and if you want then you are encouraged to implement the Update operation and use it to update the database like updating the customer name of tickets, the date and time of tickets and events, etc.
import sqlite3 def EventDetails(): conn = sqlite3.connect('event_database.db') cursor = conn.cursor() cursor.execute("CREATE TABLE IF NOT EXISTS event_details (event_name TEXT, event_id TEXT PRIMARY KEY, event_date TEXT, event_time TEXT, event_duration Text)") cursor.execute('SELECT * FROM event_details') event_details = cursor.fetchall() event_names = [] event_ids = [] event_dates = [] event_times = [] event_durations = [] conn.close() for i in event_details: event_names.append(i[0]) event_ids.append(i[1]) event_dates.append(i[2]) event_times.append(i[3]) event_durations.append(i[4]) return event_names, event_ids, event_dates, event_times, event_durations, event_details def TicketDetails(): conn = sqlite3.connect('event_database.db') cursor = conn.cursor() cursor.execute("CREATE TABLE IF NOT EXISTS ticket_details (customer_name TEXT, ticket_id TEXT PRIMARY KEY, event_name TEXT, event_id TEXT, event_date TEXT, event_time TEXT, duration Text)") cursor.execute('SELECT * FROM ticket_details') ticket_details = cursor.fetchall() customer_names = [] ticket_ids = [] event_names = [] event_ids = [] event_dates = [] event_times = [] event_durations = [] conn.close() for i in ticket_details: customer_names.append(i[0]) ticket_ids.append(i[1]) event_names.append(i[2]) event_ids.append(i[3]) event_dates.append(i[4]) event_times.append(i[5]) event_durations.append(i[6]) return customer_names, ticket_ids, event_names, event_ids, event_dates, event_times, event_durations, ticket_details def BookTicket(customer_name, ticket_id, event_name): event_names = EventDetails()[0] event_ids = EventDetails()[1] event_dates = EventDetails()[2] event_times = EventDetails()[3] event_durations = EventDetails()[4] event_index = event_names.index(event_name) event_id = event_ids[event_index] event_date = event_dates[event_index] event_time = event_times[event_index] event_duration = event_durations[event_index] try: conn = sqlite3.connect("event_database.db") cursor = conn.cursor() cursor.execute("INSERT INTO ticket_details (customer_name, ticket_id, event_name, event_id, event_date, event_time, duration) VALUES (?, ?, ?, ?, ?, ?, ?)", (customer_name, ticket_id, event_name, event_id, event_date, event_time, event_duration)) conn.commit() conn.close() return 'Success' except sqlite3.Error as e: return e finally: conn.close() def CreateNewEvent(event_name, event_id, event_date, event_time, event_duration): try: conn = sqlite3.connect("event_database.db") cursor = conn.cursor() cursor.execute("INSERT INTO event_details (event_name, event_id, event_date, event_time, event_duration) VALUES (?, ?, ?, ?, ?)", (event_name, event_id, event_date, event_time, event_duration)) conn.commit() conn.close() return 'Success' except sqlite3.Error as e: return e finally: conn.close() def DeleteTicket(ticket_id): try: conn = sqlite3.connect("event_database.db") cursor = conn.cursor() cursor.execute("DELETE FROM ticket_details WHERE ticket_id = ?", (ticket_id,)) conn.commit() conn.close() return 'Success' except sqlite3.Error as e: return e finally: conn.close()
5. Book.py
This module or Python file is used to create a GUI using which a user can book a new ticket from the available events.
from tkinter import * from GenerateNewCode import random_id from DataBase import TicketDetails from DataBase import EventDetails from DataBase import BookTicket from Message import show_message def Book(): ticket_ids = TicketDetails()[1] event_names_list = EventDetails()[0] top1 = Tk() top1.geometry('300x280') top1.title('Book ticket') customer_name = StringVar(top1) ticket_id = StringVar(top1) event_name = StringVar(top1) event_name.set('Select event') while True: new_ticket_id = random_id() if new_ticket_id not in ticket_ids: ticket_id.set(new_ticket_id) break continue def BookNow(): if len(customer_name.get())<5: show_message('Error', 'Enter valid details') return booking_status = BookTicket(customer_name.get(), ticket_id.get(), event_name.get()) if booking_status == 'Success': show_message('Success', 'booking successful') return else: show_message('Error', booking_status) Label(top1, text='Enter details', font=('Arial', 14)).grid(row=0, column=0, padx=10, pady=10, columnspan=2) Label(top1, text='Name', font=('Arial', 12)).grid(row=1, column=0, padx=10, pady=10, sticky='w') Entry(top1, textvariable=customer_name).grid(row=1, column=1) Label(top1, text='Ticket Id', font=('Arial', 12)).grid(row=2, column=0, padx=10, pady=10, sticky='w') Entry(top1, textvariable=ticket_id, state='disabled').grid(row=2, column=1) Label(top1, text='Event', font=('Arial', 12)).grid(row=3, column=0, padx=10, sticky='w', pady=10) OptionMenu(top1, event_name, *event_names_list).grid(row=3, column=1) Button(top1, text='Confirm', bg='green', fg='white', font=('Arial', 17), width=9, command=lambda:BookNow()).grid(row=4, column=1, pady=10) top1.mainloop()
6. CreateEvent.py
This module of the Event Management System Project in Python is used to create a GUI using which a user can add a new event to the list of available events.
from tkinter import * from GenerateNewCode import random_id from DataBase import EventDetails from DataBase import CreateNewEvent from Message import show_message from tkcalendar import DateEntry from datetime import date def CreateEvent(): event_ids = EventDetails()[1] top2 = Tk() top2.geometry('300x350') top2.title('Create new Event') event_name = StringVar(top2) event_id = StringVar(top2) event_date = StringVar(top2) event_date.set(date.today()) event_time = StringVar(top2) event_duration = StringVar(top2) while True: new_event_id = random_id() if new_event_id not in event_ids: event_id.set(new_event_id) break continue def CreateNow(): if len(event_name.get())<5: show_message('Error', 'Enter valid details') return event_status = CreateNewEvent(event_name.get(), event_id.get(), event_date.get(), event_time.get(), event_duration.get()) if event_status == 'Success': show_message('Success', 'Event created successfully') return else: show_message('Error', event_status) Label(top2, text='Enter details', font=('Arial', 14)).grid(row=0, column=0, padx=10, pady=10, columnspan=2) Label(top2, text='Event Name', font=('Arial', 12)).grid(row=1, column=0, padx=10, pady=10, sticky='w') Entry(top2, textvariable=event_name).grid(row=1, column=1) Label(top2, text='Event Id', font=('Arial', 12)).grid(row=2, column=0, padx=10, pady=10, sticky='w') Entry(top2, textvariable=event_id, state='disabled').grid(row=2, column=1) Label(top2, text='Event Date', font=('Arial', 12)).grid(row=3, column=0, padx=10, sticky='w', pady=10) DateEntry(top2, selectmode='day', year=2023, month=1, day=25, textvariable=event_date).grid(row=3, column=1) Label(top2, text='Event Time(24hrs)', font=('Arial', 12)).grid(row=4, column=0, padx=10, pady=10, sticky='w') Entry(top2, textvariable=event_time).grid(row=4, column=1) Label(top2, text='Event Duration', font=('Arial', 12)).grid(row=5, column=0, padx=10, pady=10, sticky='w') Entry(top2, textvariable=event_duration).grid(row=5, column=1) Button(top2, text='Submit', bg='green', fg='white', font=('Arial', 17), width=9, command=lambda:CreateNow()).grid(row=6, column=0, pady=10, columnspan=2) top2.mainloop()
7. ViewTickets.py
This module is used to create a GUI using which a user can view the booked tickets of any available event after selecting the specific event.
from tkinter import * from DataBase import EventDetails from DataBase import TicketDetails def ViewTickets(): top4 = Tk() top4.geometry('480x400') top4.title('View tickets') event_names_list = EventDetails()[0] event_name = StringVar(top4) event_name.set('Select event') def ShowTickets(): Label(top4, text="Customer Name").grid(row=3, column=0, padx=10, pady=10) Label(top4, text="Ticket ID").grid(row=3, column=1, padx=10, pady=10) Label(top4, text="Event Name").grid(row=3, column=2, padx=10, pady=10) Label(top4, text="Event Date").grid(row=3, column=3, padx=10, pady=10) required_tickets = [] for i in TicketDetails()[7]: if event_name.get() in i: required_tickets.append(i) for i in range(len(required_tickets)): Label(top4, text=required_tickets[i][0], font=('Arial', 12), width=10).grid(row=i+4, column=0) Label(top4, text=required_tickets[i][1], font=('Arial', 12), width=10).grid(row=i+4, column=1) Label(top4, text=required_tickets[i][2], font=('Arial', 12), width=10).grid(row=i+4, column=2) Label(top4, text=required_tickets[i][4], font=('Arial', 12), width=10).grid(row=i+4, column=3) Label(top4, text='Select Event', font=('Arial', 16)).grid(row=0, column=0, padx=10, sticky='w', pady=10) OptionMenu(top4, event_name, *event_names_list).grid(row=0, column=1) Button(top4, text='Submit', command=ShowTickets, bg='green', fg='white', font=('Arial', 12)).grid(row=2, column=0, columnspan=3) top4.mainloop()
8. ViewEvents.py
This module of the Event Management System Project in Python will help the user to check all the available events list.
from tkinter import * from DataBase import EventDetails from DataBase import TicketDetails def ViewEvents(): event_details = EventDetails()[5] top4 = Tk() top4.geometry('550x400') top4.title('View tickets') Label(top4, text="Event Name").grid(row=0, column=0, padx=10, pady=10) Label(top4, text="Event ID").grid(row=0, column=1, padx=10) Label(top4, text="Event Date").grid(row=0, column=2, padx=10) Label(top4, text="Event Time(24 hrs)").grid(row=0, column=3, padx=10) Label(top4, text="Event Duration(in hrs)").grid(row=0, column=4, padx=10) Label(top4, text='------------------'*6).grid(row=1, column=0, columnspan=5) for i in range(len(event_details)): Label(top4, text=event_details[i][0], font=('Arial', 12), width=10).grid(row=i+2, column=0) Label(top4, text=event_details[i][1], font=('Arial', 12), width=10).grid(row=i+2, column=1) Label(top4, text=event_details[i][2], font=('Arial', 12), width=10).grid(row=i+2, column=2) Label(top4, text=event_details[i][3], font=('Arial', 12), width=10).grid(row=i+2, column=3) Label(top4, text=event_details[i][4], font=('Arial', 12), width=10).grid(row=i+2, column=4) top4.mainloop()
9. CancelTicket.py
With the file, we have created a GUI using which the user can delete any ticket.
from tkinter import * from DataBase import TicketDetails from DataBase import DeleteTicket from Message import show_message def CancelTicket(): top3 = Tk() top3.geometry('790x300') top3.title('Cancel Tickets') Label(top3, text='Customer Name', font=('Arial', 12), borderwidth=1, relief="solid", width=20).grid(row=0, column=0, pady=10) Label(top3, text='Ticket ID', font=('Arial', 12), borderwidth=1, relief="solid", width=20).grid(row=0, column=1, pady=10) Label(top3, text='Event Name', font=('Arial', 12), borderwidth=1, relief="solid", width=20).grid(row=0, column=2, pady=10) Label(top3, text='Event Date', font=('Arial', 12), borderwidth=1, relief="solid", width=20).grid(row=0, column=3, pady=10) def delete_rows(ticket_id): delete_status = DeleteTicket(ticket_id) if delete_status == 'Success': show_message('Success', 'Ticket deleted successfully') return else: show_message('Error', delete_status) return for i in range(len(TicketDetails()[7])): Label(top3, text=TicketDetails()[7][i][0], borderwidth=1, relief="solid", width=20).grid(row=i+1, column=0) Label(top3, text=TicketDetails()[7][i][1], borderwidth=1, relief="solid", width=20).grid(row=i+1, padx=10, column=1) Label(top3, text=TicketDetails()[7][i][2], borderwidth=1, relief="solid", width=20).grid(row=i+1, padx=10, column=2) Label(top3, text=TicketDetails()[7][i][4], borderwidth=1, relief="solid", width=20).grid(row=i+1, padx=10, column=3) Button(top3, text='Delete', command=lambda current_id=TicketDetails()[7][i][1]: delete_rows(current_id)).grid(row=i+1, column=4) top3.mainloop()
Output for Event Management System Project in Python:
Thank you for visiting our website.
Also Read:
- Create your own ChatGPT with Python
- SQLite | CRUD Operations in Python
- Event Management System Project in Python
- Ticket Booking and Management in Python
- Hostel Management System Project in Python
- Sales Management System Project in Python
- Bank Management System Project in C++
- Python Download File from URL | 4 Methods
- Python Programming Examples | Fundamental Programs in Python
- Spell Checker in Python
- Portfolio Management System in Python
- Stickman Game in Python
- Contact Book project in Python
- Loan Management System Project in Python
- Cab Booking System in Python
- Brick Breaker Game in Python
- Tank game in Python
- GUI Piano in Python
- Ludo Game in Python
- Rock Paper Scissors Game in Python
- Snake and Ladder Game in Python
- Puzzle Game in Python
- Medical Store Management System Project in Python
- Creating Dino Game in Python
- Tic Tac Toe Game in Python
- Test Typing Speed using Python App
- Scientific Calculator in Python
- GUI To-Do List App in Python Tkinter
- Scientific Calculator in Python using Tkinter
- GUI Chat Application in Python Tkinter