Skip to content

Instantly share code, notes, and snippets.

@code-boxx
Last active October 7, 2023 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-boxx/6253fde0c48d75547753ae21f0904df0 to your computer and use it in GitHub Desktop.
Save code-boxx/6253fde0c48d75547753ae21f0904df0 to your computer and use it in GitHub Desktop.
Python tkinter Customer Queue System

PYTHON TKINTER CUSTOMER QUEUE

https://code-boxx.com/customer-queue-system-python-tkinter/

NOTES

  1. Run unpack.bat (Windows) unpack.sh (Linux/Mac). This will automatically:
    • Create a virtual environment - virtualenv venv
    • Activate the virtual environment - venv\scripts\activate (Windows) venv/bin/activate (Mac/Linux)
    • Install tkinter pip install tk
    • Start the server python queue.py

LICENSE

Copyright by Code Boxx

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.****

# (A) LOAD MODULES
from tkinter import *
# (B) QUEUE MECHANICS
# (B1) COUNTERS
qAll = 0 # total number of people in queue
qNow = 0 # current queue number
# (B2) ISSUE QUEUE NUMBER
def issue():
global qAll
qAll += 1
issL1["text"] = qAll
# (B3) NEXT CUSTOMER
def next():
global qAll, qNow
if qNow < qAll:
qNow += 1
issL2["text"] = qNow
nowL1["text"] = qNow
# (C) BUILD INTERFACE
# (C1) ISSUE QUEUE NUMBER
issFONTA = ("Arial", 20)
issFONTB = ("Arial", 16)
issTK = Tk()
issF1 = Frame(issTK)
issB1 = Button(issF1, width=6, bg="red", fg="white", text="Issue", font=issFONTB, command=issue)
issB2 = Button(issF1, width=6, bg="blue", fg="white", text="Next", font=issFONTB, command=next)
issL1 = Label(issF1, text="0", fg="red", font=issFONTA)
issL2 = Label(issF1, text="0", fg="blue", font=issFONTA)
#issTK.geometry("640x480")
issF1.place(relx=.5, rely=.5, anchor=CENTER)
issB1.grid(row=0, column=0, pady=2)
issB2.grid(row=1, column=0, pady=2)
issL1.grid(row=0, column=1, pady=2, padx=10)
issL2.grid(row=1, column=1, pady=2, padx=10)
# (C2) NOW SERVING
issFONTA = ("Arial", 180)
issFONTB = ("Arial", 20)
nowTK = Tk()
nowF1 = Frame(nowTK)
nowL1 = Label(nowF1, text="0", font=issFONTA)
nowL2 = Label(nowF1, text="NOW SERVING", font=issFONTB)
nowTK.geometry("350x450")
nowF1.place(relx=.5, rely=.5, anchor=CENTER)
nowL1.pack()
nowL2.pack()
# (C3) START!
issTK.mainloop()
nowTK.mainloop()
virtualenv venv
call venv\Scripts\activate
pip install tk
python queue.py
virtualenv venv
source "venv/bin/activate"
pip install tk
python queue.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment