Frontend Development 22 min read

Python Seat Reservation System with PySide2 GUI and Command-Line Interface

This article provides a step‑by‑step guide to building a Python‑based seat reservation application using PySide2 for the graphical interface, JSON configuration files for seat layouts, and several command‑line utilities for checking in, checking out, booking, and leaving seats.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Python Seat Reservation System with PySide2 GUI and Command-Line Interface

The tutorial demonstrates how to create a seat reservation system in Python, beginning with the required libraries (PySide2, datetime, json, argparse) and a visual seat‑selection widget that can display tables, chairs, and their states.

Seat layout and occupancy data are stored in { "tableNum": 6, "tablePos": [[0.02,0.15],[0.35,0.15],[0.68,0.15],[0.02,0.65],[0.35,0.65],[0.68,0.65]], "tableSize": [[0.25,0.2],[0.25,0.2],[0.25,0.2],[0.25,0.2],[0.25,0.2],[0.25,0.2]], "tableType": [0,1,2,0,0,0], "tableSS": ["QLabel{background: rgb(245,245,245);color:rgb(92,92,92);border-radius:50px;border: 3px solid rgb(142,142,142)}","QLabel{background: rgb(245,245,245);color:rgb(92,92,92);border: 3px solid rgb(142,142,142)}","QLabel{background: rgb(221,217,195);color:rgb(92,92,92);border: 3px solid rgb(142,142,142)}"], "tableId": ["A","B","C","D","E","F"], "chairNum": [6,6,6,6,6,6], "chairPos": [...], "chairSize": [0.032,0.07], "chairSS_W": "background: rgb(242,242,242);border-radius:15px;border: 3px solid rgb(74,69,42)", "chairSS_K": "background: rgb(64,64,64);border-radius:15px;border: 3px solid rgb(74,69,42)", "chairSS_R": "background: rgb(149,55,43);border-radius:15px;border: 3px solid rgb(74,69,42)", "mapSize": [2,2] } and an {"A1": false, "A2": false, ..., "C4": true, ...} file that records which seats are occupied.

Command‑line tools are provided for various actions:

Python slotCard_in.py -i="<student_id>" – simulate card swipe to check in.

Python slotCard_out.py -i="<student_id>" – simulate card swipe to check out.

Python cmd_order.py -i="<student_id>" -n="<name>" -s="<seat>" – book a seat.

Python cmd_leave.py -i="<student_id>" -t="temp" – request a temporary leave.

Python cmd_leave.py -i="<student_id>" -t="free" – release the seat.

Sample outputs illustrate successful bookings, errors for occupied seats, invalid seat IDs, and duplicate reservations.

The GUI implementation ( orderSystem.py ) creates a main window with title, information entry fields, a scrollable map of tables and chairs, and a booking button. It loads the JSON configuration, draws each table and chair as QLabel and QPushButton widgets, and updates visual styles based on occupancy.

The result display window ( orderDataDisplay.py ) shows the booked student’s name, ID, time, and seat, and provides buttons for temporary leave and final release, along with a list of important usage notes.

Overall, the article serves as a practical guide for building a desktop reservation tool with a visual interface, JSON‑driven layout, and supporting command‑line utilities.

GUIPythonCommandLinepyside2SeatReservation
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.