dionryl1995
Posts: 6
Joined: Fri Aug 02, 2019 11:06 am

Barcode Scanner in TKinter and Python

Fri Jan 24, 2020 1:44 pm

Hi,

I would like to asked help to my project.

I create a tkinter GUI that with two entry parameters which is "lot id and partname". How do I program in python that read the barcode using barcode reader and display the actual value/letters of bardcode in the said parameters "lot id and partname" in DATA ENTRY GUI windows.

Thank you,

Code: Select all

#!/usr/bin/python3
from tkinter import *
from tkinter import ttk

def Data_Entry():
    global EntryScreen
    EntryScreen = Toplevel(ProdScreen)
    
    lbllot_id = Label(EntryScreen, text = "DATA ENTRY", font = ('Arial',30,"bold"),justify = "right")
    lbllot_id.grid(row = 0, column = 1)
    
    lbllot_id = Label(EntryScreen, text = "Lot ID:", font = ('Arial',14,"bold"),justify = "right")
    lbllot_id.grid(row = 1, column = 0, sticky = E)
    lblpartname = Label(EntryScreen, text = "Partname:", font = ('Arial',14,"bold"), justify = "right")
    lblpartname.grid(row = 2, column = 0, sticky = E)
    
    lblloid = Entry(EntryScreen, textvariable = ENTlotid ,font = ('Arial',14,),relief = "solid",bg = "white", width = 25, state = NORMAL)
    lblloid.grid(row = 1, column = 1, sticky = W,padx = 20, pady = 10)
    lblpname = Entry(EntryScreen, textvariable = ENTpartname, font = ('Arial',14,),relief = "solid",bg = "white", width = 25, state = NORMAL)
    lblpname.grid(row = 2, column = 1, sticky = W,padx = 20, pady = 10)
    
    btnclose = Button(EntryScreen, text="LOAD DATA", font=('arial',20,'bold'),relief = 'raised', bd = 5, bg = "blue2", fg = "white", state = NORMAL, command = LoadData)
    btnclose.grid(row = 3, column = 1)
    
def LoadData():
    lotid.set(ENTlotid.get())
    partname.set( ENTpartname.get())
    EntryScreen.destroy()


def Main_Window():
    global ProdScreen
    global lotid
    global partname
    global ENTlotid
    global ENTpartname

    ProdScreen =  Tk()

    lotid = StringVar()
    partname = StringVar()
    ENTlotid  = StringVar()
    ENTpartname = StringVar()

    lbllot_id = Label(ProdScreen, text = "DATA DISPLAY", font = ('Arial',30,"bold"),justify = "right")
    lbllot_id.grid(row = 0, column = 1)

    lbllot_id = Label(ProdScreen, text = "Lot ID:", font = ('Arial',14,"bold"),justify = "right")
    lbllot_id.grid(row = 1, column = 0,sticky = E)
    lblpartname = Label(ProdScreen, text = "Partname:", font = ('Arial',14,"bold"), justify = "right")
    lblpartname.grid(row = 2, column = 0,sticky = E)

    lbllotid_name = Label(ProdScreen, textvariable= lotid, font = ('Arial',14, 'bold'),relief = 'groove', bd = 3,bg = "white",width = 25,height=1)
    lbllotid_name. grid(row = 1, column = 1, sticky = W,padx = 10, pady = 10)
    lbldevicename = Label(ProdScreen, textvariable = partname, font = ('Arial',14, 'bold'),relief = 'groove', bd = 3,bg = "white", width = 25,)
    lbldevicename. grid(row = 2, column = 1, sticky = W,padx = 10, pady = 10)

    btnclose = Button(ProdScreen, text="DATA ENTRY", font=('arial',20,'bold'),relief = 'raised', bd = 5, bg = "blue2", fg = "white", state = NORMAL, command = Data_Entry)
    btnclose.grid(row = 3, column = 1)

    ProdScreen.mainloop()
Main_Window()
Attachments
2020-01-24-182804_1824x984_scrot.jpg
2020-01-24-182804_1824x984_scrot.jpg (87.39 KiB) Viewed 229 times
2020-01-24-182533_1824x984_scrot.jpg
2020-01-24-182533_1824x984_scrot.jpg (18.09 KiB) Viewed 229 times


dionryl1995
Posts: 6
Joined: Fri Aug 02, 2019 11:06 am

Re: Barcode Scanner in TKinter and Python

Fri Jan 24, 2020 1:52 pm

Hi,

How do I insert in the program?

Thank you,

PiGraham
Posts: 3715
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Barcode Scanner in TKinter and Python

Fri Jan 24, 2020 6:38 pm

dionryl1995 wrote:
Fri Jan 24, 2020 1:52 pm
Hi,

How do I insert in the program?

Thank you,
Do you know anything about Python?
If not you could start here
https://www.raspberrypi.org/documentati ... /README.md

Otherwise follow the tektutorials instructions.
Open a terminal and type

Code: Select all

pip install pyzbar

In your code editor import it:

Code: Select all

import cv2
from pyzbar.pyzbar import decode
Try it out. Work through the tutorials .

Return to “Python”