コード例 #1
0
 def print_label(self):
     z = zebra(zebra().getqueues()[0])
     if self.packing < 2:
         packing_title = "Quantity"
         packing_text = "{} item in a box"
     else:
         packing_title = "Packaging Units"
         packing_text = "{} of {}"
     for i in range(1, self.packing + 1):
         #print(packing_title, packing_text.format(i, self.packing))
         pc = '^FT195,325^ARB,28,40^FH\^FD{0}^FS\n^FT246,325^AUB,28,40^FH\^FD{1}^FS'.format(
             packing_title, packing_text.format(i, self.packing))
         lbl = self.__make_label() + pc + '^XZ'
         print(lbl)
         z.output(lbl)
コード例 #2
0
    def send_epl_data(self, cr, uid, ids, context=None):
        z = zebra()
        printer = self.get_default_label_printer(cr, uid, ids, context=context)
        conf_obj = self.pool.get('qz.config')
        conf_id = conf_obj.search(cr, uid,
                                  [('qz_printer.system_name', '=', printer)])
        z.setqueue(printer)
        if conf_id:
            for x in conf_obj.browse(cr, uid, conf_id):
                thermal = x.qz_direct_thermal
                h = x.qz_label_height
                gap = x.qz_label_gap
                height = [h, gap]
                width = x.qz_label_width
                z.setup(direct_thermal=thermal,
                        label_height=height,
                        label_width=width)
        epl = self.prepare_epl_data(cr, uid, ids, context=context)
        partial_pick_obj = self.pool.get('stock.partial.line')
        line_ids = context.get('line_id', []) or []
        partial_ids = partial_pick_obj.search(cr, uid,
                                              [('wizard_id', '=', ids),
                                               ('id', '=', line_ids)])
        partial = partial_pick_obj.browse(cr,
                                          uid,
                                          partial_ids,
                                          context=context)
        for line in partial:
            num_cop = int(line.quantity)
            for n in range(0, num_cop):
                z.output(epl)
                ## sleep  between labels, if not, printer die ;)
                sleep(1.3)

            return True
コード例 #3
0
def print_oneline_zebra():
    PIDtoprint = e2.get()
    txttoprint = "printonelinzebrafunction"
    print(txttoprint)
    txttoprint = gettxttoprint(txttoprint, PIDtoprint)
    print(txttoprint)

    n_printer = v.get()
    printer_name = printer_names[n_printer]
    # test to see if it knowns the right printer.
    print("Using %s" % printer_name)

    print(txttoprint)
    print(PIDtoprint)
    #Set up the printer and go!
    z = zebra()
    z.setqueue(printer_name)

    label = """
N
B50,25,0,1,2,6,34,B,"%s"
A200,60,0,2,1,1,N,"EA PID"
A50,3,0,2,1,1,N,"%s"
P1

	""" % (PIDtoprint, txttoprint)
    #End of EPL commands to print PID tag
    z.setqueue(printer_name)
    z.output(label)
    print("Print Complete")
    return
コード例 #4
0
ファイル: picking_extension.py プロジェクト: IJOL/SINERGIA
    def send_epl_data(self, cr, uid, ids, context=None):
        z = zebra()
        queue = self.get_queue(cr, uid, context=context)
        z.setqueue(queue)
        conf_obj = self.pool.get('qz.config')
        conf_id = conf_obj.search(cr, uid, [('qz_default', '=', 1)])
        if conf_id:
            for x in conf_obj.browse(cr, uid, conf_id):
                thermal = x.qz_direct_thermal
                h = x.qz_label_height
                gap = x.qz_label_gap
                height = [h, gap]
                width = x.qz_label_width
                z.setup(direct_thermal=thermal, label_height=height, label_width=width)
        epl = self.prepare_epl_data(cr, uid, ids, context=context)
        partial_pick_obj = self.pool.get('stock.partial.picking.line')
        line_ids = context.get('line_id', []) or []
        partial_ids = partial_pick_obj.search(cr, uid, [('wizard_id', '=', ids), ('id', '=', line_ids)])
        partial = partial_pick_obj.browse(cr, uid, partial_ids, context=context)
        for line in partial:
            num_cop = int(line.quantity)
            for n in range(0, num_cop):
                z.output(epl)
                ## sleep  between labels, if not, printer die ;)
                sleep(1.3)

            return True
