Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to print the content of a text widget ?

91 views
Skip to first unread message

Nicolas Decoster

unread,
Jun 12, 2003, 9:20:29 AM6/12/03
to
Hi all.

Does anyone know how to print the content of a text widget in a
postscript file ? I need to have main layouts of the contents like
character size and eventually fonts and colors. The widget contains some
image too.

Thanks in advance.

Nicolas.

Veronica Loell

unread,
Jun 12, 2003, 10:25:22 AM6/12/03
to
No easy way to do this that I know of, but if you use the canvas widget
with text-items you can save it to a postscript file. Canvas text item
should be able to do the things your mention.

http://mini.net/tcl/canvas
http://mini.net/tcl/printing

- Veronica

Nicolas Decoster

unread,
Jun 12, 2003, 10:44:13 AM6/12/03
to

Veronica Loell wrote:
> No easy way to do this that I know of, but if you use the canvas widget
> with text-items you can save it to a postscript file. Canvas text item
> should be able to do the things your mention.
>

Unfortunately the text widget I want to print is not of my own, it has
already been developped and I don't plan to modify the source.

Anyway, thank you for your answer.

Nicolas.


Bryan Oakley

unread,
Jun 12, 2003, 11:13:31 AM6/12/03
to
Nicolas Decoster wrote:
>
> Veronica Loell wrote:
>
>> No easy way to do this that I know of, but if you use the canvas
>> widget with text-items you can save it to a postscript file. Canvas
>> text item should be able to do the things your mention.
>>
>
> Unfortunately the text widget I want to print is not of my own, it has
> already been developped and I don't plan to modify the source.
>

So, is this a plain Tk text widget or some custom thing? If it's a
custom thing, see if there's a command similar to the text widget 'dump'
command. Use it to get the contents of the widget in a parseable format,
then step through the data and recreate it in a hidden canvas. From
there, use the canvas commands to save as postscript.

I've not actually tried this, and it might be a chore to get the canvas
to look exactly like the text widget, but it might be worth a shot.


Veronica Loell

unread,
Jun 12, 2003, 11:24:02 AM6/12/03
to

This is pretty much how I would go about it as well. I havn't actually
tried this either, but it should be doable and it should be of interest
to the community to get some sort of general even if rough solution. I
don't have all that much time at the moment but I would certainly be
willing to pitch in when I have some more time. If you are interested in
going this way, starting a page at the Tcl'ers wiki would be a good way
to do a simple colloborative effort towards this.

- Veronica

lvi...@yahoo.com

unread,
Jun 17, 2003, 9:16:02 AM6/17/03
to

:> So, is this a plain Tk text widget or some custom thing? If it's a
:> custom thing, see if there's a command similar to the text widget 'dump'
:> command. Use it to get the contents of the widget in a parseable format,
:> then step through the data and recreate it in a hidden canvas. From
:> there, use the canvas commands to save as postscript.
:>
:> I've not actually tried this, and it might be a chore to get the canvas
:> to look exactly like the text widget, but it might be worth a shot.
:>
:>
:
:This is pretty much how I would go about it as well. I havn't actually
:tried this either, but it should be doable and it should be of interest
:to the community to get some sort of general even if rough solution. I
:don't have all that much time at the moment but I would certainly be
:willing to pitch in when I have some more time. If you are interested in
:going this way, starting a page at the Tcl'ers wiki would be a good way
:to do a simple colloborative effort towards this.

If you take a look at <URL: http://wiki.tcl.tk/9007 > you will see an
attempt by one wiki contributor to create a method of serializing a text
widget. It is not a complete solution (he doesn't attempt to deal with
embedded widgets). However, if someone has an itch, it might serve as a
a way to begin scratching...
--
The Tenth Annual Tcl/Tk Conference <URL: http://www.tcl.tk/community/tcl2003 >
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvi...@yahoo.com > <URL: http://www.purl.org/NET/lvirden/ >

0 new messages