[Tkinter-discuss] Text to postscript

Vasilis Vlachoudis Vasilis.Vlachoudis at cern.ch
Mon Jun 24 08:31:53 EDT 2019

Hi all,

last weekend I started working on an initial version of the Text() -> postscript exporter.
Still is very primitive but some basic functionality is there.
Who ever is interested (or propose changes), can find it on 


run with "python3 pstext.py" (Sorry it executes the "gv" command to visualize the postscript
in linux.  I don't know how to do it in windows or on mac)
(After 1s it opens the gv viewer, or you can trigger it with the "v" keyboard command, "q" to quit)

Needless to say I am completely newbie in postscript, so maybe a few things might be done in a wrong way.

The program is using the "Text.dump()" command to go through all the Text() content and convert it
to postscript.

However I have a list of problems some related to tk and some with postscript

Tk related:
1. I could not find a way to get the "image" data from an embeded image in the Text() widget
2. When word wrap is enabled how I can find where is the "word break" on each line?

Tk-Postscript related:
1. How to make a proper "font" mapping from x11 to postscript
2. Unicode text: I have no idea how to do it in postscript.
3. How to get from postscript the font information (height, ascending, descending etc...) when
   running in python? 

I was thinking that the best way will be to "subclass" the Text and add a "postscript" method
maybe like in the Canvas that returns a text object, but for starting I preferred to make it external.

Any comments, suggestions are more than welcome

From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] on behalf of Cameron Laird [Cameron at phaseit.net]
Sent: Wednesday, June 19, 2019 15:52
To: tkinter-discuss at python.org
Subject: Re: [Tkinter-discuss] Text to postscript

On Tue, Jun 18, 2019 at 11:21:29PM +0200, Michael Lange wrote:
> On Tue, 18 Jun 2019 10:09:08 +0000
> Vasilis Vlachoudis <Vasilis.Vlachoudis at cern.ch> wrote:
> > Thanks Michael,
> >
> > not exactly what I was looking for.
> oh yes, I thought so :)
> > I am investigating how difficult is to write my own ps exporter,
> > based on the Canvas postscript source code.
> This would surely be awesome! In case you succeed please make sure to let
> us know :)
I've written such before.

More precisely, I composed several PostScript utilities and
programs, including one exporter from a custom Tk Canvas.  I
remember it as being fun and rewarding.  While I'm overbooked
at the present, I can at least say that a similar project
for Tkinter certainly *sounds* feasible.
Tkinter-discuss mailing list
Tkinter-discuss at python.org

More information about the Tkinter-discuss mailing list