コード例 #5
0
    def send_epl_data(self, cr, uid, ids, context=None):
        z = zebra()
        printer = self.get_default_label_printer(cr, uid, ids, context=context)
        conf_obj = self.pool.get('qz.config')
        conf_id = conf_obj.search(cr, uid,
                                  [('qz_printer.system_name', '=', printer)])
        z.setqueue(printer)
        if conf_id:
            for x in conf_obj.browse(cr, uid, conf_id):
                thermal = x.qz_direct_thermal
                h = x.qz_label_height
                gap = x.qz_label_gap
                height = [h, gap]
                width = x.qz_label_width
                z.setup(direct_thermal=thermal,
                        label_height=height,
                        label_width=width)
        epl = self.prepare_epl_data(cr, uid, ids, context=context)
        for data in self.browse(cr, uid, ids, context=context):
            num_cop = data.copies
        splited = epl.split('____')
        for label in splited:
            for n in range(0, num_cop):
                z.output(label)
                ## sleep  between labels, if not, printer die ;)
                sleep(1.2)

        return True
コード例 #6
0
ファイル: barcodeGen.py プロジェクト: dgaudiosi/LoginApp
    def print_zebra(self,
                    member_id,
                    name_str="Member Name",
                    member_type_str="Member_type",
                    dry_run=False):

        printer = zebra()

        z_design = """CT~~CD,~CC^~CT~
        ^XA~TA000~JSN^LT0^MNW^MTD^PON^PMN^LH0,0^JMA^PR6,6~SD15^JUS^LRN^CI0^XZ
        ^XA
        ^MMT
        ^PW406
        ^LL0203
        ^LS0
        ^BY3,3,54^FT20,0^BCN,,N,N
        ^FD>;""" + str(member_id) + """^FS
        ^FT8,147^A0N,100,60^FH\^FD""" + name_str[0:14] + """^FS
        ^FT140,187^A0N,28,28^FH\^FD""" + member_type_str[0:12] + """^FS
        ^PQ1,0,1,Y^XZ
        """

        if dry_run:
            print('Printer queues found:', printer.getqueues())
            print("ZPL Doc: ")
            print(z_design)
        else:
            testing = printer.getqueues()
            printer.setqueue(config.zebra_printer_name)
            printer.setup(direct_thermal=True,
                          label_height=(203, 32),
                          label_width=406)  # 2" x 1" direct thermal label
            printer.output(z_design)
コード例 #7
0
ファイル: TurkCell.py プロジェクト: alorenzana1/2GIG
 def printerRefresh_cb(self):
     self.printers_list.delete(0, self.printers_list.size())
     z = zebra()
     printers = z.getqueues()
     del z
     for port in range(len(printers)):
         self.printers_list.insert(Tkinter.END, printers[port])
コード例 #8
0
ファイル: qz_print.py プロジェクト: dhecar/sine_qz_print
    def send_epl_data(self, cr, uid, ids, context=None):
        z = zebra()
        printer = self.get_default_label_printer(cr, uid, ids, context=context)
        conf_obj = self.pool.get('qz.config')
        conf_id = conf_obj.search(cr, uid, [('qz_printer.system_name', '=', printer)])
        z.setqueue(printer)
        if conf_id:
            for x in conf_obj.browse(cr, uid, conf_id):
                thermal = x.qz_direct_thermal
                h = x.qz_label_height
                gap = x.qz_label_gap
                height = [h, gap]
                width = x.qz_label_width
                z.setup(direct_thermal=thermal, label_height=height, label_width=width)
        epl = self.prepare_epl_data(cr, uid, ids, context=context)
        for data in self.browse(cr, uid, ids, context=context):
            num_cop = data.copies
        splited = epl.split('____')
        for label in splited:
            for n in range(0, num_cop):
                z.output(label)
                ## sleep  between labels, if not, printer die ;)
                sleep(1.4)

        return True
