I can't seem to figure out how to print with my printer using python.
I'm using Mac OSX 10.4. I was thinking maybe something with
applescript. Does anyone know?
I can't seem to figure out how to print with my printer using python. I'm using Mac OSX 10.4. I was thinking maybe something with applescript. Does anyone know?
Mac OSX is unix, right?
This ought to work then:
import os printer = os.popen('lpr', 'w') printer.write('This is a test.\n') printer.close()
Try to get 'lpr' or 'lp' to work from a command line.
You should be able to use 'lpstat -p' to figure out
printer names if you need that (then use 'lpr -P ps'
to print to a printer called ps.)
Do you know if there's a way to print a file? I'm trying to print an
HTML file, so your solution is good, but doesn't really work for me.
Just reading the HTML file and the printing the content obviously
wouldn't work. I also tried:
printer.write(file('path/to/file.ext'))
but apparently this function only takes strings as parameters.
Do you know if there's a way to print a file? I'm trying to print an HTML file, so your solution is good, but doesn't really work for me. Just reading the HTML file and the printing the content obviously wouldn't work. I also tried:
printer.write(file('path/to/file.ext'))
but apparently this function only takes strings as parameters.
Unless you have a strong desire to waste time and memory by opening
the file reading the content into a string and then call printer.write,
you could simply do something along the lines of this: