On Tuesday, September 22, 2015 at 2:20:56 AM UTC-5, Bala Ji wrote: > Hello, > This is my programe : on mac i was able to output ps file but i didn't > got the pdf file :/ > > # -*- coding: utf-8 -*- > # script lecture_gif.py > from Tkinter import * > import tkMessageBox > import Tkconstants > import tkFileDialog > from PIL import ImageTk > import PIL.Image > import os, sys > import subprocess > > > def Ouvrir(): > Canevas.delete(ALL) # on efface la zone graphique > > filename = tkFileDialog.askopenfilename(title="Ouvrir une > image",filetypes=[('gif files','.gif'),('all files','.*')]) > print(filename) > photo = PhotoImage(file=filename) > gifdict[filename] = photo # référence > print(gifdict) > > Canevas.create_image(0,0,anchor=NW,image=photo) > Canevas.config(height=photo.height(),width=photo.width()) > > Mafenetre.title("Image "+str(photo.width())+" x "+str(photo.height())) > > def insertimage(): > n=tkFileDialog.askopenfilename(filetypes = [("Image Files", ("*.jpg", > "*.gif")),("JPEG",'*.jpg'),("GIF",'*.gif'),('All','*')]) > img = PIL.Image.open(n) > img = img.resize((229, 253)) > photoimg = ImageTk.PhotoImage(img) > label = Label(image=photoimg) > label.image = photoimg # keep a reference! > Canevas.create_image(65,320,anchor=W,image = photoimg) > def insertsign(): > n=tkFileDialog.askopenfilename(filetypes = [("Image Files", ("*.jpg", > "*.gif")),("JPEG",'*.jpg'),("GIF",'*.gif'),('All','*')]) > img = PIL.Image.open(n) > img = img.resize((300, 100)) > photoimg = ImageTk.PhotoImage(img) > Canevas.create_image(600,500,anchor=W,image = photoimg) > Canvas.pack() > > def Fermer(): > Canevas.delete(ALL) > Mafenetre.title("Image") > > def save(): > Canevas.update() > Canevas.postscript(file=tkFileDialog.asksaveasfilename(), colormode='color') > subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"]) > > # def convert(): > # ps2pdf -dEPSCrop image.ps > # convert -density 300 PASSPORTQUALITE.ps output.png > > # class TkFileDialogExample(Tkinter.Frame): > # > # def __init__(self, root): > # > # Tkinter.Frame.__init__(self, root) > # button_opt = {'fill': Tkconstants.BOTH, 'padx': 5, 'pady': 5} > # Tkinter.Button(self, text='Save', > command=self.asksaveasfilename).pack(**button_opt) > # > # self.file_opt = options = {} > # options['filetypes'] = [('all files', '.*'), ('text files', '.txt')] > # options['initialfile'] = 'myfile.txt' > # options['parent'] = root > # > # def asksaveasfilename(self): > # filename = tkFileDialog.asksaveasfilename(**self.file_opt) > # > # if filename: > # return open(filename, 'w') > # > # if __name__=='__main__': > # root = Tkinter.Tk() > # TkFileDialogExample(root).pack() > # root.mainloop() > def Apropos(): > tkMessageBox.showinfo("A propos","Tutorial") > > def Write(): > def delete(): > e1.delete(0,END) > e2.delete(0,END) > e3.delete(0,END) > e4.delete(0,END) > e5.delete(0,END) > e6.delete(0,END) > Canevas.delete("e1") > def valider(): > Canevas.create_text(315,200,anchor=W,text="Surname/Nom",fill='Black',font='Arial > 14') > Canevas.create_text(315,220,anchor=W,text=e1.get(),fill='Black',font='Arial > 30',tags ="e1") > Canevas.create_text(315,250,anchor=W,text="Given > name/Prénom",fill='Black',font='Arial 14') > Canevas.create_text(315,270,anchor=W,text=e2.get(),fill='Black',font='Arial > 30',tags ="e1") > Canevas.create_text(315,300,anchor=W,text="Fonction/Function",fill='Black',font='Arial > 14') > Canevas.create_text(315,320,anchor=W,text=e3.get(),fill='Black',font='Arial > 30',tags ="e1") > Canevas.create_text(470,395,anchor=W,text=e4.get(),fill='Black',font='Arial > 30',tags ="e1") > Canevas.create_text(500,438,anchor=W,text=e5.get(),fill='Black',font='Arial > 30',tags ="e1") > Canevas.create_text(228,503,anchor=W,text=e6.get(),fill='Black',font='Arial > 30',tags ="e1") > master = Tk() > Label(master, text="Surname/Nom").grid(row=0) > Label(master, text="Given name/Prénom").grid(row=1) > Label(master, text="Fonction/Function").grid(row=2) > Label(master, text="Validity Date").grid(row=3) > Label(master, text="Chef").grid(row=4) > Label(master, text="Student number").grid(row=5) > e1 = Entry(master) > e2 = Entry(master) > e3 = Entry(master) > e4 = Entry(master) > e5 = Entry(master) > e6 = Entry(master) > e1.grid(row=0, column=1) > e2.grid(row=1, column=1) > e3.grid(row=2, column=1) > e4.grid(row=3, column=1) > e5.grid(row=4, column=1) > e6.grid(row=5, column=1) > Button(master, text='Ok', command=valider).grid(row=2, column=2, > sticky=W, pady=4) > Button(master, text='Delete', command=delete).grid(row=3, column=2, > sticky=W, pady=4) > mainloop( ) > > # Main window > Mafenetre = Tk() > Mafenetre.title("Image") > > # Création d'un widget Menu > menubar = Menu(Mafenetre) > > menufichier = Menu(menubar,tearoff=0) > menufichier.add_command(label="Open mask",command=Ouvrir) > menufichier.add_command(label="Save mask",command=save) > #menufichier.add_command(label="Convert pdf",command=convert) > menufichier.add_command(label="Close mask",command=Fermer) > menufichier.add_command(label="Quit",command=Mafenetre.destroy) > menubar.add_cascade(label="File", menu=menufichier) > > menuwrite = Menu(menubar,tearoff=0) > menuwrite.add_command(label="Insert informations",command=Write) > menuwrite.add_command(label="Insert image",command=insertimage) > menuwrite.add_command(label="Insert signature",command=insertsign) > menubar.add_cascade(label="Informations", menu=menuwrite) > > > menuaide = Menu(menubar,tearoff=0) > menuaide.add_command(label="A propos",command=Apropos) > menubar.add_cascade(label="Aide", menu=menuaide) > > # Affichage du menu > Mafenetre.config(menu=menubar) > > # Création d'un widget Canvas > Canevas = Canvas(Mafenetre) > Canevas.pack(padx=5,pady=5) > > # Utilisation d'un dictionnaire pour conserver une référence > gifdict={} > > Mafenetre.mainloop() > > 2015-09-21 0:50 GMT+02:00 Laura Creighton <l...@openend.se>: > > In a message of Sun, 20 Sep 2015 23:11:20 +0200, Baladjy KICHENASSAMY > > writes: > >>well one more question :/ > >> > >>i tried this > >> > >>def save(): > >> Canevas.update() > >> Canevas.postscript(file=tkFileDialog.asksaveasfilename(), > >>colormode='color') > >> subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"]) > >>
Try putting the entire path to ps2pdf in the subprocess call, something like: /usr/local/bin/ps2pdf -- https://mail.python.org/mailman/listinfo/python-list