コード例 #9
0
	def __init__(self):
		self.builder = Gtk.Builder()
		self.builder.add_from_file("Glade_Print_Counter.glade")
		self.window = self.builder.get_object("PrinterWindow")
		closeBtn = self.builder.get_object("CloseBtn")
		printBtn = self.builder.get_object("PrintBtn")
		printNumBtn = self.builder.get_object("PrintNumBtn")
		self.pauseBtn = self.builder.get_object("PauseBtn")
		self.pauseFlag = False#if this flag set to true, then printing will be paused
		closeBtn.connect("clicked", self.quit)
		self.pauseBtn.connect("clicked", self.pause)
		#closeBtn.connect("clicked", self.debug_quit)#for debug
		self.window.connect("destroy", self.quit)
		if zebraFound == True:
			printNumBtn.connect("clicked", self.print_number)
			self.z = zebra('Zebra-Technologies-ZTC-GK420d')
			if(type(self.z) is zebra):
				printBtn.connect("clicked", self.printing_process)
			else:
				print("Printer wasn't detected! Output will be in terminal.\n")
				printBtn.connect("clicked", self.virtual_print)
		else:
			printBtn.connect("clicked", self.virtual_print)#for debug or emulation mode
		
		#Restoring "Printed" last value
		printed_entry = self.builder.get_object("Printed")
		try:#opening file with "Printed" last value
			printedFile = open("./printed.txt", 'r')
			printed = int(printedFile.read())
			printedFile.close()
			printed_entry.set_text(str(printed))
		except:
			print("printed.txt not found! New one will be created!\n")
		self.window.show_all()
コード例 #10
0
def print_lab(label,printer):
	label = label
	z = zebra([])
	p = z.getqueues()
	#print p                                      #This will return a list of printers installed on your computer. 
	z.setqueue(printer)  #Set the default printer to your new ZPL printer
	z.output(label)                                  #Have fun sending data to your printer.It's as easy as it can get. :)
コード例 #11
0
	def __init__(self, Body=" ", Printer="Zebra", Copies=1, Direct=True, **kwargs):
		self.z=zebra()
		for q in self.z.getqueues():
			if re.search(Printer, q):
				print(q)
				self.z.setqueue(q)
		#Label absolute 0 offset
		LabelOffsetXY=[10,20]
		Prefix="^XA~TA000~JSN^LT0^MNW^MT{}^LH{},{}^PON^PMN^XZ".format(("T", "D")[Direct],
			 LabelOffsetXY[0],  LabelOffsetXY[1])
		LblTxt="{}^XA{}^PQ{}^XZ".format(Prefix,  Template(Body).safe_substitute(kwargs), Copies)
		l=LblTxt
コード例 #12
0
def printlabel(device, deviceid, imei, amount):
    i = 1
    while i <= int(amount):
        printFile = open("Template.txt", "r")
        printer = zebra(device)
        lines = printFile.readlines()
        lineStr = "".join(lines)
        lineStr = lineStr.replace("{DEVICEID}", deviceid).replace("{IMEI}", imei).replace("{FIRMWARE}", getFirmware()).replace("{PACKAGE}", getPackage())
        printer.output(lineStr)
        time.sleep(2)
        i += 1
    printFile.close()
コード例 #13
0
def gen_zpl(sender, receiver, dt, code):
    zpl = "^XA^PR12^LRY^MD30^PW440^LL400^PON^CFd0,50,15^FO0,20^FB440,2,0,C^FD" + str(
        receiver)
    zpl += "^FS^CFd0,30,18^FO5,85^FDSender:^FS^CF00,70,30^FO5,120^FB440,1,0,L^FD" + str(
        sender)
    zpl += "^FS^CF00,30,30^FO0,190^FB440,1,0,C^FD" + str(dt).split('.')[0]
    zpl += "^FS^FO100,210^BQN,2,9^FDQA," + str(code)
    zpl += "^FS^PQ1^XZ"
    print(zpl)
    #sendip('10.17.204.201',zpl)
    z = zebra("Zebra ZP 500 (EPL)")
    z.output(zpl)
