I want to take user input through tkinter gui. When the user confirms his entry by pressing a button, I want to create a barcode from that input.
The barcode will be saved as an image and it will be named after the user input, so for example "456789.png".
I have the gui working, but I have a problem with the barcode-creation-process.
When I confirm my entry, I get the error message:
"TypeError: StringVar object is not iterable".
Here is my code
from barcode import generate
from barcode.writer import ImageWriter
from tkinter import Tk, Entry, Label, Button
root = Tk()
root.geometry("640x640+0+0")
heading = Label(root, text="Barcode Creator", fg="steelblue", font=("arial", 16)).pack()
label1 = Label(root, text = "Enter Barcode: ", font=("arial", 16, "bold"), fg = "black").place(x=10, y = 200)
name = StringVar()
entry_box = Entry(root, textvariable = name, width=25, bg="lightgreen").place(x=280, y=210)
def create_code():
create = generate('code128', name, output = name, writer = ImageWriter())
create
work = Button(root, text = "Create Barcode", width = 30, height = 5,
bg = "lightblue", command = create_code).place(x=250, y=300)
root.mainloop()