[Tkinter-discuss] Generating Postscript from canvas whilst hidden
igor.e.novikov at gmail.com
Wed Mar 2 02:15:34 CET 2011
You can try using pycairo to generate PS/PDF/PNG in the background.
I think this will be better way than widget tricks.
On Tue, Mar 1, 2011 at 6:05 PM, Matt Keenan <matt.keenan at oracle.com> wrote:
> Looking for the best means of generating postscript from a canvas widget
> but having the canvas widget in the background, and not visible to the user.
> I have an application that I'd like to batch generate a web site from,
> including a set of graphs.
> the graphs are plotted on a canvas widget with a convenience function and
> then postscript is generated using the canvas.postscript() method.
> The only means I can see of generating valid postscript is when the canvas
> widget and root are displayed to the user. I'd prefer if this could be
> Following code is a rough example of what happens when the user clicks the
> generate button
> def generate_webpage(self, emplist):
> myroot = Tk()
> mycanvas = Canvas(myroot, width=700, height=400)
> mycanvas.root = myroot
> for i in range(0, len(emplist)):
> # PostScript file name
> psname = "graph%s.ps" % (i)
> # Clear canvas down
> # Plot graph on canvas
> PlotLineGraph(mycanvas, emplist[i])
> # Update tasks and canvas
> # Generate postscript
> mycanvas.postscript(file=psname, pagewidth=675,
> As can be seen, when generate_webpage is clicked, a new popup window is
> shown and each graph as generated is shown within the window as it's done.
> If I add myroot.withdraw() to above method, just after packing mycanvas,
> then no popup appears but all the postsript files are blank
> nothing is actually plotted on the canvas !!
> Does anyone know of a way to get around this ?
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tkinter-discuss