コード例 #14
0
def detect_printer():
    """ Basic automated check to see if a printer is connected or not.

    This code has been tested on a Windows machine and a Raspberry Pi
    (Ubuntu).
    """
    z = zebra()

    # Identify which operating system is being used and find the printer
    printer_present = False
    system_name = os.name
    if system_name == "nt":
        print("Running on Windows...", end=" ")
        from infi.devicemanager import DeviceManager
        import win32print

        # Identify if a Zebra printer is connected and available
        printer_queues = []
        for (a, b, name,
             d) in win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL):
            printer_queues.append(name)

        dm = DeviceManager()
        devices = dm.all_devices
        for dev in devices:
            if 'ZDesigner' in dev.description:
                if dev.children[0].friendly_name in printer_queues:
                    print("found printer: {}".format(
                        dev.children[0].friendly_name))
                    z.setqueue(dev.children[0].friendly_name)
                    printer_present = True
                    break

    elif system_name == "posix":
        print("Running on Raspberry Pi... configure printer setting:")
        try:
            printers = [
                device for device in z.getqueues() if 'GK420' in device
            ]
            print("")
            for i, printer in enumerate(printers):
                print("  {}: {}".format(i, printer))

            z.setqueue(printers[PI_PRINTER_SELECTION])
            print("Connected to: {}".format(printers[PI_PRINTER_SELECTION]))
            printer_present = True
        except:
            print("Check that 'PI_PRINTER_SELECTION' is correctly configured.")
            printer_present = False

    return z
コード例 #15
0
ファイル: TurkCell.py プロジェクト: alorenzana1/2GIG
 def printerConnect_cb(self):
     index = self.printers_list.curselection()
     if index:
         printer = self.printers_list.get(index)
         self.logger.info("Connecting: " + printer)
         try:
             self.ZebraPrinter = zebra()
         except:
             self.logger.warn("Error has occurred")
         else:
             self.ZebraPrinter.setqueue(printer)
             self.printerConnect_btn.config(state="disable")
             self.printerDisconnect_btn.config(state="normal")
     else:
         self.logger.warn("Wrong printer selected")
コード例 #16
0
ファイル: TurkCell.py プロジェクト: alorenzana1/2GIG
 def TestPrinter(self):
     index = self.printers_list.curselection()
     if index:
         printer = self.printers_list.get(index)
         self.logger.info("Connecting: " + printer)
         try:
             from zebra import zebra
             z = zebra()
             z.setqueue(printer)
         except:
             self.logger.warn("Error has occurred")
         else:
             self.logger.info("Printing label test: Hello World")
             z.output(CreateLabel("0"))
     else:
         self.logger.warn("Wrong printer selected")
コード例 #17
0
ファイル: barcode.py プロジェクト: gugumice/barcode
        def __init__(self, queue=1):
                self.zebra=zebra()
                self.lblText=''
                try:
                        self.zebra.setqueue(self.zebra.getqueues()[queue])
                except:
                        logging.debug('Queue {} not found!'.format(queue))
                        sys.exit(1)
                try:
                        fl='{}/{}'.format(os.path.dirname(os.path.abspath(sys.argv[0])),LBL_FILE)
                        with open(fl) as f:
                                self.lblText=f.read()
                        logging.debug('Reading from {}'.format(fl))
                except:
                        logging.debug('Error reading from {}. Using defaults'.format(LBL_FILE))
                        self.lblText='''

^XA
#label darkness 0-30
~SD10
#label offset width,height
^LH20,10^MTT
^FO0,0
^AS
^FDEGL^FS
^FO0,35
^AQ
^FD$hostName ^FS
^FO30,150
^AS
^FD$barCode^FS
^FO0,65
^GB200,2,2
^FS
^BY2,3,105
^FT20,150
^BCN,80,N,N
^FD>;$barCode^FS
^PQ$numCopies
^XZ
'''


                        self.lblSave()
コード例 #18
0
 def _SendToPrinter(self, epl_code):
     from zebra import zebra
     zebra = zebra(self._printer_name)
     zebra.output(epl_code)
コード例 #19
0
ファイル: barcode.py プロジェクト: gugumice/barcode
        def lblPrint(self, barCode="12345678", numCopies=1):
                t=Template(self.lblText)
                #print(self.__cleanBc(barCode))
                lblStr=t.substitute(hostName=socket.gethostname(), barCode=self.__cleanBc(barCode), numCopies=numCopies)
                self.zebra.output(lblStr)

        def __cleanBc(self, barCode):
                b=[]
                for s in barCode:
                        if 32 <= ord(s) <=127:
                                b += s
                return("".join(b))

if __name__ == '__main__':
        z=zebra()
        zQueues=z.getqueues()
        q=0
        i=0
        if(len(zQueues))==1:
                z.setqueue(zQueues[0])
                logging.debug('Printer: {}'.format(zQueues[0]))
        else:
                for q in zQueues:
                        i+=1
                        print('{}. {}'.format(i,q))
                try:
                        q=input('Select printer ({}):'.format(i))
                except:
                        q=i
                        if  not 0 <= q-1 <= i-1:
