A desktop ticketing application built with CustomTkinter that enables users to browse events, purchase tickets, manage their profile, and display QR codes for purchased tickets. Admin users can create events, validate tickets via QR codes or reference numbers, and issue promo codes. The system integrates a MySQL backend with environment-based credentials and supports profile picture management and promo-based discounts.
- Secure signup & login (basic validation)
- Browse events (filter by category)
- Purchase tickets with promo code discounts
- Auto-generated unique ticket reference + QR code image
- View active tickets & show individual QR code
- View expired (used) tickets
- Profile management: change password, change username, upload profile picture
- Add new events (ticket inventory, category, pricing, image)
- Validate tickets (status update to Expired)
- Scan QR codes from clipboard (image decode)
- Create promo codes with discount percent + voucher quantity
- Change username/password & profile picture (same as user)
- MySQL schema auto-creation on first run
- Tables:
promo_code,ticket_data,user_data,userTicket_Bought - Environment-based DB credentials (
.envfile) - QR code generation using
qrcodepackage - Simple random alphanumeric ticket number generation
- Separation of concerns between UI and DB layer (
backend_db.py)
- Python 3.x
- CustomTkinter
- Pillow (PIL)
- PyMySQL
- qrcode
- pyzbar (QR decode for admin ticket validation)
- tkcalendar (date picker)
- python-dotenv (environment configuration)
Tinh-Ticket/
├─ admin_homePage.py # Admin UI (add tickets, validate, promo codes)
├─ home_page.py # User UI (feed, tickets, profile)
├─ login.py # Login screen
├─ signup.py # Signup screen
├─ backend_db.py # Database logic & QR generator
├─ main.py # Application entry point
├─ requirements.txt # Python dependencies
├─ .env # Environment variables (DB credentials)
├─ images/ # UI assets & generated QR codes
│ ├─ QRCode/ # Generated ticket QR images
│ └─ ...
└─ profile_pics/
└─ profile_picture/ # Uploaded profile pictures
- Clone the repository:
git clone [https://github.com/YOUR_USERNAME/YOUR_REPO.git](https://github.com/thisisnotleng/Tinh-Ticket.git)
cd Tinh-Ticket- Create and activate a virtual environment (recommended):
python -m venv venv
venv\Scripts\activate # Windows- Install dependencies:
pip install -r requirements.txt- Create and configure the
.envfile (already present):
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=your_database
DB_PORT=3306- Ensure the MySQL server is running and the user has permissions to create databases and tables.
- Run the application:
python main.py- Automatically creates the database (if missing) and required tables
- Inserts a default admin account:
- Username:
admin - Email:
admin - Password:
admin - User Type:
admin
- Username:
| Variable | Required | Description | Default |
|---|---|---|---|
| DB_HOST | Yes | MySQL server host | — |
| DB_USER | Yes | MySQL username | — |
| DB_PASSWORD | Yes | MySQL password | — |
| DB_NAME | Yes | Target database name | — |
| DB_PORT | No | MySQL port | 3306 |
- Admin creates event (ticket inventory recorded)
- User books ticket → QR code generated under
images/QRCode/ - Admin validates ticket (via reference number or QR decode) → status set to
Expired - User can view Active vs Expired tickets in profile
user_data(user_id, username, email, password, user_type, profile_picture, user_stamp)ticket_data(ticket_id, event_name, event_date, event_location, event_category, ticket_price, amount_left, image_path)userTicket_Bought(ticket_id, event_name, event_date, event_location, event_category, ticket_price, ticket_ref_number, ticket_owner, image_path, ticket_status, qr_path)promo_code(id, publisher_name, promo_number, disc_amount, voucher_amount)
- Admin creates promo code: discount fraction (e.g.
0.15) and voucher count - User enters code at purchase → price recalculated
- (Future improvement) Decrement voucher count & expire when zero
images/
login_ui.png
signup_ui.png
ticket_logo.png
You can embed screenshots using standard markdown once hosted:
- Hash passwords (e.g. bcrypt) instead of plain text
- Enforce stronger input validation & error handling
- Improve DB schema normalization (remove multi-column composite PKs)
- Add voucher usage decrement logic for promo codes
- Add pagination / search for events
- Add export (CSV) for admin reports
- Dockerize app + MySQL for easier onboarding
- Unit tests & CI workflow
- Current password storage is plain text (NOT secure) → Hashing recommended
- Validate image uploads (limit size & type)
- Sanitize user input for robustness (though parameterized queries help)
MIT
- CustomTkinter for modern Tkinter styling
- Pillow for image handling
- pyzbar for QR decoding
- qrcode for QR generation
Feel free to suggest improvements or open an issue if something breaks. Enjoy building and managing events with Tinh Sombot!