Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96973

Re: Postscript to pdf

References (5 earlier) <201509201909.t8KJ93oU018314@fido.openend.se> <CAKSfFmiThEyW8B=ni8NA1FGY1aC2sU3L1CApgy1oA6A8+MKQvQ@mail.gmail.com> <201509201952.t8KJqh7W029272@fido.openend.se> <CAKSfFmiV7pqRk4f0y28Vq3z-5pQb6Vs+J1TotR4CShKwk5GecQ@mail.gmail.com> <201509202250.t8KMoC0h009296@fido.openend.se>
From Baladjy KICHENASSAMY <baladjy@gmail.com>
Date 2015-09-21 17:20 +0200
Subject Re: Postscript to pdf
Newsgroups comp.lang.python
Message-ID <mailman.55.1442906405.28679.python-list@python.org> (permalink)

Show all headers | View raw


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 <lac@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"])
>>
>>
>>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



-- 
KICHENASSAMY Baladjy
Ingénieur en Génie Mécanique
Spécialiste Contrôle Non Destructif et Qualification des procédés spéciaux
COSAC CND Niveau 2 RT et PT
Aircelle SAFRAN
Tel:06.03.72.53.12

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Postscript to pdf Bala Ji <baladjy@gmail.com> - 2015-09-20 09:20 -0700
  Re: Postscript to pdf Laura Creighton <lac@openend.se> - 2015-09-20 18:40 +0200
    Re: Postscript to pdf Bala Ji <baladjy@gmail.com> - 2015-09-20 09:50 -0700
      Re: Postscript to pdf Laura Creighton <lac@openend.se> - 2015-09-20 20:12 +0200
      Re: Postscript to pdf Laura Creighton <lac@openend.se> - 2015-09-20 21:09 +0200
      Re: Postscript to pdf Baladjy KICHENASSAMY <baladjy@gmail.com> - 2015-09-20 20:27 +0200
        Re: Postscript to pdf Christian Gollwitzer <auriocus@gmx.de> - 2015-09-21 15:39 +0200
      Re: Postscript to pdf Baladjy KICHENASSAMY <baladjy@gmail.com> - 2015-09-20 21:32 +0200
      Re: Postscript to pdf Laura Creighton <lac@openend.se> - 2015-09-20 21:52 +0200
      Re: Postscript to pdf Laura Creighton <lac@openend.se> - 2015-09-21 00:50 +0200
      Re: Postscript to pdf Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-20 20:25 -0400
      Re: Postscript to pdf Baladjy KICHENASSAMY <baladjy@gmail.com> - 2015-09-20 23:11 +0200
        Re: Postscript to pdf Nobody <nobody@nowhere.invalid> - 2015-09-21 13:56 +0100
      Re: Postscript to pdf Baladjy KICHENASSAMY <baladjy@gmail.com> - 2015-09-21 17:20 +0200
        Re: Postscript to pdf Christian Gollwitzer <auriocus@gmx.de> - 2015-09-23 08:40 +0200
        Re: Postscript to pdf mithra <curtis.rendon@gmail.com> - 2015-09-23 17:01 -0700
  Re: Postscript to pdf Terry Reedy <tjreedy@udel.edu> - 2015-09-21 00:17 -0400

csiph-web