コード例 #20
0
ファイル: print.py プロジェクト: sauriiiin/wet-lab-python
#!/usr/bin/env python

import sys
import csv

from zebra import zebra

z = zebra('Zebra')

z.setqueue('Zebra_Technologies_ZTC_ZT410-203dpi_ZPL')

z.setup(direct_thermal=None, label_height=(100, 24), label_width=(500))

data = []
with open(sys.argv[2]) as csvfile:
    file = csv.reader(csvfile)
    for row in file:
        data.append(row)

for i in range(len(data)):
    label = """^XA
^LH0,0 ^FO1,20^BY%s
^BCN,30,Y,N,N
^FD%s^FS
^XZ""" % (sys.argv[1], data[i][0])
    z.output(label)
コード例 #21
0
ファイル: badgesapp.py プロジェクト: evbeda/mercury-badges
    def __init__(self, top=None):

        self.printer_object = zebra()
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#d9d9d9'  # X11 color: 'gray85'
        font10 = "-family {Helvetica Neue} -size 13 -weight bold -slant "  \
            "roman -underline 0 -overstrike 0"
        font11 = "-family {Helvetica Neue} -size 7 -weight normal "  \
            "-slant roman -underline 0 -overstrike 0"

        top.geometry("600x400+343+138")
        top.title("Mercury Badges")
        top.configure(background="#F8F7FA")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        self.PrinterSelectionCanvas = tk.Canvas(top)
        self.PrinterSelectionCanvas.place(
            relx=0.008,
            rely=0.013,
            relheight=0.975,
            relwidth=0.983,
        )
        self.PrinterSelectionCanvas.configure(background="#F8F7FA")
        self.PrinterSelectionCanvas.configure(highlightbackground="#d9d9d9")
        self.PrinterSelectionCanvas.configure(highlightcolor="black")
        self.PrinterSelectionCanvas.configure(insertbackground="black")
        self.PrinterSelectionCanvas.configure(selectbackground="#c4c4c4")
        self.PrinterSelectionCanvas.configure(selectforeground="black")
        self.PrinterSelectionCanvas.configure(width=283)

        self.log_label = tk.Text(self.PrinterSelectionCanvas)
        self.wl = WidgetLogger(self.log_label)
        self.log_label.place(
            relx=0.034,
            rely=0.564,
            height=144,
            width=415,
        )
        self.log_label.configure(background="#ffffff")
        self.log_label.configure(foreground="#000000")
        self.log_label.configure(highlightbackground="#d9d9d9")
        self.log_label.configure(highlightcolor="black")
        self.log_label.configure(state=tk.DISABLED)

        self.printer_radio_buttons = []
        self.populate_radio_buttons()

        self.choose_printer_label = tk.Label(self.PrinterSelectionCanvas)
        self.choose_printer_label.place(
            relx=0.068,
            rely=0.077,
            height=24,
            width=122,
        )
        self.choose_printer_label.configure(activebackground="#f9f9f9")
        self.choose_printer_label.configure(activeforeground="black")
        self.choose_printer_label.configure(background="#F8F7FA")
        self.choose_printer_label.configure(foreground="#000000")
        self.choose_printer_label.configure(highlightbackground="#d9d9d9")
        self.choose_printer_label.configure(highlightcolor="black")
        self.choose_printer_label.configure(text='''Choose a printer:''')

        self.disclaimer_label = tk.Label(self.PrinterSelectionCanvas)
        self.disclaimer_label.place(
            relx=0.042,
            rely=0.949,
            height=7,
            width=221,
        )
        self.disclaimer_label.configure(activebackground="#f9f9f9")
        self.disclaimer_label.configure(activeforeground="black")
        self.disclaimer_label.configure(background="#F8F7FA")
        self.disclaimer_label.configure(font=font11)
        self.disclaimer_label.configure(foreground="#000000")
        self.disclaimer_label.configure(highlightbackground="#d9d9d9")
        self.disclaimer_label.configure(highlightcolor="black")
        self.disclaimer_label.configure(
            text='''Disclaimer: This app was designed\
to support only Zebra printers.''')

        self.start_button = tk.Button(
            self.PrinterSelectionCanvas,
            command=self.configure_printer,
        )
        self.start_button.place(
            relx=0.746,
            rely=0.233,
            height=22,
            width=125,
        )
        self.start_button.configure(activebackground="#d9d9d9")
        self.start_button.configure(activeforeground="#000000")
        self.start_button.configure(background="#d9d9d9")
        self.start_button.configure(foreground="#000000")
        self.start_button.configure(highlightbackground="#d9d9d9")
        self.start_button.configure(highlightcolor="black")
        self.start_button.configure(relief='raised')
        self.start_button.configure(text='''Connect printer''')

        self.printer_id_label = tk.Label(self.PrinterSelectionCanvas)
        self.printer_id_label.place(
            relx=0.797,
            rely=0.077,
            height=24,
            width=71,
        )
        self.printer_id_label.configure(activebackground="#f9f9f9")
        self.printer_id_label.configure(activeforeground="black")
        self.printer_id_label.configure(background="#F8F7FA")
        self.printer_id_label.configure(foreground="#000000")
        self.printer_id_label.configure(highlightbackground="#d9d9d9")
        self.printer_id_label.configure(highlightcolor="black")
        self.printer_id_label.configure(text='''Printer ID''')

        self.printer_id = tk.Text(self.PrinterSelectionCanvas)
        self.printer_id.place(
            relx=0.746,
            rely=0.128,
            relheight=0.056,
            relwidth=0.212,
        )
        self.printer_id.configure(background="white")
        self.printer_id.configure(font="TkTextFont")
        self.printer_id.configure(foreground="black")
        self.printer_id.configure(highlightbackground="#d9d9d9")
        self.printer_id.configure(highlightcolor="black")
        self.printer_id.configure(insertbackground="black")
        self.printer_id.configure(selectbackground="#c4c4c4")
        self.printer_id.configure(selectforeground="black")
        self.printer_id.configure(width=108)
        self.printer_id.configure(wrap='word')

        self.restore_connection_details()

        self.static_status_label = tk.Label(self.PrinterSelectionCanvas)
        self.static_status_label.place(
            relx=0.811,
            rely=0.31,
            height=30,
            width=52,
        )
        self.static_status_label.configure(activebackground="#f9f9f9")
        self.static_status_label.configure(activeforeground="black")
        self.static_status_label.configure(background="#F8F7FA")
        self.static_status_label.configure(font=font10)
        self.static_status_label.configure(foreground="#000000")
        self.static_status_label.configure(highlightbackground="#d9d9d9")
        self.static_status_label.configure(highlightcolor="black")
        self.static_status_label.configure(text='''Status''')

        self.status_label = tk.Label(self.PrinterSelectionCanvas)
        self.status_label.place(relx=0.775, rely=0.362, height=24, width=97)
        self.status_label.configure(activebackground="#f9f9f9")
        self.status_label.configure(activeforeground="black")
        self.status_label.configure(background="#F8F7FA")
        self.status_label.configure(foreground="#000000")
        self.status_label.configure(highlightbackground="#d9d9d9")
        self.status_label.configure(highlightcolor="black")
        self.status_label.configure(text='''Disconnected''')

        self.refresh_printer_button = tk.Button(self.PrinterSelectionCanvas)
        self.refresh_printer_button.place(
            relx=0.110,
            rely=0.154,
            height=22,
            width=80,
        )
        self.refresh_printer_button.configure(activebackground="#F8F7FA")
        self.refresh_printer_button.configure(activeforeground="#F8F7FA")
        self.refresh_printer_button.configure(background="#F8F7FA")
        self.refresh_printer_button.configure(foreground="#000000")
        self.refresh_printer_button.configure(highlightbackground="#d9d9d9")
        self.refresh_printer_button.configure(highlightcolor="black")
        self.refresh_printer_button.configure(text='''Refresh''')
        self.refresh_printer_button.configure(
            command=self.refresh_radio_buttons, )

        self.test_printer_button = tk.Button(self.PrinterSelectionCanvas)
        self.test_printer_button.place(
            relx=0.093,
            rely=0.22,
            height=22,
            width=100,
        )
        self.test_printer_button.configure(activebackground="#F8F7FA")
        self.test_printer_button.configure(activeforeground="#F8F7FA")
        self.test_printer_button.configure(background="#F8F7FA")
        self.test_printer_button.configure(foreground="#000000")
        self.test_printer_button.configure(highlightbackground="#d9d9d9")
        self.test_printer_button.configure(highlightcolor="black")
        self.test_printer_button.configure(text='''Test Printer''')
        self.test_printer_button.configure(command=self.test_printer)
