0
열 EPSON TM-T82 프린터로 인쇄 할 때 this question의 코드를 사용하지만, tkinter
및 mainloop()
python으로 수정 한 경우 레이아웃 GUI를 닫을 때까지 내 데이터를 직접 인쇄하지 마십시오. 이 스크립트가 레이아웃 GUI를 닫지 않고 내 데이터를 인쇄 할 수 있기를 바랍니다. 당신은 버퍼링 발생하는Popen 및 GUI tkinter 프린터로 인쇄하는 방법
import subprocess
from Tkinter import *
class tes_print:
def __init__(self):
self.printData()
def printData(self):
data = " MY TEXT "
lpr = subprocess.Popen("/usr/bin/lpr", stdin=subprocess.PIPE, shell=True)
lpr.stdin.write(data)
root = Tk()
app2 = tes_print()
root.mainloop()
'shell = True'는 그곳에서 유용한 것을하지 않습니다. 'lpr'을리스트에 넣어야하지만 쉘을 사용할 필요는 없습니다 :'subprocess.Popen ([ 'lpr'], stdin = subprocess.PIPE)' – tripleee
코드는 'printData'를 호출하면, 아무것도 쓰지 않을 것이라고 기대합니다. – Goyo