I have a usb barcode scanner which I want to use it in raspberry pi. Barcode scanner is a plug and play device i.e where ever is the current cursor focus it prints the output. My query is that how can I get that output in a pygame rect box, is there a way that whenever we scan the barcode the output appears on the pygame rec box. I couldn't get the cursor in pygame. I have to use pygame because our application is in pygame (written by previous colleague)and I have a very little familiarity with pygame. Is there an example which I can check?
Thanks,
class RectLabel:
def __init__(self, app, pos, dim, text, font, fontCol = 0, bcgCol = 0, txtMode = 'mpte', scaleFactor = 1.0):
    self.app = app
    self.disp = self.app.disp
    self.x = pos[0]
    self.y = pos[1]
    self.xdim = dim[0]
    self.ydim = dim[1]
    self.text = str(text)
    self.font = font
    self.txtMode = txtMode
    if not fontCol:
        self.setFontCol(self.app.font_col)
    else:
        self.setFontCol(fontCol)  
    if not bcgCol:
        self.setBcgCol(self.app.textView_col)
    else:
        self.setBcgCol(bcgCol)  
    self.bcgSurface = pg.Surface((self.xdim, self.ydim), pg.SRCALPHA)  # per-pixel alpha
    self.setHasBorder(False)
    self.scaleFactor = scaleFactor
def setFontCol(self, fontCol):
    self.fontCol = fontCol
    self.app.updateScreen()
def setBcgCol(self, bcgCol):
    self.bcgCol = bcgCol
    self.app.updateScreen()
def setText(self, text):
    self.text = str(text)
    self.app.updateScreen()
def setHasBorder(self, hasBorder):
    self.hasBorder = hasBorder
    self.app.updateScreen()
def display(self):
    self.show(self.x, self.y)
def displayWithY(self, y):
    self.show(self.x, y)
def show(self, x, y):
    self.bcgSurface.fill(self.bcgCol)
    self.disp.blit(self.bcgSurface, (x - self.xdim / 2, y - self.ydim / 2, self.xdim, self.ydim))
    if self.hasBorder:
        pg.draw.rect(self.disp, [0, 0, 255], (x - self.xdim/2,y - self.ydim / 2,self.xdim,self.ydim), 5)
    if self.txtMode == 'spu':
        txt.spu(self.disp,
                self.text,
                (x, y),
                self.font,
                self.fontCol)
    elif self.txtMode == 'spt':
        txt.spt(self.disp,
                self.text,
                (x, y),
                self.xdim * self.scaleFactor,
                self.font,
                self.fontCol)
    elif self.txtMode == 'mpue':
        txt.mpue(self.disp,
                self.text,
                (x, y),
                self.ydim * self.scaleFactor,
                self.font,
                self.fontCol)
    elif self.txtMode == 'mpta':
        txt.mpta(self.disp,
                self.text,
                (x, y),
                (self.xdim * self.scaleFactor, self.ydim * self.scaleFactor),
                self.font,
                self.fontCol)
    elif self.txtMode == 'mpte':
        txt.mpte(disp = self.disp,
                text = self.text,
                pos = (x, y),
                dim = (self.xdim * self.scaleFactor, self.ydim * self.scaleFactor),
                font = self.font,
                fontCol = self.fontCol)