コード例 #22
0
import sys
import glob
import serial
from zebra import zebra
import datetime

# seriall = serial.Serial("/dev/cu.UC-232AC1", baudrate=115200)
barcodeprinter = zebra("Barcode3")
labeltoprint = """
^XA
^MD30
^FO400,50^BY3^B3,N,50,N,N^FD41000523^FS
^FO400,120^A0,30,40^FDDevice ID 41000523^FS

^FO400,165^BY2^B3,N,50,N,N^FD013796001346517^FS
^FO400,245^A0,30,40^FDIMEI 013796001346517^FS

^FO400,300^A0,24,26^FDEngenX, LLC^FS
^FO400,325^A0,24,26^FD(812) 759-6900^FS

^FO760,300^A0,24,26^FDF/W: 
20.2.2.56^FS
^FO760,325^A0,24,26^FDPKG: 2-D8^FS

^PQ1
^XZ"""

barcodeprinter.output(labeltoprint)

# if seriall.isOpen():
#     seriall.close()
コード例 #23
0
ファイル: TurkCell.py プロジェクト: alorenzana1/2GIG
    def initialize(self):

        log_frame = Tkinter.Frame(self)
        interface_frame = Tkinter.Frame(self)
        printers_frame = Tkinter.Frame(self)

        log_frame.pack(side="right", fill="both", expand=True)
        interface_frame.pack(side="left", fill="x")
        printers_frame.pack(side="right", fill="x")

        comport_frame = Tkinter.Frame(interface_frame)
        center_frame = Tkinter.Frame(interface_frame)

        comport_frame.pack(side="top", )
        center_frame.pack(side="bottom", fill="y")

        printList_frame = Tkinter.Frame(printers_frame)
        printBtns_frame = Tkinter.Frame(printers_frame)

        printList_frame.pack(side="top")
        printBtns_frame.pack(side="bottom")

        #Logger
        import ScrolledText
        terminal = ScrolledText.ScrolledText(log_frame,
                                             state='disabled',
                                             height=1)
        terminal.pack(side="left", fill="both", expand=True)
        # Create textLogger
        self.logger = TextRedirector(terminal)

        #Comport Interface
        list_frame = Tkinter.Frame(comport_frame)
        btns_frame = Tkinter.Frame(comport_frame)

        list_frame.pack(side="top", fill="both", expand=True)
        btns_frame.pack(side="bottom")

        #Listbox that lists serial comport available
        self.comport_list = Tkinter.Listbox(list_frame, height=3)
        self.comport_list.pack(side="left", expand=True)
        comports = serial_ports()
        for comport in range(len(comports)):
            self.comport_list.insert(Tkinter.END, comports[comport])

        comport_scrollBar = Tkinter.Scrollbar(list_frame,
                                              orient=Tkinter.VERTICAL)
        comport_scrollBar.pack(side="right", fill="y", expand=True)
        comport_scrollBar.configure(command=self.comport_list.yview)
        self.comport_list.configure(yscrollcommand=comport_scrollBar.set)

        self.Refresh_Btn = Tkinter.Button(btns_frame,
                                          text=u"Refresh",
                                          command=self.Refresh_Btn,
                                          width=15)
        self.Refresh_Btn.pack()

        self.Connect_Btn = Tkinter.Button(btns_frame,
                                          text=u"Connect",
                                          command=self.Connect,
                                          width=15)
        self.Connect_Btn.pack()

        self.Disconnect_Btn = Tkinter.Button(btns_frame,
                                             text=u"Disconnect",
                                             command=self.Disconect,
                                             width=15,
                                             state='disable')
        self.Disconnect_Btn.pack()

        self.Clear_Btn = Tkinter.Button(btns_frame,
                                        text=u"Clear log",
                                        command=self.Clear,
                                        width=15)
        self.Clear_Btn.pack()

        #Creation of IMEI entry,
        self.CartonNo_label = Tkinter.Label(center_frame, text="Carton No.")
        self.CartonNo_label.pack()
        self.entry = Tkinter.Entry(center_frame)
        self.entry.pack()

        self.SetCarton_Btn = Tkinter.Button(center_frame,
                                            text=u"Set Carton No",
                                            command=self.SetCartonNo,
                                            width=15)
        self.SetCarton_Btn.pack()

        if os.path.isfile('nIMEI.bin'):
            with open('nIMEI.bin', 'r') as file:
                imei = file.read()
        else:
            with open('nIMEI.bin', 'w') as file:
                imei = "35337208000000"
                file.write(imei)

        self.IMEI_label = Tkinter.Label(center_frame, text="IMEI")
        self.IMEI_label.pack()

        self.IMEI = Tkinter.StringVar()
        self.IMEI.set(imei)
        self.IMEIentry = Tkinter.Entry(center_frame, textvariable=self.IMEI)
        self.IMEIentry.pack()

        self.FetchBtn = Tkinter.Button(center_frame,
                                       text=u"Write IMEI",
                                       command=self.WriteIMEI,
                                       width=15)
        self.FetchBtn.pack()

        self.ReadBtn = Tkinter.Button(center_frame,
                                      text=u"Read IMEI",
                                      command=self.ReadIMEI,
                                      width=15)
        self.ReadBtn.pack()

        #Listbox that lists printers available

        self.printers_list = Tkinter.Listbox(printList_frame, width=30)
        self.printers_list.pack(side="left", expand=True)
        z = zebra()
        printers = z.getqueues()
        del z
        for port in range(len(printers)):
            self.printers_list.insert(Tkinter.END, printers[port])

        printers_scrollBar = Tkinter.Scrollbar(printList_frame,
                                               orient=Tkinter.VERTICAL)
        printers_scrollBar.pack(side="right", fill="y", expand=True)
        printers_scrollBar.configure(command=self.printers_list.yview)
        self.printers_list.configure(yscrollcommand=printers_scrollBar.set)

        self.printerRefresh_btn = Tkinter.Button(
            printBtns_frame,
            text=u"Refresh",
            command=self.printerRefresh_cb,
            width=15)
        self.printerRefresh_btn.pack()

        self.printerConnect_btn = Tkinter.Button(
            printBtns_frame,
            text=u"Connect printer",
            command=self.printerConnect_cb,
            width=15)
        self.printerConnect_btn.pack()

        self.printerDisconnect_btn = Tkinter.Button(
            printBtns_frame,
            text=u"Disconnect printer",
            command=self.printerDisconnect_cb,
            state="disable",
            width=15)
        self.printerDisconnect_btn.pack()

        self.printerTest_btn = Tkinter.Button(printBtns_frame,
                                              text=u"Test printer",
                                              command=self.TestPrinter,
                                              width=15)
        self.printerTest_btn.pack()

        self.PrintBtn = Tkinter.Button(
            printBtns_frame,
            text=u"Print",
            command=lambda: self.PrintLabel(self.IMEI.get()),
            width=15)
        self.PrintBtn.pack()

        self.logger.info("IMEI to be written: " + imei)
