printer delusion
Jeff Shannon
jeff at ccvcorp.com
Wed Nov 3 19:35:01 EST 2004
Mario wrote:
>>"Larry Bates" <lbates at syscononline.com> wrote:
>>When you are new to something you may want to consider
>>going slow about criticism. Quite often what you want
>>exists and you are unaware of it at the beginning.
>>
>>
>
>Hi, thanks for the answer, mine was not a real criticism, was more a
>delusion to see that a powerful thing such as Python needs external apps for
>making a serious printing task, instead of having a set of built in
>functions that handle it, no matter what os you are in [...]
>
>
The problem is that different OSes have greatly different ideas of what
is involved in sending something to a printer. It is not a simple task
to print in a cross-platform way -- methods of finding/naming printers,
determining printer capabilities, formatting data to send to the
printer, etc., bear no relation to each other. In situations like this,
the Python team have a tradition of punting -- leaving it up to others
to develop libraries for the needed functionality. This is very much
like the situation with GUI libraries.
As it turns out, nobody (AFAIK) has developed a real stand-alone printer
library for Python. In most cases, it's not that difficult to use one
of the GUI toolkits that includes printer support, or deferring printing
through the use of Reportlab and PDFs, or using an OS-specific system
command for basic text printing (e.g. 'start notepad /p', or 'lpr', etc).
On the one hand, I can certainly see that there's a niche for just the
sort of tool you're asking about -- something that'll do fairly simple
styled-text printing in a cross-platform way. On the other hand, I
certainly don't have the time or skill to develop such a library, and
I'm not even certain that it's reasonably possible. I'm not sure that
there *is* a way to do styled-text printing, on either Windows or Linux,
without doing one of (a) working through the GUI subsystem, in which
case you might as well install wxPython or equivalent instead of
duplicating half of their code, or (b) using external tools to create
device-independent data files which can then be printed by another
external tool (i.e. PDFs or postscript), or (c) using printer-specific
control sequences which would be a nightmare to make even remotely
comprehensive.
It wouldn't be too hard to write a library that would let you write
plain, unstyled text to the current system's default printer... but
then, the benefit of having such a library is pretty slight, so why
bother? It's also easy enough to do this as a part of the application,
rather than in a library.
In short, while it *sounds* simple to say "just dump this stuff to the
printer", the reality is that it's not a very simple thing to do at all,
and difficult problems may have multiple best answers depending on the
specific circumstances.
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list