Create a Python Tkinter GUI to Generate QR Codes and Barcodes

This guide shows how to build a simple desktop GUI with Tkinter that lets users input data, generate QR codes or EAN‑13 barcodes using the qrcode and python‑barcode libraries, preview the images, and save them to disk.

Test Development Learning Exchange
Test Development Learning Exchange
Test Development Learning Exchange
Create a Python Tkinter GUI to Generate QR Codes and Barcodes

This article explains how to develop a lightweight Python desktop application that can generate QR codes and barcodes through a graphical user interface built with Tkinter.

Prerequisites

First install the required packages:

pip install qrcode Pillow python-barcode

Application Structure

The program defines a BarcodeGeneratorApp class that creates two side‑by‑side frames: one for QR code operations and one for barcode operations. Each frame contains an entry widget for user input, a label to display the generated image, and three buttons to generate, save, and clear the image.

Key Functions

generate_qr_code : Reads the text from the QR entry, creates a QR image with qrcode.make, saves it as qr_code.png, loads it with Pillow, resizes it, and shows it in the label. If the entry is empty, a warning dialog appears.

generate_bar_code : Reads the numeric string from the barcode entry, validates that it contains 12 or 13 digits, creates an EAN‑13 barcode using python-barcode with ImageWriter, saves it as bar_code.png, loads and resizes it, then displays it. Invalid input triggers a warning.

save_qr and save_bar : Open a file‑save dialog, write the currently displayed image to the chosen location, and show a success message.

Running the App

The script ends with the usual Tkinter bootstrap code:

if __name__ == "__main__":
    root = tk.Tk()
    app = BarcodeGeneratorApp(root)
    root.mainloop()

When executed, the window displays two panels where users can type data, click “Generate QR Code” or “Generate Barcode”, preview the result, and click “Save QR Code” or “Save Barcode” to store the image.

Conclusion

This example demonstrates a practical use of Tkinter combined with qrcode and python-barcode to provide a quick, cross‑platform tool for creating and saving QR codes and barcodes without needing external services.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

GUIPythonQR codeDesktop ApplicationTkinterbarcode
Test Development Learning Exchange
Written by

Test Development Learning Exchange

Test Development Learning Exchange

0 followers
Reader feedback

How this landed with the community

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.