Python Color Printing

K

Kamilche

I'm pretty desperate to get color syntax printing. I just tried out
the evaluation version of 'Komodo', which several people in here
suggested, and its print features are terrible. The text is coming out
huge when I print at 8 point, tiny when I'm printing at 14 point (so
tiny that it looks like subscripts), the margins are reset at random,
and so on. Plus it doesn't recognize all my fonts.

I don't care if the pretty printer is in an IDE. I just want color
printing with headers and footers! And I wanted it automated - I don't
want to have to print each one by hand, I want to start them all
printing and walk away. It has to be able to print in larger fonts
reliably, because 10 point is too small for my computer-weary eyes.

Does anyone have any suggestions?

--Kamilche
 
P

Peter Hickman

Kamilche said:
I'm pretty desperate to get color syntax printing. I just tried out
the evaluation version of 'Komodo', which several people in here
suggested, and its print features are terrible. The text is coming out
huge when I print at 8 point, tiny when I'm printing at 14 point (so
tiny that it looks like subscripts), the margins are reset at random,
and so on. Plus it doesn't recognize all my fonts.

I don't care if the pretty printer is in an IDE. I just want color
printing with headers and footers! And I wanted it automated - I don't
want to have to print each one by hand, I want to start them all
printing and walk away. It has to be able to print in larger fonts
reliably, because 10 point is too small for my computer-weary eyes.

Does anyone have any suggestions?

--Kamilche

There is a GNU tool called source-highlight that handles python. It will create
a html file with the colour coding. You could then print the html file.

You'll have to google for it.
 
P

Peter Hansen

Kamilche said:
I'm pretty desperate to get color syntax printing. I just tried out
the evaluation version of 'Komodo', which several people in here
suggested, and its print features are terrible. The text is coming out
huge when I print at 8 point, tiny when I'm printing at 14 point (so
tiny that it looks like subscripts), the margins are reset at random,
and so on. Plus it doesn't recognize all my fonts.

I don't care if the pretty printer is in an IDE. I just want color
printing with headers and footers! And I wanted it automated - I don't
want to have to print each one by hand, I want to start them all
printing and walk away. It has to be able to print in larger fonts
reliably, because 10 point is too small for my computer-weary eyes.

Does anyone have any suggestions?

I generally look to PDF first for all my printing needs. In this
case, I'd use ReportLab and whatever conveniently syntax-colouring
script I stumbled over.

Automating the printing is probably simple enough from the command
line (i.e. os.system()), though I don't know the incantation, but
I'm sure it could also be automated fairly easily through the
Acrobat COM interface, assuming you're on Windows. On Linux I
am sure there are equivalent (and likely better :) solutions.

-Peter
 
D

Duncan Booth

(e-mail address removed) (Kamilche) wrote in
I'm pretty desperate to get color syntax printing. I just tried out
the evaluation version of 'Komodo', which several people in here
suggested, and its print features are terrible. The text is coming out
huge when I print at 8 point, tiny when I'm printing at 14 point (so
tiny that it looks like subscripts), the margins are reset at random,
and so on. Plus it doesn't recognize all my fonts.

I don't care if the pretty printer is in an IDE. I just want color
printing with headers and footers! And I wanted it automated - I don't
want to have to print each one by hand, I want to start them all
printing and walk away. It has to be able to print in larger fonts
reliably, because 10 point is too small for my computer-weary eyes.

Does anyone have any suggestions?

--Kamilche

Try SciTE which can be downloaded free from http://www.scintilla.org

It will print[*] any of its supported languages in colour, or can export to
HTML, Rtf, Pdf &c. The latest versions are scriptable (in Lua) so you
should be able to automate the process if you really have that many files.

Headers, footers, and fonts are all configurable through properties files
(and I expect configurable from scripts as well).

[*] Direct printing only works on windows, on other platforms you can
convert to pdf or html and print that.
 
K

Kamilche

Peter Hickman said:
There is a GNU tool called source-highlight that handles python. It will create
a html file with the colour coding. You could then print the html file.

Thanks, I've got one of those. But then, how do I handle adding
headers, footers, changing the window title to get rid of 'Microsoft
Internet Explorer', and automatically printing? That's the part where
it falls down on.

If someone knew how to do that via Python, that'd work! :)

--Kamilche
 
M

marduk

I'm pretty desperate to get color syntax printing. I just tried out
the evaluation version of 'Komodo', which several people in here
suggested, and its print features are terrible. The text is coming out
huge when I print at 8 point, tiny when I'm printing at 14 point (so
tiny that it looks like subscripts), the margins are reset at random,
and so on. Plus it doesn't recognize all my fonts.

I don't care if the pretty printer is in an IDE. I just want color
printing with headers and footers! And I wanted it automated - I don't
want to have to print each one by hand, I want to start them all
printing and walk away. It has to be able to print in larger fonts
reliably, because 10 point is too small for my computer-weary eyes.

GNU enscript supports highlighting (in color?). As well as headers,
footers, and a lot of other cool stuff.
 
F

Fernando Perez

Kamilche said:
Thanks, I've got one of those. But then, how do I handle adding
headers, footers, changing the window title to get rid of 'Microsoft
Internet Explorer', and automatically printing? That's the part where
it falls down on.

If someone knew how to do that via Python, that'd work! :)

Sometimes, simple, old tools can be very handy:

haar[~]> which codeps
codeps: aliased to enscript -G2rjE --color -o !*.ps !*; gv !*.ps
haar[~]> which codeprint
codeprint: aliased to enscript -G2rjE --color !*

This gives 2-up output, just remove the 2 option for single-page output.
enscript is a wonderful tool, I use this all the time to print code (and it
highlights many languages, not just python).

Cheers,

f
 
Joined
Dec 2, 2008
Messages
9
Reaction score
0
>Try SciTE which can be downloaded free from www . scintilla . org


I use PyPE as the IDE for my code. Because it doesn't have the capability to print, I came here searching for some way to print python code in color. I don't/didn't know how to use the GNU thing so I downloaded SciTE and it works very well. The only thing I didn't like was the fact that by default, it uses different fonts for each of the color; however, after checking the FAQ I saw that you can change this.

To do so,
1)start up SciTE
2)under the Options menu, open python.properties
3)copy the following code, add it to the bottom of python.properties and then save python.properties

font.base=$(font.monospace)
font.small=$(font.monospace)
font.comment=$(font.monospace)
font.text=$(font.monospace)
font.text.comment=$(font.monospace)
font.embedded.base=$(font.monospace)
font.embedded.comment=$(font.monospace)
font.vbs=$(font.monospace)

4) You should be good to go. Here is what it should look like:
http: //img505.imageshack.us/img505/3369/scitehd4.jpg

5) You can then export your colored .py file as an html and then print it out in color.

NOTE: Because I don't have 100 posts, I can't post pictures or images so just remove the spaces from the urls above and you can view it.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top