Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added barcode generator #1004

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Barcode_gen/barcode_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import barcode
from barcode.writer import ImageWriter
from tkinter import *
from tkinter import ttk
from tkinter import messagebox

def generate_barcode():
try:
ean = ean_entry.get()
if not ean.isdigit():
messagebox.showerror("Error", "EAN must be a number.")
return

# Generate barcode
my_code = barcode.EAN13(ean, writer=ImageWriter())
my_code.save("barcode")

# Display success message
messagebox.showinfo("Success", "Barcode generated successfully!")
except Exception as e:
messagebox.showerror("Error", f"An error occurred: {e}")

# Create main window
root = Tk()
root.title("Barcode Generator")

# EAN label and entry
ean_label = Label(root, text="Enter EAN:")
ean_label.grid(row=0, column=0, padx=10, pady=10)
ean_entry = Entry(root)
ean_entry.grid(row=0, column=1, padx=10, pady=10)

# Generate button
generate_button = Button(root, text="Generate Barcode", command=generate_barcode)
generate_button.grid(row=1, column=0, columnspan=2, padx=10, pady=10)

root.mainloop()
Loading