原文:
11.8. How do I get a PostScript(c) output of a Canvas w/ widgets?
In general you don't. You can't do it in Tcl/Tk either (if that is any consolation). Nick Ing-Simmons posted an explicit discussion of what is involved: Subj: RE: Canvases and postscript outputOn Tue, 28 Nov 95 14:37:09 PSTDavis <morry@dsg.tandem.com> writes:! I have a canvas with text and some entry widgets that I want to create!postscript from. I used the !widget->postscript( -file => 'ld.ps', -colormode => 'gray');!the file gets created but its empty. Is there some other options I need?
Core Tk cannot write postscript for embedded windows, the best it could do would be to grab a Pixmap of the window as displayed. This is fine if the window is visible, but if it is scrolled off screen or under another application there is no pixmap.
Only complete fix is to have a ->postscript method for every possible widget which can render un-mapped widgets. This is non-trivial task.
!Also I have a scrollbar for this canvas and when I scroll the entry widget!actually scroll part way out of the frame the canvas is in. Why does this!happen and can I fix it?
The Entry widgets need to be descendants of the canvas or they just get clipped to their parent.
译文:
11.8. 如何把画布中的窗口组件输出成PostScript?
一般来说,这样是不可以的。Tcl/Tk也不能做到这一点(是否这样你会觉得安慰一些?:P)。作者Nick Ing-Simmons在下面的帖子里详细讨论了这个问题:
主题:回复:画布和postscript输出
On Tue, 28 Nov 95 14:37:09 PST
Davis写到:
!我设置了一个画布,里面包含了一些文字和输入框组件,我想把它们输出成postscript。
!我用了如下的命令:$widget->postscript( -file => 'ld.ps', -colormode => 'gray');
!输出文件是有的,但是里面是空的!我还需要什么其它的选项吗?
核心的Tk不能把内嵌的窗口输出成postscript,最多也就是把窗口显示的部分抓成图片。这样在窗口是可见的情况下当然没有问题,但是如果它滚动出了屏幕或者是被其它组件遮住,那么就不能生产图片了。
唯一彻底解决的方法是给每一个可能的组件都加上->postscript方法,但这可是个不小的工作……
(译者注:这个问题我没有太看懂,只能是半猜测的翻译出来的,所以如果我理解的有问题,请大家指正!另外,后面的几句话我实在有些看不明白,所以就不翻了……L)