Welcome to a quick tutorial on how to create a simple customer queue system with Python Flask. Want to create your own simple queue management system? Well, the basics are actually pretty simple – Read on for an example!
ⓘ I have included a zip file with all the source code at the start of this tutorial, so you don’t have to copy-paste everything… Or if you just want to dive straight in.
TABLE OF CONTENTS
|Download & Notes||Python Queue||Useful Bits & Links|
DOWNLOAD & NOTES
Firstly, here is the download link to the example code as promised.
- Create your own project folder, e.g.
D:\queue, unzip the code inside this folder.
- Open the terminal (or command line), navigate to your project folder
- As usual, create a virtual environment if you don’t want to mess up your other projects.
- Windows –
- Mac/Linux –
- Get all the packages –
pip install tk
EXAMPLE CODE DOWNLOAD
Click here to download all the example source code, I have released it under the MIT license, so feel free to build on top of it or use it in your own project.
PYTHON CUSTOMER QUEUE
All right, let us now get into the details of creating a simple python customer queue system.
PART 1) FOUNDATIONS
# (A) LOAD MODULES from tkinter import * # (B) WINDOWS & COUNTERS wNow = Tk() # window - currently serving wIss = Tk() # window - queue number issuer qAll = 0 # total number of people in queue qNow = 0 # current queue number
- (A) For the folks who have not heard of
tkinter, it is one of the more popular options in Python to create a GUI.
- (B) For this application, we are going to create 2 windows –
wNow“Currently serving queue number”.
wIssThis “admin panel” issues a queue number, and shows the total number of customers.
- (B) Next, we have 2 simple variables to keep track of the queue.
qAllThe total number of customers.
qNowCurrently serving this customer.
So yes, this system can be deployed using only a single device. But 2 monitors are required, one for the “admin”, and another to display the “currently serving”.
PART 2) MECHANICS
# (C) MECHANICS # (C1) ISSUE QUEUE NUMBER def issue(): global qAll qAll += 1 wIssNum["text"] = qAll # (C2) NEXT CUSTOMER def next(): global qAll, qNow if qNow < qAll: qNow += 1 wNowNum["text"] = qNow
How does the queue system work?
- (C1) The admin hits “issue queue number”,
qAll += 1.
- (C2) Then, hits the “next customer”,
if qNow < qAll: qNow += 1.
As simple as “ABC”.
PART 3) USER INTERFACE
# (D) BUILD INTERFACE # (D1) ISSUE QUEUE NUMBER wIssNum = Label(wIss, text="0", font=("Arial", 25)) wIssNum.pack(pady=20) wIssIss = Button(wIss, text="Issue Queue Number", command=issue) wIssIss.pack() wIssNxt = Button(wIss, text="Next Customer", command=next) wIssNxt.pack() # (D2) CURRENTLY SERVING wNowNum = Label(wNow, text="0", font=("Arial", 25)) wNowNum.pack(pady=20)
Not the prettiest interface design in the world, but it works…
PART 4) LAUNCH
# (E) START! wNow.mainloop() wIss.mainloop()
Don’t think this needs explanation.
USEFUL BITS & LINKS
That’s all for the tutorial, and here is a small section on some extras and links that may be useful to you.
Of course, this is only a tutorial and covers the bare basics. A lot of improvements can be made:
- A better interface. Big numbers, funky fonts, and stuff.
- Play a sound on “next customer”, and flash the screen.
- Find ways to better manage the queue number… Or it will run to very big numbers eventually.
- Maybe even save the current queue numbers in a file, so that it is not lost when the system crashes.
- Attach a thermal printer, print, and issue a “hard copy” to the customer.
- If there is an Internet connection, maybe even send out a reminder to the customer.
The possibilities are endless, so it’s up to you to create your own “perfect system”.
LINKS & REFERENCES
Thank you for reading, and we have come to the end. I hope that it has helped you to better understand, and if you want to share anything with this guide, please feel free to comment below. Good luck and happy coding!