[Tutor] Python printing to LPT
Ken G.
beachkidken at gmail.com
Sun Feb 13 01:33:55 CET 2011
On 02/12/2011 10:14 AM, Bill Allen wrote:
>
> Is is possible to print directly to an LPT port printer from Python?
>
>
> --Bill
>
I use the following format in my Ubuntu 10.04 usage. It set up a
printing file.
import os
# declare values
month = "02"; date = "11"; year = "2011"
# open up file
pr = os.popen("lpr", "w")
#tab two times before printing string
pr.write("\t\tDate of Drawing: "),
# print the month on the same line and added a space
pr.write(month), pr.write (" " ),
# print the date on the same line and added a space
pr.write(date), pr.write(" "),
# print the year on the same line and added a space
pr.write(year), pr.write(" "),
# print up two line feeds
pr.write("\n"), pr.write("\n")
# close the print file
pr.close()
will produce the following:
Date of Drawing: 02 11 2011
(start of new line here)
Very time consuming and detailing but it work.
Ken
More information about the Tutor
mailing list