so sieht der Code aus:
Code: Alles auswählen
p = app.CAN.postscript(file = "chart_from_method.ps")
f = open("chart.ps", "wb")
f.write(p)
f.close()
Fällt euch was dazu ein?
Grüße,
Hannes.
Code: Alles auswählen
p = app.CAN.postscript(file = "chart_from_method.ps")
f = open("chart.ps", "wb")
f.write(p)
f.close()
Code: Alles auswählen
#!/usr/bin/env python
from __future__ import with_statement
####
import Tkinter as tk
####
class Gui(object):
def __init__(self, width=400, height=400):
self.root = tk.Tk()
self.canvas = tk.Canvas(self.root, width=width, height=height, bg='white',
highlightthickness=None)
self.canvas.pack(fill=tk.BOTH, expand=True)
self.button = tk.Button(self.root, text='Print', command=self.print_out)
self.button.pack()
self.item1 = self.canvas.create_rectangle(33, 33, 99, 99, fill='red')
self.canvas.itemconfig(self.item1, tags=('a', 'x', 't42'))
self.item2 = self.canvas.create_rectangle(222, 222, 333, 333, fill='yellow')
self.canvas.itemconfig(self.item2, tags=('b', 'x', 't42'))
def print_out(self):
pic = self.canvas.postscript()
#print pic
with open('canvas.ps', 'w') as fp:
fp.write(pic)
def run(self):
self.root.mainloop()
####
if __name__ == '__main__':
Gui().run()
Code: Alles auswählen
self.canvas.postscript(file='c3.ps')
Code: Alles auswählen
import Tkinter as tk
root = tk.Tk()
canv = tk.Canvas(root, width=200, height=200)
canv.create_line(10,10,190,190)
canv.pack()
tk.Button(root, text="Postscript", command=lambda :canv.postscript(file="canv.ps")).pack()
root.mainloop()