我正在尝试在code128中编写文本,打印机也以图片结尾,但这两种方式都不起作用,我查看了官方文档和其他论坛问题,但它没有在code128中打印
from PyQt4.QtGui import QApplication,QImage,QFont
from PyQt4.QtCore import QSizeF
import sys,time
app = QApplication(sys.argv)
image = QImage(640,100,QImage.Format_Mono)
image.fill(1)
font = QFont('code128',32,QFont.Normal)
painter = QPainter()
painter.begin(image)
painter.setFont(font)
text = "\xccasdfsf\xce"
painter.drawText(10,90,text)
painter.end()
image.save('test.png')
还有我的热敏打印机
from PyQt4.QtGui import QApplication,QImage,QFont,QPrinter
from PyQt4.QtCore import QSizeF
import sys,time
app = QApplication(sys.argv)
printer = QPrinter('POS-58(copy of 1)')
font = QFont('code128',32,QFont.Normal)
painter = QPainter()
painter.begin(printer)
painter.setFont(font)
text = "\xccasdfsf\xce"
painter.drawText(10,90,text)
painter.end()
这两个都不适合我,我找到了解决方案,会发生什么?
我在带有 python 2.7 的 Windows 10 中使用 PyQt4