printer delusion

M

Mario

Hello, I am a new Python entusiast, I am studing it since some weeks and I
think it's a great language and I was very happy with it, but when I came to
make a printer routine I really got demotivated by the difficulty, why does
Python covers easily the most complicated tasks and on the printer there is
this big hole? I was looking on the web, on newsgroups, to find some good
solution but I couldn't believe that there is this big lack on the printers,
as much I was happily surprised to find that Python handles easily diffucult
tasks, I had a big delusion to find out the lacks of Python on the print
problem, which is very important for me.

I really wish that soon will come out some implementation on the Python
native package to handle printing on the various platforms.

I saw that the most easy thing was to write a txt file and shell "notepad /p
filename" to print the data, (what a rude thing! imho), but that is not
enough cause I need to eloborate datas and print styled reports that I used
to code directly inside VB, but now I can't do it or is some cliffhanger
task.

I started to work also for unix platforms and I thought that Python was the
perfect language to write multiplatforms programs, I was so entusiast about
it that I couldn't believe that I had to go in that problem now.

I really would appreciate that the developers will develope soon a global
print function that one can use inside the code, that can use styled texts
and graphics and then the interpreter will care about the os and printers.

Bye and thanks for any suggestion, if any.

Mario

PS: Was all too good to be true :p lol
 
L

Larry Bates

Mario,

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.

wxWindows has good support for printers and is cross platform.

Specifically take a look at wxPython.lib.printout. I use
PrintTable to do my table-style output quite a lot. It
provides you with Print Preview, scaling, etc. with little
effort.

or if you prefer

You can use ReportLab to produce .PDF output files.
With this you have fine-grained output capabilities and
get electronic cross-platform files which for some
applications is a real benefit (e.g web projects).

Hope information helps.

Regards,
Larry Bates
Hello, I am a new Python entusiast, I am studing it since some weeks and I
think it's a great language and I was very happy with it, but when I came to
make a printer routine I really got demotivated by the difficulty, why does
Python covers easily the most complicated tasks and on the printer there is
this big hole? I was looking on the web, on newsgroups, to find some good
solution but I couldn't believe that there is this big lack on the printers,
as much I was happily surprised to find that Python handles easily diffucult
tasks, I had a big delusion to find out the lacks of Python on the print
problem, which is very important for me.

I really wish that soon will come out some implementation on the Python
native package to handle printing on the various platforms.

I saw that the most easy thing was to write a txt file and shell "notepad /p
filename" to print the data, (what a rude thing! imho), but that is not
enough cause I need to eloborate datas and print styled reports that I used
to code directly inside VB, but now I can't do it or is some cliffhanger
task.

I started to work also for unix platforms and I thought that Python was the
perfect language to write multiplatforms programs, I was so entusiast about
it that I couldn't believe that I had to go in that problem now.

I really would appreciate that the developers will develope soon a global
print function that one can use inside the code, that can use styled texts
and graphics and then the interpreter will care about the os and printers.

Bye and thanks for any suggestion, if any.

Mario

PS: Was all too good to be true :p lol
1
 
M

Mario

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 or if you want, or
don't want to use/install wxWindows, or produce pdf, or shell "notepad /p",
my goal is to produce and sell to my clients complete packages that doesen't
require third party softwares or libraries. Also because often clients says
"no way" about installing other things than what is strictly needed (for
security and stability reasons) and wouldn't be nice to install some big
library just to make the print job; I would rather produce a small
executable in C (or VB for windows) so to be called when it's needed to
print, but I would still prefer a built in function so I'll have a complete
indipendent app :)

Thanks a lot for the info btw.

Mario
 
J

Jeff Shannon

Mario said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top