Path: csiph.com!news.swapon.de!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'root': 0.04; 'sys': 0.05; '-*-': 0.07; 'canvas': 0.07; 'filename': 0.07; 'meeting.': 0.07; 'utf-8': 0.07; 'cc:addr:python-list': 0.09; "'w')": 0.09; 'coding:': 0.09; 'creighton': 0.09; 'english)': 0.09; 'pil': 0.09; 'skip:# 30': 0.09; 'skip:c 80': 0.09; 'output': 0.13; 'def': 0.13; 'argument': 0.15; '100))': 0.16; 'dialog.': 0.16; 'skip:> 20': 0.16; 'subprocess': 0.16; 'tk()': 0.16; 'app': 0.16; 'laura': 0.18; 'linux,': 0.18; 'widget': 0.18; 'windows': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'button,': 0.22; 'os,': 0.22; 'sep': 0.22; 'skip:c 70': 0.22; 'tkinter': 0.22; 'cc:no real name:2**0': 0.22; 'code.': 0.23; 'bit': 0.23; '8bit%:5': 0.23; 'slightly': 0.23; 'tried': 0.24; 'import': 0.24; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'script': 0.25; "i've": 0.25; "doesn't": 0.26; '(which': 0.26; 'skip:" 20': 0.26; 'skip:_ 20': 0.26; 'skip:m 30': 0.27; 'skip:t 40': 0.27; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; '+0200,': 0.27; 'img': 0.29; 'skip:m 60': 0.29; 'convert': 0.29; 'push': 0.30; 'somebody': 0.30; 'window': 0.30; 'skip:s 30': 0.31; 'skip:_ 10': 0.32; 'non': 0.32; 'getting': 0.33; 'run': 0.33; 'options': 0.33; 'class': 0.33; 'problem': 0.33; 'curious': 0.33; 'file': 0.34; 'received:google.com': 0.35; 'next': 0.35; 'done': 0.35; 'dir': 0.35; 'label': 0.35; 'skip:" 50': 0.35; "isn't": 0.35; 'but': 0.36; 'skip:i 20': 0.36; '(and': 0.36; 'skip:m 40': 0.36; 'subject:: ': 0.37; 'mac': 0.37; 'pdf': 0.37; 'building': 0.38; 'skip:p 20': 0.38; 'skip:o 20': 0.38; "didn't": 0.39; 'takes': 0.39; 'hello,': 0.40; 'save': 0.60; 'your': 0.60; 'real': 0.62; 'back': 0.62; 'needing': 0.63; 'more': 0.63; 'different': 0.63; 'great': 0.63; 'between': 0.65; 'here': 0.66; 'skip:n 40': 0.72; 'photo': 0.81; 'lying': 0.84; 'ok?': 0.84; 'working,': 0.84; 'period.': 0.95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=bAzUeyJAEBGRuXq6DHchvFOVkfS9T8kPHD+DCJuk4/g=; b=CL85RQGMa7CLdh5v4ebYDkYMySfJhprnJGoMLkw+9Cu9DOJe03UiGN0CgOV/1VZplU NsSS+NoGeSlZQHxt6RCPhoG7B4Kv29Oiugp9Bk8TH85lJst3k/n1fcZ9vvAUc4mkP8gm TY3m5RgFq3AcXIhuoTY1bmyArASXByGl/lr13CJHAHzlYn8gpn2MCvjL8mKgT/bON05l dlGRt4f5ky8USJMw8wKIw+P6HSQwrrH9MVT+aPlVjVcKOPp2FHbo0iP1/BGS+D5q6hig PNkk1riyYTrG3nKhP2izGBKMziUanb7OL1diWauHhjcazQPHxzHBAzlU+36BB1cdPJmF 30Aw== X-Received: by 10.180.210.162 with SMTP id mv2mr11104511wic.47.1442848867383; Mon, 21 Sep 2015 08:21:07 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <201509202250.t8KMoC0h009296@fido.openend.se> References: <201509201812.t8KICXHu004041@fido.openend.se> <201509201909.t8KJ93oU018314@fido.openend.se> <201509201952.t8KJqh7W029272@fido.openend.se> <201509202250.t8KMoC0h009296@fido.openend.se> From: Baladjy KICHENASSAMY Date: Mon, 21 Sep 2015 17:20:47 +0200 Subject: Re: Postscript to pdf To: Laura Creighton Cc: python-list@python.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Tue, 22 Sep 2015 09:20:04 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 243 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442906405 news.xs4all.nl 23733 [2001:888:2000:d::a6]:47417 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96973 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 =3D tkFileDialog.askopenfilename(title=3D"Ouvrir une image",filetypes=3D[('gif files','.gif'),('all files','.*')]) print(filename) photo =3D PhotoImage(file=3Dfilename) gifdict[filename] =3D photo # r=C3=A9f=C3=A9rence print(gifdict) Canevas.create_image(0,0,anchor=3DNW,image=3Dphoto) Canevas.config(height=3Dphoto.height(),width=3Dphoto.width()) Mafenetre.title("Image "+str(photo.width())+" x "+str(photo.height())) def insertimage(): n=3DtkFileDialog.askopenfilename(filetypes =3D [("Image Files", ("*.jpg", "*.gif")),("JPEG",'*.jpg'),("GIF",'*.gif'),('All','*')]) img =3D PIL.Image.open(n) img =3D img.resize((229, 253)) photoimg =3D ImageTk.PhotoImage(img) label =3D Label(image=3Dphotoimg) label.image =3D photoimg # keep a reference! Canevas.create_image(65,320,anchor=3DW,image =3D photoimg) def insertsign(): n=3DtkFileDialog.askopenfilename(filetypes =3D [("Image Files", ("*.jpg", "*.gif")),("JPEG",'*.jpg'),("GIF",'*.gif'),('All','*')]) img =3D PIL.Image.open(n) img =3D img.resize((300, 100)) photoimg =3D ImageTk.PhotoImage(img) Canevas.create_image(600,500,anchor=3DW,image =3D photoimg) Canvas.pack() def Fermer(): Canevas.delete(ALL) Mafenetre.title("Image") def save(): Canevas.update() Canevas.postscript(file=3DtkFileDialog.asksaveasfilename(), colormode=3D'co= lor') 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 =3D {'fill': Tkconstants.BOTH, 'padx': 5, 'pady': 5} # Tkinter.Button(self, text=3D'Save', command=3Dself.asksaveasfilename).pack(**button_opt) # # self.file_opt =3D options =3D {} # options['filetypes'] =3D [('all files', '.*'), ('text files', '.t= xt')] # options['initialfile'] =3D 'myfile.txt' # options['parent'] =3D root # # def asksaveasfilename(self): # filename =3D tkFileDialog.asksaveasfilename(**self.file_opt) # # if filename: # return open(filename, 'w') # # if __name__=3D=3D'__main__': # root =3D 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=3DW,text=3D"Surname/Nom",fill=3D'Black',= font=3D'Arial 14') Canevas.create_text(315,220,anchor=3DW,text=3De1.get(),fill=3D'Black',font= =3D'Arial 30',tags =3D"e1") Canevas.create_text(315,250,anchor=3DW,text=3D"Given name/Pr=C3=A9nom",fill=3D'Black',font=3D'Arial 14') Canevas.create_text(315,270,anchor=3DW,text=3De2.get(),fill=3D'Black',font= =3D'Arial 30',tags =3D"e1") Canevas.create_text(315,300,anchor=3DW,text=3D"Fonction/Function",fill=3D'B= lack',font=3D'Arial 14') Canevas.create_text(315,320,anchor=3DW,text=3De3.get(),fill=3D'Black',font= =3D'Arial 30',tags =3D"e1") Canevas.create_text(470,395,anchor=3DW,text=3De4.get(),fill=3D'Black',font= =3D'Arial 30',tags =3D"e1") Canevas.create_text(500,438,anchor=3DW,text=3De5.get(),fill=3D'Black',font= =3D'Arial 30',tags =3D"e1") Canevas.create_text(228,503,anchor=3DW,text=3De6.get(),fill=3D'Black',font= =3D'Arial 30',tags =3D"e1") master =3D Tk() Label(master, text=3D"Surname/Nom").grid(row=3D0) Label(master, text=3D"Given name/Pr=C3=A9nom").grid(row=3D1) Label(master, text=3D"Fonction/Function").grid(row=3D2) Label(master, text=3D"Validity Date").grid(row=3D3) Label(master, text=3D"Chef").grid(row=3D4) Label(master, text=3D"Student number").grid(row=3D5) e1 =3D Entry(master) e2 =3D Entry(master) e3 =3D Entry(master) e4 =3D Entry(master) e5 =3D Entry(master) e6 =3D Entry(master) e1.grid(row=3D0, column=3D1) e2.grid(row=3D1, column=3D1) e3.grid(row=3D2, column=3D1) e4.grid(row=3D3, column=3D1) e5.grid(row=3D4, column=3D1) e6.grid(row=3D5, column=3D1) Button(master, text=3D'Ok', command=3Dvalider).grid(row=3D2, column=3D2, sticky=3DW, pady=3D4) Button(master, text=3D'Delete', command=3Ddelete).grid(row=3D3, column=3D2, sticky=3DW, pady=3D4) mainloop( ) # Main window Mafenetre =3D Tk() Mafenetre.title("Image") # Cr=C3=A9ation d'un widget Menu menubar =3D Menu(Mafenetre) menufichier =3D Menu(menubar,tearoff=3D0) menufichier.add_command(label=3D"Open mask",command=3DOuvrir) menufichier.add_command(label=3D"Save mask",command=3Dsave) #menufichier.add_command(label=3D"Convert pdf",command=3Dconvert) menufichier.add_command(label=3D"Close mask",command=3DFermer) menufichier.add_command(label=3D"Quit",command=3DMafenetre.destroy) menubar.add_cascade(label=3D"File", menu=3Dmenufichier) menuwrite =3D Menu(menubar,tearoff=3D0) menuwrite.add_command(label=3D"Insert informations",command=3DWrite) menuwrite.add_command(label=3D"Insert image",command=3Dinsertimage) menuwrite.add_command(label=3D"Insert signature",command=3Dinsertsign) menubar.add_cascade(label=3D"Informations", menu=3Dmenuwrite) menuaide =3D Menu(menubar,tearoff=3D0) menuaide.add_command(label=3D"A propos",command=3DApropos) menubar.add_cascade(label=3D"Aide", menu=3Dmenuaide) # Affichage du menu Mafenetre.config(menu=3Dmenubar) # Cr=C3=A9ation d'un widget Canvas Canevas =3D Canvas(Mafenetre) Canevas.pack(padx=3D5,pady=3D5) # Utilisation d'un dictionnaire pour conserver une r=C3=A9f=C3=A9rence gifdict=3D{} Mafenetre.mainloop() 2015-09-21 0:50 GMT+02:00 Laura Creighton : > In a message of Sun, 20 Sep 2015 23:11:20 +0200, Baladjy KICHENASSAMY wri= tes: >>well one more question :/ >> >>i tried this >> >>def save(): >> Canevas.update() >> Canevas.postscript(file=3DtkFileDialog.asksaveasfilename(), >>colormode=3D'color') >> subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"]) >> >> >>i got the ps file but i didn't get the pdf file :/ > > It's 00:41 here in Sweden, and I have an 08:00 meeting. I am off to bed. > Perhaps somebody else can help now, otherwise I will be back > tomorrow. > > I've never tried to get subprocess to run as part of a savefile dialog. > Try building a tkinter app that takes a filename argument (somepostscript > file you have lying around) and then push the button, in the same dir > makes a pdf of your ps using subprocess. > > If that works, then see about getting save to run that subprocess as > part of the save process. I am very curious about whether that can > be done -- but first check that your subprocess is working, period. > The wretched thing is slightly different between windows and linux, > and even between different linuxes, so needing to fiddle a bit here is > normal (and frustrating). > > So right now I cannot tell if your problem is 'save doesn't like > it like that' or 'your subprocess isn't working'. > > But nothing in Tkinter likes 'Canevas' -- (which is great French > but rotten English) you must have written Canvas in your code. > > Paste the real thing in next time, ok? > > Sorry I am off now, > Laura --=20 KICHENASSAMY Baladjy Ing=C3=A9nieur en G=C3=A9nie M=C3=A9canique Sp=C3=A9cialiste Contr=C3=B4le Non Destructif et Qualification des proc=C3= =A9d=C3=A9s sp=C3=A9ciaux COSAC CND Niveau 2 RT et PT Aircelle SAFRAN Tel:06.03.72.53.12