Skip to content

Commit

Permalink
added barcode generator
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvenom17 authored Oct 19, 2024
1 parent bcdccd5 commit f60c38d
Showing 1 changed file with 37 additions and 0 deletions.
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()

0 comments on commit f60c38d

Please sign in to comment.