def veri(): df = pd.read_excel(r'C:\Users\DELL\Desktop\barcode_test.xlsx') eski_barcode = df['eski'].tolist() yeni_barcode = df['yeni'].tolist() count = 0 #dictionary = dict(zip(eski_barcode, yeni_barcode)) for eski in eski_barcode: if readed_barcode_ == str(eski): new_barcode_ = yeni_barcode[count] print(new_barcode_) zdoc = ZPLDocument() zdoc.add_comment(" TEX {}".format(new_barcode_)) zdoc.add_field_origin(20, 20) zdoc.add_print_quantity(2) code128_data = str(new_barcode_) bc = Code128_Barcode(code128_data, 'N', 100, 'Y') zdoc.add_barcode(bc) print(zdoc.zpl_text) # Get PNG byte array png = zdoc.render_png(label_width=2, label_height=1) # render fake file from bytes fake_file = io.BytesIO(png) img = Image.open(fake_file) # Open image with the default image viewer on your system img.show() else: pass count += 1
def test_print_quantity_replicates_error(): zdoc = ZPLDocument() with pytest.raises(Exception): zdoc.add_print_quantity(1, 0, -1) with pytest.raises(Exception): zdoc.add_print_quantity(1, 0, 'A') with pytest.raises(Exception): zdoc.add_print_quantity(1, 0, 100000000)
def test_print_quantity_pause_error(): zdoc = ZPLDocument() with pytest.raises(Exception): zdoc.add_print_quantity(1, -1) with pytest.raises(Exception): zdoc.add_print_quantity(1, 'A') with pytest.raises(Exception): zdoc.add_print_quantity(1, 100000000)
def test_print_quantity_range(): zdoc = ZPLDocument() with pytest.raises(Exception): zdoc.add_print_quantity(0) with pytest.raises(Exception): zdoc.add_print_quantity('A') with pytest.raises(Exception): zdoc.add_print_quantity(100000000)
def test_print_quantity_cut_on_error_error(): zdoc = ZPLDocument() with pytest.raises(Exception): zdoc.add_print_quantity(1, 0, 0, 'N', 1) with pytest.raises(Exception): zdoc.add_print_quantity(1, 0, 0, 'N', 'A')
def test_print_quantity_override_error(): zdoc = ZPLDocument() with pytest.raises(Exception): zdoc.add_print_quantity(1, 0, 0, 'A') with pytest.raises(Exception): zdoc.add_print_quantity(1, 0, 0, 10)
def test_print_quantity(): zdoc = ZPLDocument() zdoc.add_print_quantity(4) assert (zdoc.zpl_bytes == b'^XA\n^PQ4,0,0,N,Y\n^XZ')
def text_print_quantity_cut_on_error(): zdoc = ZPLDocument() zdoc.add_print_quantity(1000, 22, 901, 'Y', 'N') assert (zdoc.zpl_bytes == b'^XA\n^PQ1000,22,901,Y,N\n^XZ')
def text_print_quantity_override(): zdoc = ZPLDocument() zdoc.add_print_quantity(1000, 22, 901, 'Y') assert (zdoc.zpl_bytes == b'^XA\n^PQ1000,22,901,Y,Y\n^XZ')
def text_print_quantity_replicates(): zdoc = ZPLDocument() zdoc.add_print_quantity(1000, 22, 901) assert (zdoc.zpl_bytes == b'^XA\n^PQ1000,22,901,N,Y\n^XZ')
def text_print_quantity_pause(): zdoc = ZPLDocument() zdoc.add_print_quantity(4, 5) assert (zdoc.zpl_bytes == b'^XA\n^PQ4,5,0,N,Y\n^XZ')