[Tutor] Python printing to LPT

Bill Allen wallenpb at gmail.com
Sun Feb 13 03:53:34 CET 2011


Ken,

Thanks for the great info on doing this on a Linux platform.  I am sure I
will be trying this with Linux sometime and I'll refer back to this.


--Bill










On Sat, Feb 12, 2011 at 18:33, Ken G. <beachkidken at gmail.com> wrote:

> 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
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110212/000f58ec/attachment.html>


More information about the Tutor mailing list