コード例 #24
0
 def _SendToPrinter(self, epl_code):
     from zebra import zebra
     zebra = zebra(self._printer_name)
     zebra.output(epl_code)
コード例 #25
0
from zebra import zebra

from parser_utils import ChassisParser, CPUParser, DriveParser, MacAddressParse, MemoryParser, NetworkParser, ServerParse
from utils import CSVReport, FileWatcher, PrinterTemplate, ThermalPrinter, TEMPLATE
from config import FILE_PATH, LABEL_DIMENSIONS, PRINTER_NAME, REPORT_NAME

specs = ServerParse(FILE_PATH)
mac = MacAddressParse(FILE_PATH, 'SFP')
net = NetworkParser(FILE_PATH)
drive = DriveParser(FILE_PATH)
cpu = CPUParser(FILE_PATH)
mem = MemoryParser(FILE_PATH)
watcher = FileWatcher(FILE_PATH)
report = CSVReport(FILE_PATH, REPORT_NAME, specs)
chassis = ChassisParser(FILE_PATH)
servers = os.listdir(chassis.path)

z = zebra(queue=PRINTER_NAME)
zeb = ThermalPrinter(mac, z)

if __name__ == "__main__":
    print("   ________________________")
    print(r"//                        \\")
    print(r"||    Script running...   ||")
    print(r"\\________________________//", '\n')
    print('Press: ctrl+c to exit program', '\n')

    report.get_po_input()
    report.open_report()
    watcher.watch(report, zeb)