Bonjour,
J'ai réalisé un code de génération de code barres et celui-ci doit avoir comme but final d'imprimer le code sur une imprimante.
Le problème c'est que l'imprimante est connecté et fonctionne mais python m'envoie un erreur que "USB Device n'est pas detecté"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from tokenize import Name
from unicodedata import name
from barcode import EAN13
import tkinter as tk
from tkinter import ttk
from PIL import Image, ImageTk
import random, os
from svglib.svglib import svg2rlg
from reportlab.graphics import renderPM
from escpos.printer import Usb
 
 
row1 = 1
row2 = 2
column1 = 0
 
def codebarre(event):
    global row1, row2, column1
    num = random.randint(1,9999999999999)
    ean = EAN13(f'{num:013}')
    name = entry.get()
    if os.path.exists(name+'.svg') or not name:
        entry.configure(bg="RED")
        entry.update_idletasks()
        root.after(500)
        entry.configure(bg="WHITE")
        return
    ean.save('C:\\Users\Acer\Desktop\Saint Nicolas\Projet\\'+name)
    printer = Usb(0x416,0x501) 
    printer.codebarre(ean,58,2)
    printer.cut()
 
 
    label2 = tk.Label(root, text=name+".svg")
    label2.grid(row=row1, column=column1, columnspan=2)
 
    path=name+'.png'
    drawing = svg2rlg('C:\\Users\Acer\Desktop\Saint Nicolas\Projet\\'+name+".svg")
    renderPM.drawToFile(drawing, path, fmt="PNG")
    image = Image.open(path)    
    imagetk = ImageTk.PhotoImage(image)    
    label3 = tk.Label(root, image=imagetk)
    label3.image = imagetk
    label3.grid(row=row2, column=column1, columnspan=2)
 
    ttk.Separator(root, orient='horizontal').grid(row=row2+1, column=column1, columnspan=2, pady=5, ipadx=120)
 
    os.remove(path)
 
    entry.delete(0,tk.END)
    row1, row2 = row1+3, row2+3
    if row1%16==0:
        column1+=3
        row1=1
        row2=2
 
 
root = tk.Tk()
label = tk.Label(root, text = "NOM :")
label.grid(row=0, column=0, padx=5, pady=5)
entry = tk.Entry(root, width=20)
entry.grid(row=0, column=1, padx=5)
entry.focus_set()
entry.bind("<Return>", codebarre)
root.mainloop()
J'arrive à trouver le iD Vendor et le Id product mais le input end point et output end point je n'arrive pas à l'identifier.

Merci d'avance.