Comment imprimer avec python
Bonjour,
Je suis débutant python j'utilise la version 2.7.6.
Cependant je n'ai pas compris comment imprimer avec python.
Je suis sous linux Kubuntu 14.04.
J'utilise une imprimante réseau ?
Code:
lpd://192.168.0.45/binary_p1
Paquet installé :
Code:
1 2 3 4
| laurent@Laurent-Bureau:~$ sudo dpkg -l | grep lpr
ii lpr 1:2008.05.17+nmu1 amd64 BSD lpr/lpd line printer spooling system
ii mfc6490cwlpr 1.1.2-2 i386 Brother lpr Inkjet Printer Definitions
laurent@Laurent-Bureau:~$ |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| def licence():
global texte_imp
print "Licence"
filewin = Toplevel(root)
tex1 = Label(filewin, text='Licence \n', fg='black')
tex1.pack()
S = Scrollbar(filewin)
T = Text(filewin, height=80, width=100)
S.pack(side=RIGHT, fill=Y)
T.pack(side=LEFT, fill=Y)
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
texte_imp = """Ceci est mon texte abrégé pour effectuer un test d'impression
Article 12.
Sauf lorsqu'explicitement prévu par la Loi ou accepté par écrit, ni le détenteur des droits, ni quiconque autorisé à modifier et/ou redistribuer le Programme comme il est permis ci-dessus ne pourra être tenu pour responsable de tout dommage direct, indirect, secondaire ou accessoire (pertes financières dues au manque à gagner, à l'interruption d'activités ou à la perte de données, etc., découlant de l'utilisation du Programme ou de l'impossibilité d'utiliser celui-ci). """
T.insert(END, texte)
bouton1=Button(filewin,text=' Ok ',command=filewin.destroy)
bouton2=Button(filewin,text='Imprimer',command=imprimer)
texte = Label(filewin, text="", fg='black')
texte.pack()
bouton1.pack()
bouton2.pack()
mainloop( )
def imprimer():
import os
print 'Imprimer'
modele_commande = 'cat %s | lpr'
commande = modele_commande %(texte_imp)
os.popen(commande) |
retour:
Code:
1 2 3 4 5
| Imprimer
cat: GPL: Aucun fichier ou dossier de ce type
sh: 2: Introduction: not found
sh: 3: This: not found
sh: 5: Syntax error: word unexpected (expecting ")") |
Pour Linux j'ai trouvé que cette doc :
http://www.openvet.org/files/impress...c%20python.pdf
Pouvez-vous m'aiguiller ?
Merci.