def Header(): dataTableau = [] largeursColonnes = ( (420, 100) ) dateDuJour = DateEngFr(str(datetime.date.today())) dataTableau.append( (_(u"Réservations"), _(u"%s\nEdité le %s") % (UTILS_Organisateur.GetNom(), dateDuJour)) ) style = TableStyle([ ('BOX', (0,0), (-1,-1), 0.25, colors.black), ('VALIGN', (0,0), (-1,-1), 'TOP'), ('ALIGN', (0,0), (0,0), 'LEFT'), ('FONT',(0,0),(0,0), "Helvetica-Bold", 16), ('ALIGN', (1,0), (1,0), 'RIGHT'), ('FONT',(1,0),(1,0), "Helvetica", 6), ]) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.append(tableau) story.append(Spacer(0,20))
def Header(): dataTableau = [] largeursColonnes = ((420, 100)) dateDuJour = UTILS_Dates.DateEngFr(str(datetime.date.today())) dataTableau.append( (dictOptions["titre_texte"], _(u"%s\nEdité le %s") % (UTILS_Organisateur.GetNom(), dateDuJour))) style = TableStyle([ ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ('VALIGN', (0, 0), (-1, -1), 'TOP'), ('ALIGN', (0, 0), (0, 0), ConvertAlignement1(dictOptions["titre_alignement"])), ('FONT', (0, 0), (0, 0), "Helvetica-Bold", dictOptions["titre_taille_texte"]), ('ALIGN', (1, 0), (1, 0), 'RIGHT'), ('FONT', (1, 0), (1, 0), "Helvetica", 6), ]) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.append(tableau) story.append(Spacer(0, 20))
def Header(): dataTableau = [] largeursColonnes = ((420, 100)) dateDuJour = UTILS_Dates.DateEngFr(str(datetime.date.today())) if self.mode == "attente": titre = _(u"Inscriptions en attente") else: titre = _(u"Inscriptions refusées") dataTableau.append((titre, _(u"%s\nEdité le %s") % (UTILS_Organisateur.GetNom(), dateDuJour))) style = TableStyle([ ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ('VALIGN', (0, 0), (-1, -1), 'TOP'), ('ALIGN', (0, 0), (0, 0), 'LEFT'), ('FONT', (0, 0), (0, 0), "Helvetica-Bold", 16), ('ALIGN', (1, 0), (1, 0), 'RIGHT'), ('FONT', (1, 0), (1, 0), "Helvetica", 6), ]) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.append(tableau) story.append(Spacer(0, 20))
def Imprimer(self, event=None): # Création du PDF from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.styles import ParagraphStyle hauteur_page = A4[1] largeur_page = A4[0] # Initialisation du PDF nomDoc = FonctionsPerso.GenerationNomDoc("EVENEMENTS", "pdf") if sys.platform.startswith("win"): nomDoc = nomDoc.replace("/", "\\") doc = SimpleDocTemplate(nomDoc, pagesize=(largeur_page, hauteur_page), topMargin=30, bottomMargin=30, leftMargin=40, rightMargin=40) story = [] # Création du titre du document dataTableau = [] largeursColonnes = ((largeur_page - 175, 100)) dateDuJour = UTILS_Dates.DateEngFr(str(datetime.date.today())) dataTableau.append((_(u"Evènements"), _(u"%s\nEdité le %s") % (UTILS_Organisateur.GetNom(), dateDuJour))) style = TableStyle([ ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ('VALIGN', (0, 0), (-1, -1), 'TOP'), ('ALIGN', (0, 0), (0, 0), 'LEFT'), ('FONT', (0, 0), (0, 0), "Helvetica-Bold", 16), ('ALIGN', (1, 0), (1, 0), 'RIGHT'), ('FONT', (1, 0), (1, 0), "Helvetica", 6), ]) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.append(tableau) story.append(Spacer(0, 10)) # Intro styleA = ParagraphStyle(name="A", fontName="Helvetica", fontSize=6, spaceAfter=20) #story.append(Paragraph(self.labelParametres, styleA)) # Tableau dataTableau = [] largeurColonnesSuivantes = 70 largeurColonne1 = largeur_page - 80 - 1.0 * ( len(self.dictImpression["entete"]) - 1) * largeurColonnesSuivantes largeursColonnes = [ largeurColonne1, ] for x in range(0, len(self.dictImpression["entete"]) - 1): largeursColonnes.append(largeurColonnesSuivantes) # Entetes labels dataTableau.append(self.dictImpression["entete"]) # Contenu du tableau listeRubriques = ("contenu", "total") for rubrique in listeRubriques: listeLignes = self.dictImpression[rubrique] for ligne in listeLignes: dataTableau.append(ligne) positionLigneTotal = len(self.dictImpression["contenu"]) + 1 listeStyles = [ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), # Centre verticalement toutes les cases ('FONT', (0, 0), (-1, -1), "Helvetica", 7), # Donne la police de caract. + taille de police ('GRID', (0, 0), (-1, -1), 0.25, colors.black), # Crée la bordure noire pour tout le tableau ('ALIGN', (1, 0), (-1, -1), 'CENTRE'), # Centre les cases ('BACKGROUND', (0, 0), (-1, 0), (0.6, 0.6, 0.6)), # Donne la couleur de fond du label ('BACKGROUND', (0, positionLigneTotal), (-1, positionLigneTotal), (0.8, 0.8, 0.8)), # Donne la couleur de fond du total ] # Formatage des lignes "Activités" for indexColoration, typeColoration in self.dictImpression[ "coloration"]: if typeColoration == "activite": listeStyles.append( ('FONT', (0, indexColoration + 1), (-1, indexColoration + 1), "Helvetica-Bold", 7)) listeStyles.append( ('BACKGROUND', (0, indexColoration + 1), (-1, indexColoration + 1), (0.91, 0.91, 0.91))) if typeColoration == "regroup": listeStyles.append( ('FONT', (0, indexColoration + 1), (-1, indexColoration + 1), "Helvetica-Bold", 7)) listeStyles.append(('TEXTCOLOR', (0, indexColoration + 1), (-1, indexColoration + 1), (1, 1, 1))) listeStyles.append(('BACKGROUND', (0, indexColoration + 1), (-1, indexColoration + 1), (0, 0, 0))) # Création du tableau tableau = Table(dataTableau, largeursColonnes, repeatRows=1) tableau.setStyle(TableStyle(listeStyles)) story.append(tableau) story.append(Spacer(0, 20)) # Enregistrement du PDF doc.build(story) # Affichage du PDF FonctionsPerso.LanceFichierExterne(nomDoc)
def Imprimer(self, event=None): # Création du PDF from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak from reportlab.platypus.flowables import ParagraphAndImage, Image from reportlab.rl_config import defaultPageSize from reportlab.lib.units import inch, cm from reportlab.lib.utils import ImageReader from reportlab.lib import colors from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle self.hauteur_page = defaultPageSize[1] self.largeur_page = defaultPageSize[0] # Initialisation du PDF PAGE_HEIGHT = defaultPageSize[1] PAGE_WIDTH = defaultPageSize[0] nomDoc = FonctionsPerso.GenerationNomDoc("LISTE_PRESTATIONS_", "pdf") if sys.platform.startswith("win"): nomDoc = nomDoc.replace("/", "\\") doc = SimpleDocTemplate(nomDoc, topMargin=30, bottomMargin=30, leftMargin=40, rightMargin=40) story = [] largeurContenu = 520 # Création du titre du document dataTableau = [] largeursColonnes = ((420, 100)) dateDuJour = DateEngFr(str(datetime.date.today())) dataTableau.append( (_(u"Liste des prestations"), _(u"%s\nEdité le %s") % (UTILS_Organisateur.GetNom(), dateDuJour))) style = TableStyle([ ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ('VALIGN', (0, 0), (-1, -1), 'TOP'), ('ALIGN', (0, 0), (0, 0), 'LEFT'), ('FONT', (0, 0), (0, 0), "Helvetica-Bold", 16), ('ALIGN', (1, 0), (1, 0), 'RIGHT'), ('FONT', (1, 0), (1, 0), "Helvetica", 6), ]) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.append(tableau) story.append(Spacer(0, 10)) # Intro styleA = ParagraphStyle(name="A", fontName="Helvetica", fontSize=6, spaceAfter=20) story.append(Paragraph(self.labelParametres, styleA)) # Famille for dictFamille in self.listeImpression["donnees"]: # Init tableau dataTableau = [] largeursColonnes = [220, 220, 40, 40] dataTableau.append((dictFamille['nom'], dictFamille['adresse'], dictFamille['montant'], dictFamille['nombre'])) # Individu for dictIndividu in dictFamille["individus"]: dataTableau.append( (u" %s (%s)" % (dictIndividu["nom"], dictIndividu["date_naiss"]), "", "", "")) # Prestations for dictPrestation in dictIndividu["prestations"]: dataTableau.append( (u" " + dictPrestation["label"], dictPrestation["nomActivite"], dictPrestation["montant"], dictPrestation["nombre"])) couleurFond = (0.8, 0.8, 1) listeStyles = [ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), # Centre verticalement toutes les cases ('FONT', (0, 0), (-1, -1), "Helvetica", 7), # Donne la police de caract. + taille de police ('BOX', (0, 1), (-1, -1), 0.25, colors.black), # Crée la bordure noire pour tout le tableau ('ALIGN', (2, 0), (-1, -1), 'CENTRE'), # Ligne de labels colonne alignée au centre ('BOX', (0, 0), (-1, 0), 0.25, colors.black), # Crée la bordure noire du nom de famille ( 'FONT', (0, 0), (0, 0), "Helvetica-Bold", 8 ), # Donne la police de caract. + taille de police du titre de groupe ('BACKGROUND', (0, 0), (-1, 0), couleurFond), # Donne la couleur de fond du titre de groupe ('TOPPADDING', (0, 0), (-1, -1), 1), ('BOTTOMPADDING', (0, 0), (-1, -1), 1), ] # Création du tableau tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(TableStyle(listeStyles)) story.append(tableau) story.append(Spacer(0, 6)) # TOTAUX dataTableau = [] largeursColonnes = [220, 220, 40, 40] for ligne in self.listeImpression["totaux"]: dataTableau.append(ligne) couleurFond = (0.8, 0.8, 0.8) listeStyles = [ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), # Centre verticalement toutes les cases ('FONT', (0, 0), (-1, -1), "Helvetica", 7), # Donne la police de caract. + taille de police ('BOX', (0, 1), (-1, -1), 0.25, colors.black), # Crée la bordure noire pour tout le tableau ('ALIGN', (2, 0), (-1, -1), 'CENTRE'), # Ligne de labels colonne alignée au centre ('BOX', (0, 0), (-1, 0), 0.25, colors.black), # Crée la bordure noire du nom de famille ( 'FONT', (0, 0), (0, 0), "Helvetica-Bold", 8 ), # Donne la police de caract. + taille de police du titre de groupe ('BACKGROUND', (0, 0), (-1, 0), couleurFond), # Donne la couleur de fond du titre de groupe ('TOPPADDING', (0, 0), (-1, -1), 1), ('BOTTOMPADDING', (0, 0), (-1, -1), 1), ] # Création du tableau tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(TableStyle(listeStyles)) story.append(tableau) # Enregistrement du PDF doc.build(story) # Affichage du PDF FonctionsPerso.LanceFichierExterne(nomDoc)
def Imprimer(self): # Création du PDF from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak from reportlab.platypus.flowables import ParagraphAndImage, Image from reportlab.rl_config import defaultPageSize from reportlab.lib.pagesizes import A4 from reportlab.lib.units import inch, cm from reportlab.lib.utils import ImageReader from reportlab.lib import colors from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle hauteur_page = A4[0] largeur_page = A4[1] # Initialisation du PDF nomDoc = FonctionsPerso.GenerationNomDoc("synthese_modes_reglements", "pdf") if sys.platform.startswith("win"): nomDoc = nomDoc.replace("/", "\\") doc = SimpleDocTemplate(nomDoc, pagesize=(largeur_page, hauteur_page), topMargin=30, bottomMargin=30, leftMargin=40, rightMargin=40) story = [] # Création du titre du document dataTableau = [] largeursColonnes = ((largeur_page - 175, 100)) dateDuJour = DateEngFr(str(datetime.date.today())) dataTableau.append( (_(u"Synthèse des modes de règlements"), _(u"%s\nEdité le %s") % (UTILS_Organisateur.GetNom(), dateDuJour))) style = TableStyle([ ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ('VALIGN', (0, 0), (-1, -1), 'TOP'), ('ALIGN', (0, 0), (0, 0), 'LEFT'), ('FONT', (0, 0), (0, 0), "Helvetica-Bold", 16), ('ALIGN', (1, 0), (1, 0), 'RIGHT'), ('FONT', (1, 0), (1, 0), "Helvetica", 6), ]) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.append(tableau) story.append(Spacer(0, 10)) # Intro styleA = ParagraphStyle(name="A", fontName="Helvetica", fontSize=6, spaceAfter=20) story.append(Paragraph(self.labelParametres, styleA)) # Tableau dataTableau = [] largeursColonnes = [ 160, ] for x in range(0, len(self.dictImpression["entete"]) - 1): largeursColonnes.append(45) # Entetes labels dataTableau.append(self.dictImpression["entete"]) # Contenu du tableau listeRubriques = ("contenu", "total") for rubrique in listeRubriques: listeLignes = self.dictImpression[rubrique] for ligne in listeLignes: dataTableau.append(ligne) positionLigneTotal = len(self.dictImpression["contenu"]) + 1 listeStyles = [ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), # Centre verticalement toutes les cases ('FONT', (0, 0), (-1, -1), "Helvetica", 7), # Donne la police de caract. + taille de police ('GRID', (0, 0), (-1, -1), 0.25, colors.black), # Crée la bordure noire pour tout le tableau ('ALIGN', (0, 0), (-1, -1), 'CENTRE'), # Centre les cases ('BACKGROUND', (0, 0), (-1, 0), (0.6, 0.6, 0.6)), # Donne la couleur de fond du label ('BACKGROUND', (0, positionLigneTotal), (-1, positionLigneTotal), (0.6, 0.6, 0.6)), # Donne la couleur de fond du label ] # Formatage des lignes "Activités" for indexColoration in self.dictImpression["coloration"]: listeStyles.append( ('FONT', (0, indexColoration + 1), (-1, indexColoration + 1), "Helvetica-Bold", 7)) listeStyles.append(('BACKGROUND', (0, indexColoration + 1), (-1, indexColoration + 1), (0.8, 0.8, 0.8))) # Création du tableau tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(TableStyle(listeStyles)) story.append(tableau) story.append(Spacer(0, 20)) # Enregistrement du PDF doc.build(story) # Affichage du PDF FonctionsPerso.LanceFichierExterne(nomDoc)
def Apercu(self): """ Impression tableau de données """ if self.GetNumberRows() == 0 or self.GetNumberCols() == 0: dlg = wx.MessageDialog(self, _(u"Il n'y a rien à imprimer !"), "Erreur", wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return None avecCouleurs = True from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle def ConvertCouleur(couleur): r, g, b = couleur return r / 255.0, g / 255.0, b / 255.0 # Récupération des données du tableau tableau = self nbreColonnes = tableau.GetNumberCols() nbreLignes = tableau.GetNumberRows() # Initialisation du tableau story = [] dataTableau = [] listeCouleurs = [] # Création des colonnes largeursColonnes = [] largeurColonne = 33 largeurColonneLabel = 90 for col in range(0, nbreColonnes + 1): if col == 0: largeursColonnes.append(largeurColonneLabel) else: largeursColonnes.append(largeurColonne) listeStyles = [ ('GRID', (0, 0), (-1, -1), 0.25, colors.black), # Crée la bordure noire pour tout le tableau ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), # Centre verticalement toutes les cases ('ALIGN', (0, 0), (-1, 0), 'CENTRE'), # Centre les labels de colonne ('ALIGN', (1, 1), (-1, -1), 'CENTRE'), # Valeurs à gauche ('ALIGN', (0, 1), (0, -1), 'CENTRE'), # Colonne Label Ligne centrée ( 'FONT', (0, 0), (-1, -1), "Helvetica", 6 ), # Donne la police de caract. + taille de police de la ligne de total ( 'FONT', (0, 0), (-1, 0), "Helvetica-Bold", 6 ), # Donne la police de caract. + taille de police de la ligne de total ] # Création de l'entete valeursLigne = [ "", ] for numColonne in range(0, nbreColonnes): labelColonne = tableau.GetColLabelValue(numColonne) valeursLigne.append(labelColonne) dataTableau.append(valeursLigne) # Création des lignes for numLigne in range(0, nbreLignes): labelLigne = tableau.GetRowLabelValue(numLigne) valeursLigne = [ labelLigne, ] for numCol in range(0, nbreColonnes): valeurCase = tableau.GetCellValue(numLigne, numCol) couleurCase = tableau.GetCellBackgroundColour(numLigne, numCol) if couleurCase != (255, 255, 255, 255) and avecCouleurs == True: r, g, b = ConvertCouleur(couleurCase) listeStyles.append( ('BACKGROUND', (numCol + 1, numLigne + 1), (numCol + 1, numLigne + 1), (r, g, b))) if numLigne == 0: valeurCase = valeurCase.replace(" ", "\n") valeursLigne.append(valeurCase) dataTableau.append(valeursLigne) # Style du tableau style = TableStyle(listeStyles) # Création du tableau tableau = Table(dataTableau, largeursColonnes, hAlign='LEFT') tableau.setStyle(style) story.append(tableau) story.append(Spacer(0, 20)) # Calcul du format de la page tailleMarge = 20 if sum(largeursColonnes) > A4[0] - (tailleMarge * 2): hauteur, largeur = A4 else: largeur, hauteur = A4 # Création du titre du document dataTableau = [] largeurContenu = largeur - (tailleMarge * 2) largeursColonnes = ((largeurContenu - 100, 100)) dateDuJour = DateEngFr(str(datetime.date.today())) dataTableau.append( (_(u"Synthèse des consommations"), _(u"%s\nEdité le %s") % (UTILS_Organisateur.GetNom(), dateDuJour))) style = TableStyle([ ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ('VALIGN', (0, 0), (-1, -1), 'TOP'), ('ALIGN', (0, 0), (0, 0), 'LEFT'), ('FONT', (0, 0), (0, 0), "Helvetica-Bold", 16), ('ALIGN', (1, 0), (1, 0), 'RIGHT'), ('FONT', (1, 0), (1, 0), "Helvetica", 6), ]) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.insert(0, tableau) story.insert(1, Spacer(0, 10)) # Insertion du label Paramètres styleA = ParagraphStyle(name="A", fontName="Helvetica", fontSize=6, spaceAfter=20) story.insert(2, Paragraph(self.labelParametres, styleA)) # Enregistrement du PDF nomDoc = FonctionsPerso.GenerationNomDoc("SYNTHESE_CONSO", "pdf") if sys.platform.startswith("win"): nomDoc = nomDoc.replace("/", "\\") doc = SimpleDocTemplate(nomDoc, pagesize=(largeur, hauteur), leftMargin=tailleMarge, rightMargin=tailleMarge, topMargin=tailleMarge, bottomMargin=tailleMarge) doc.build(story) # Affichage du PDF FonctionsPerso.LanceFichierExterne(nomDoc)
def OnBoutonFichier(self, event): """ Génération d'un fichier normalisé """ # Validation des données if self.ValidationDonnees() == False: return False # Vérifie que des pièces existent if not (self.ctrl_pieces.GetObjects()): dlg = wx.MessageDialog( self, _(u"Vous devez ajouter au moins une pièce !"), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False # Récupération des infos sur la remise remise_nom = DLG_Saisie_lot_tresor_public.Supprime_accent( self.ctrl_nom.GetValue()) nom_fichier = remise_nom nomOrganisateur = UTILS_Organisateur.GetNom() # Génération des pièces jointes dict_pieces_jointes = False if self.ctrl_parametres.GetPropertyValue( "inclure_pieces_jointes") == True: dict_pieces_jointes = self.GenerationPiecesJointes() if dict_pieces_jointes == False: return False # Récupération des transactions à effectuer montantTotal = FloatToDecimal(0.0) nbreTotal = 0 listeAnomalies = [] listePieces = [] for track in self.ctrl_pieces.GetObjects(): montant = FloatToDecimal(track.montant) if track.analysePiece == False: listeAnomalies.append(u"%s : %s" % (track.libelle, track.analysePieceTexte)) # Objet de la pièce objet_piece = self.ctrl_parametres.GetPropertyValue("objet_piece") objet_piece = DLG_Saisie_lot_tresor_public.Supprime_accent( objet_piece).upper() objet_piece = objet_piece.replace("{NOM_ORGANISATEUR}", nomOrganisateur) objet_piece = objet_piece.replace("{NUM_FACTURE}", str(track.numero)) objet_piece = objet_piece.replace("{LIBELLE_FACTURE}", track.libelle) objet_piece = objet_piece.replace( "{MOIS}", str(self.ctrl_parametres.GetPropertyValue("mois"))) objet_piece = objet_piece.replace( "{MOIS_LETTRES}", DLG_Saisie_lot_tresor_public.GetMoisStr( self.ctrl_parametres.GetPropertyValue("mois"), majuscules=True, sansAccents=True)) objet_piece = objet_piece.replace( "{ANNEE}", str(self.ctrl_parametres.GetPropertyValue("exercice"))) # Création du libellé du prélèvement prelevement_libelle = self.ctrl_parametres.GetPropertyValue( "prelevement_libelle") prelevement_libelle = prelevement_libelle.replace( "{NOM_ORGANISATEUR}", nomOrganisateur) prelevement_libelle = prelevement_libelle.replace( "{OBJET_PIECE}", objet_piece) prelevement_libelle = prelevement_libelle.replace( "{LIBELLE_FACTURE}", track.libelle) prelevement_libelle = prelevement_libelle.replace( "{NUM_FACTURE}", str(track.numero)) prelevement_libelle = prelevement_libelle.replace( "{MOIS}", str(self.ctrl_parametres.GetPropertyValue("mois"))) prelevement_libelle = prelevement_libelle.replace( "{MOIS_LETTRES}", DLG_Saisie_lot_tresor_public.GetMoisStr( self.ctrl_parametres.GetPropertyValue("mois"), majuscules=True, sansAccents=True)) prelevement_libelle = prelevement_libelle.replace( "{ANNEE}", str(self.ctrl_parametres.GetPropertyValue("exercice"))) dictPiece = { "id_piece": str(track.IDfacture), "objet_piece": objet_piece, "num_dette": str(track.numero), "montant": str(montant), "sequence": track.prelevement_sequence, "prelevement": track.prelevement, "prelevement_date_mandat": str(track.prelevement_date_mandat), "prelevement_rum": track.prelevement_rum, "prelevement_bic": track.prelevement_bic, "prelevement_iban": track.prelevement_iban, "prelevement_titulaire": track.prelevement_titulaire, "prelevement_libelle": prelevement_libelle, "titulaire_civilite": track.titulaireCivilite, "titulaire_nom": track.titulaireNom, "titulaire_prenom": track.titulairePrenom, "titulaire_rue": track.titulaireRue, "titulaire_cp": track.titulaireCP, "titulaire_ville": track.titulaireVille, "idtiers_helios": track.idtiers_helios, "natidtiers_helios": track.natidtiers_helios, "reftiers_helios": track.reftiers_helios, "cattiers_helios": track.cattiers_helios, "natjur_helios": track.natjur_helios, "IDfacture": track.IDfacture, } listePieces.append(dictPiece) montantTotal += montant nbreTotal += 1 # Mémorisation de tous les données dictDonnees = { "nom_fichier": nom_fichier, "date_emission": UTILS_Dates.ConvertDateWXenDate( self.ctrl_parametres.GetPropertyValue( "date_emission")).strftime("%Y-%m-%d"), "date_envoi": UTILS_Dates.ConvertDateWXenDate( self.ctrl_parametres.GetPropertyValue("date_envoi")).strftime( "%Y-%m-%d"), "date_prelevement": UTILS_Dates.ConvertDateWXenDate( self.ctrl_parametres.GetPropertyValue( "date_prelevement")).strftime("%Y-%m-%d"), "id_poste": self.ctrl_parametres.GetPropertyValue("id_poste"), "id_collectivite": self.ctrl_parametres.GetPropertyValue("id_collectivite"), "code_collectivite": self.ctrl_parametres.GetPropertyValue("code_collectivite"), "code_budget": self.ctrl_parametres.GetPropertyValue("code_budget"), "exercice": str(self.ctrl_parametres.GetPropertyValue("exercice")), "mois": str(self.ctrl_parametres.GetPropertyValue("mois")), "id_bordereau": self.ctrl_parametres.GetPropertyValue("id_bordereau"), "montant_total": str(montantTotal), "objet_dette": self.ctrl_parametres.GetPropertyValue("objet_dette"), "code_prodloc": self.ctrl_parametres.GetPropertyValue("code_prodloc"), "code_etab": self.ctrl_parametres.GetPropertyValue("code_etab"), "pieces": listePieces, "pieces_jointes": dict_pieces_jointes, } if len(listeAnomalies) > 0: import wx.lib.dialogs as dialogs message = "\n".join(listeAnomalies) dlg = dialogs.MultiMessageDialog( self, _(u"Le fichier ne peut être généré en raison des anomalies suivantes :" ), caption=_(u"Génération impossible"), msg2=message, style=wx.ICON_ERROR | wx.OK, icon=None, btnLabels={wx.ID_OK: _(u"Fermer")}) dlg.ShowModal() dlg.Destroy() return # Génération du fichier XML doc = UTILS_Pes.GetXML(dictDonnees) xml = doc.toprettyxml(encoding="utf-8") # Validation XSD valide = UTILS_Pes.ValidationXSD(xml) if valide != True: liste_erreurs = valide dlg = DLG_Messagebox.Dialog( self, titre=_(u"Validation XSD"), introduction=_( u"Les %d anomalies suivantes ont été détectées :") % len(liste_erreurs), detail=u"\n".join(liste_erreurs), conclusion= _(u"Le fichier ne semble pas valide. Souhaitez-vous continuer quand même ?" ), icone=wx.ICON_EXCLAMATION, boutons=[_(u"Oui"), _(u"Non"), _(u"Annuler")]) reponse = dlg.ShowModal() dlg.Destroy() if reponse in (1, 2): return False # Demande à l'utilisateur le nom de fichier et le répertoire de destination wildcard = "Fichier XML (*.xml)|*.xml| All files (*.*)|*.*" sp = wx.StandardPaths.Get() cheminDefaut = sp.GetDocumentsDir() dlg = wx.FileDialog( None, message= _(u"Veuillez sélectionner le répertoire de destination et le nom du fichier" ), defaultDir=cheminDefaut, defaultFile=nom_fichier, wildcard=wildcard, style=wx.FD_SAVE) dlg.SetFilterIndex(0) if dlg.ShowModal() == wx.ID_OK: cheminFichier = dlg.GetPath() dlg.Destroy() else: dlg.Destroy() return # Le fichier de destination existe déjà : if os.path.isfile(cheminFichier) == True: dlg = wx.MessageDialog( None, _(u"Un fichier portant ce nom existe déjà. \n\nVoulez-vous le remplacer ?" ), _(u"Attention !"), wx.YES_NO | wx.NO_DEFAULT | wx.ICON_EXCLAMATION) if dlg.ShowModal() == wx.ID_NO: return False dlg.Destroy() else: dlg.Destroy() # Création du fichier texte f = open(cheminFichier, "w") try: if six.PY2: f.write(doc.toxml(encoding="ISO-8859-1")) else: #f.write(doc.toprettyxml(indent=" ")) f.write(doc.toxml()) finally: f.close() # Confirmation de création du fichier et demande d'ouverture directe txtMessage = _( u"Le fichier xml PES Recette ORMC a été créé avec succès.\n\nSouhaitez-vous visualiser son contenu maintenant ?" ) dlgConfirm = wx.MessageDialog( None, txtMessage, _(u"Confirmation"), wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) reponse = dlgConfirm.ShowModal() dlgConfirm.Destroy() if reponse == wx.ID_NO: return else: FonctionsPerso.LanceFichierExterne(cheminFichier)
def CreationPDF(self, nomDoc=FonctionsPerso.GenerationNomDoc("RELEVE_PRESTATIONS", "pdf"), afficherDoc=True): """ Création du PDF """ from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate, NextPageTemplate from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak from reportlab.platypus.flowables import ParagraphAndImage, Image from reportlab.platypus.frames import Frame, ShowBoundaryValue from reportlab.lib.pagesizes import A4 from reportlab.lib.units import inch, cm, mm from reportlab.lib.utils import ImageReader from reportlab.lib import colors from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.pdfgen.canvas import Canvas TAILLE_PAGE = A4 LARGEUR_PAGE = TAILLE_PAGE[0] HAUTEUR_PAGE = TAILLE_PAGE[1] # Initialisation du document if sys.platform.startswith("win") : nomDoc = nomDoc.replace("/", "\\") doc = SimpleDocTemplate(nomDoc, topMargin=30, bottomMargin=30, pagesize=TAILLE_PAGE, showBoundary=False) story = [] dictChampsFusion = {} largeurContenu = 520 # Recherche la couleur de titre couleur_fond_titre = ConvertCouleurWXpourPDF((255, 255, 255)) if self.dictOptionsImpression.has_key("couleur") : if self.dictOptionsImpression["couleur"] != False : couleur_fond_titre = ConvertCouleurWXpourPDF(self.dictOptionsImpression["couleur"]) paraStyleTitre = ParagraphStyle(name="titre", fontName="Helvetica-Bold", fontSize=12, #leading=7, spaceBefore=0, spaceafter=0, ) paraStyle = ParagraphStyle(name="compte", fontName="Helvetica", fontSize=9, #leading=7, spaceBefore=5, spaceafter=0, ) titreDocument = Paragraph(_(u"Relevé des prestations"), paraStyleTitre) texteTitulaire = Paragraph(u"%s" % self.dictTitulaires[self.IDfamille]["titulairesSansCivilite"], paraStyle) # Création du titre du document dataTableau = [] largeursColonnes = ( (420, 100) ) dateDuJour = DateEngFr(str(datetime.date.today())) dictChampsFusion["{DATE_EDITION_RELEVE}"] = dateDuJour dataTableau.append( ([titreDocument, texteTitulaire], _(u"%s\nEdité le %s") % (UTILS_Organisateur.GetNom(), dateDuJour)) ) style = TableStyle([ ('BOX', (0,0), (-1,-1), 0.25, colors.black), ('VALIGN', (0,0), (-1,-1), 'TOP'), ('ALIGN', (0,0), (0,0), 'LEFT'), ('FONT',(0,0),(0,0), "Helvetica-Bold", 16), ('ALIGN', (1,0), (1,0), 'RIGHT'), ('FONT',(1,0),(1,0), "Helvetica", 6), ]) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.append(tableau) story.append(Spacer(0,20)) # Nom du compte ## texteTitulaire = Paragraph(_(u"Compte de %s") % self.dictTitulaires[self.IDfamille]["titulairesSansCivilite"], paraStyle) ## dataTableau = [] ## largeursColonnes = ( (520,) ) ## dataTableau.append([texteTitulaire,]) ## style = TableStyle([ #### ('BOX', (0,0), (-1,-1), 0.25, colors.black), ## ('VALIGN', (0,0), (-1,-1), 'TOP'), ## ('ALIGN', (0,0), (0,0), 'LEFT'), ## ('FONT',(0,0),(0,0), "Helvetica-Bold", 16), ## ('FONT',(0,0),(0,0), "Helvetica", 6), ## ]) ## tableau = Table(dataTableau, largeursColonnes) ## tableau.setStyle(style) ## story.append(tableau) ## story.append(Spacer(0,20)) # Création des périodes total_reste_global = 0.0 dictPrestationsAffichees = {} for periode in self.listePeriodes : if periode["selection"] == True : # Récupération des paramètres de la période typeDonnees = periode["type"] dictPeriode = periode["periode"] dictOptions = periode["options"] date_debut = dictPeriode["date_debut"] date_fin = dictPeriode["date_fin"] # Impayés if dictOptions.has_key("impayes") and dictOptions["impayes"] == True : impayes = True else : impayes = False # ------------------------------------------------------------------------------------------------------- # ----------------------------------------- PRESTATIONS --------------------------------------- # ------------------------------------------------------------------------------------------------------- if typeDonnees == "prestations" : # Regroupement modeRegroupement = "date" if dictOptions.has_key("regroupement") and dictOptions["regroupement"] != None : modeRegroupement = dictOptions["regroupement"] detail = False else : detail = True if modeRegroupement == "date" : labelRegroupement = _(u"Date") if modeRegroupement == "mois" : labelRegroupement = _(u"Mois") if modeRegroupement == "annee" : labelRegroupement = _(u"Année") # Affichage des conso if dictOptions.has_key("conso") and dictOptions["conso"] == True : modeConso = True else : modeConso = False # Dessin du tableau de titre pour cette période dataTableau = [] if impayes == True : labelTitre = _(u"Prestations impayées - %s") % dictPeriode["label"] else : labelTitre = _(u"Prestations - %s") % dictPeriode["label"] dataTableau.append([labelTitre,]) listeStyles = [ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('GRID', (0, 0), (-1,-1), 0.25, colors.black), ('FONT', (0, 0), (-1, -1), "Helvetica", 9), ('ALIGN', (0, 0), (-1, -1), 'LEFT'), ('FONT', (0, 1), (-1, -1), "Helvetica", 8), ('BACKGROUND', (-1, -1), (-1, -1), couleur_fond_titre), ] tableau_titre = Table(dataTableau, [520,]) tableau_titre.setStyle(TableStyle(listeStyles)) # Dessin du tableau pour les prestations dataTableau = [] if detail == True : largeursColonnes = [60, 190, 120, 50, 50, 50] dataTableau.append([labelRegroupement, _(u"Prestation"), _(u"Individu"), _(u"Total dû"), _(u"Réglé"), _(u"Reste dû")]) else : largeursColonnes = [370, 50, 50, 50] dataTableau.append([labelRegroupement, _(u"Total dû"), _(u"Réglé"), _(u"Reste dû")]) paraStyle = ParagraphStyle(name="standard", fontName="Helvetica", fontSize=8, leading=10, #spaceBefore=8, spaceAfter=0, ) total_du = 0.0 total_regle = 0.0 total_reste = 0.0 # Regroupement dictRegroupement = {} for dictPrestation in self.listePrestations : valide = True date = dictPrestation["date"] montant = dictPrestation["montant"] montant_ventilation = dictPrestation["montant_ventilation"] reste_du = montant - montant_ventilation # Filtre impayes if impayes == True and reste_du <= 0.0 : valide = False # Filtre Date if date < date_debut or date > date_fin : valide = False if valide == True : # Création de la Key de regroupement if modeRegroupement == "date" : key = date if modeRegroupement == "mois" : key = (date.year, date.month) if modeRegroupement == "annee" : key = date.year # Mémorisation if dictRegroupement.has_key(key) == False : dictRegroupement[key] = [] dictRegroupement[key].append(dictPrestation) # Tri des keys listeKeys = dictRegroupement.keys() listeKeys.sort() # Parcours des éléments for key in listeKeys : listeLigne = [] # Key if type(key) == datetime.date : labelKey = DateEngFr(str(key)) if type(key) == tuple : labelKey = u"%s %d" % (LISTE_MOIS[key[1]-1], key[0]) if type(key) == int : labelKey = _(u"Année %d") % key texteKey = Paragraph(u"<para align='center'>%s</para>" % labelKey, paraStyle) listeLabels = [] listeIndividus = [] listeTotalDu = [] listeTotalRegle = [] listeTotalReste = [] total_du_groupe = 0.0 total_regle_groupe = 0.0 total_reste_groupe = 0.0 # Détail for dictPrestation in dictRegroupement[key] : # Calcul des montants montant = dictPrestation["montant"] montant_ventilation = dictPrestation["montant_ventilation"] reste_du = montant - montant_ventilation # Label de la prestation labelPrestation = dictPrestation["label"] if modeConso == True : liste_consommations = dictPrestation["liste_consommations"] if len(liste_consommations) > 0 : listeConsoTemp = [] doublons = False for dictConso in liste_consommations: nomUnite = dictConso["abregeUnite"] if nomUnite in listeConsoTemp : doublons = True listeConsoTemp.append(nomUnite) if len(listeConsoTemp) > 0 and doublons == False : labelPrestation = u"%s (%s)" % (labelPrestation, u"+".join(listeConsoTemp)) listeLabels.append(Paragraph(labelPrestation, paraStyle)) # Individu if dictPrestation["IDindividu"] != None and dictPrestation["IDindividu"] != 0 : texteIndividu = self.dictIndividus[dictPrestation["IDindividu"]]["prenom"] else : texteIndividu = u"-" listeIndividus.append(Paragraph(texteIndividu, paraStyle)) # Total dû listeTotalDu.append(Paragraph(u"<para align='right'>%.02f %s</para>" % (montant, SYMBOLE), paraStyle)) total_du += montant total_du_groupe += montant # Réglé listeTotalRegle.append(Paragraph(u"<para align='right'>%.02f %s</para>" % (montant_ventilation, SYMBOLE), paraStyle)) total_regle += montant_ventilation total_regle_groupe += montant_ventilation # Reste dû listeTotalReste.append(Paragraph(u"<para align='right'>%.02f %s</para>" % (reste_du, SYMBOLE), paraStyle)) total_reste += reste_du total_reste_groupe += reste_du total_reste_global += reste_du IDprestation = dictPrestation["IDprestation"] if dictPrestationsAffichees.has_key(IDprestation) == False : dictPrestationsAffichees[IDprestation] = 0 dictPrestationsAffichees[IDprestation] += 1 # Si détails ou non if detail == True : dataTableau.append([texteKey, listeLabels, listeIndividus, listeTotalDu, listeTotalRegle, listeTotalReste]) else : dataTableau.append([ texteKey, Paragraph(u"<para align='right'>%.02f %s</para>" % (total_du_groupe, SYMBOLE), paraStyle), Paragraph(u"<para align='right'>%.02f %s</para>" % (total_regle_groupe, SYMBOLE), paraStyle), Paragraph(u"<para align='right'>%.02f %s</para>" % (total_reste_groupe, SYMBOLE), paraStyle), ]) listeStyles = [ ('VALIGN', (0, 0), (-1, -1), 'TOP'), ('GRID', (0, 0), (-1,-1), 0.25, colors.black), ('FONT', (0, 0), (-1, 0), "Helvetica", 6), ('ALIGN', (0, 0), (-1, 0), 'CENTRE'), ('FONT', (0, 1), (-1, 1), "Helvetica", 8), ] if len(dataTableau) > 1 : story.append(tableau_titre) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(TableStyle(listeStyles)) story.append(tableau) # Insertion du total par période dataTableau = [] listeLigne = [ Paragraph(_(u"<para align='right'>Totaux :</para>"), paraStyle), Paragraph(u"<para align='right'>%.02f %s</para>" % (total_du, SYMBOLE), paraStyle), Paragraph(u"<para align='right'>%.02f %s</para>" % (total_regle, SYMBOLE), paraStyle), Paragraph(u"<para align='right'><b>%.02f %s</b></para>" % (total_reste, SYMBOLE), paraStyle), ] dataTableau.append(listeLigne) listeStyles = [ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('FONT', (0, 0), (-1, -1), "Helvetica", 8), ('GRID', (1, -1), (-1,-1), 0.25, colors.black), ('ALIGN', (-1, -1), (-1, -1), 'CENTRE'), ('BACKGROUND', (-1, 0), (-1, -1), couleur_fond_titre), ] # Création du tableau largeursColonnesTotal = [370, 50 , 50, 50] tableau = Table(dataTableau, largeursColonnesTotal) tableau.setStyle(TableStyle(listeStyles)) story.append(tableau) story.append(Spacer(0, 12)) # ------------------------------------------------------------------------------------------------------- # ----------------------------------------- FACTURES -------------------------------------------- # ------------------------------------------------------------------------------------------------------- if typeDonnees == "factures" : # Dessin du tableau de titre pour cette période dataTableau = [] if impayes == True : labelTitre = _(u"Factures impayées - %s") % dictPeriode["label"] else : labelTitre = _(u"Factures - %s") % dictPeriode["label"] dataTableau.append([labelTitre,]) listeStyles = [ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('GRID', (0, 0), (-1,-1), 0.25, colors.black), ('FONT', (0, 0), (-1, -1), "Helvetica", 9), ('ALIGN', (0, 0), (-1, -1), 'LEFT'), ('FONT', (0, 1), (-1, -1), "Helvetica", 8), ('BACKGROUND', (-1, -1), (-1, -1), couleur_fond_titre), ] tableau_titre = Table(dataTableau, [520,]) tableau_titre.setStyle(TableStyle(listeStyles)) # Dessin du tableau pour les prestations dataTableau = [] largeursColonnes = [60, 110, 200, 50, 50, 50] dataTableau.append([_(u"Date d'édition"), _(u"Numéro"), _(u"Période"), _(u"Total dû"), _(u"Réglé"), _(u"Reste dû")]) paraStyle = ParagraphStyle(name="standard", fontName="Helvetica", fontSize=8, leading=10, #spaceBefore=8, spaceAfter=0, ) total_du = 0.0 total_regle = 0.0 total_reste = 0.0 for dictFacture in self.listeFactures : valide = True date = dictFacture["date_edition"] montant = dictFacture["totalPrestations"] montant_ventilation = dictFacture["totalVentilation"] reste_du = montant - montant_ventilation # Filtre impayes if impayes == True and reste_du <= 0.0 : valide = False # Filtre Date if date < date_debut or date > date_fin : valide = False if valide == True : listeLigne = [] # Date d'édition listeLigne.append(Paragraph(u"<para align='center'>%s</para>" % DateEngFr(str(date)), paraStyle)) # Numéro de facture if dictFacture["IDprefixe"] != None : numero = u"%s-%06d" % (dictFacture["prefixe"], dictFacture["numero"]) else : numero = u"%06d" % dictFacture["numero"] listeLigne.append(Paragraph(_(u"Facture n°%s") % numero, paraStyle)) # Période facture listeLigne.append(Paragraph(_(u"Du %s au %s") % (DateEngFr(str(dictFacture["date_debut"])), DateEngFr(str(dictFacture["date_fin"]))), paraStyle)) # Total dû listeLigne.append(Paragraph(u"<para align='right'>%.02f %s</para>" % (montant, SYMBOLE), paraStyle)) total_du += montant # Réglé listeLigne.append(Paragraph(u"<para align='right'>%.02f %s</para>" % (montant_ventilation, SYMBOLE), paraStyle)) total_regle += montant_ventilation # Reste dû listeLigne.append(Paragraph(u"<para align='right'>%.02f %s</para>" % (reste_du, SYMBOLE), paraStyle)) total_reste += reste_du total_reste_global += reste_du for dictPrestation in dictFacture["listePrestations"] : IDprestation = dictPrestation["IDprestation"] if dictPrestationsAffichees.has_key(IDprestation) == False : dictPrestationsAffichees[IDprestation] = 0 dictPrestationsAffichees[IDprestation] += 1 dataTableau.append(listeLigne) listeStyles = [ ('VALIGN', (0, 0), (-1, -1), 'TOP'), ('GRID', (0, 0), (-1,-1), 0.25, colors.black), ('FONT', (0, 0), (-1, 0), "Helvetica", 6), ('ALIGN', (0, 0), (-1, 0), 'CENTRE'), ('FONT', (0, 1), (-1, 1), "Helvetica", 8), ] if len(dataTableau) > 1 : story.append(tableau_titre) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(TableStyle(listeStyles)) story.append(tableau) # Insertion du total par période dataTableau = [] listeLigne = [ Paragraph(_(u"<para align='right'>Totaux :</para>"), paraStyle), Paragraph(u"<para align='right'>%.02f %s</para>" % (total_du, SYMBOLE), paraStyle), Paragraph(u"<para align='right'>%.02f %s</para>" % (total_regle, SYMBOLE), paraStyle), Paragraph(u"<para align='right'><b>%.02f %s</b></para>" % (total_reste, SYMBOLE), paraStyle), ] dataTableau.append(listeLigne) listeStyles = [ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('FONT', (0, 0), (-1, -1), "Helvetica", 8), ('GRID', (1, -1), (-1,-1), 0.25, colors.black), ('ALIGN', (-1, -1), (-1, -1), 'CENTRE'), ('BACKGROUND', (-1, 0), (-1, -1), couleur_fond_titre), ] # Création du tableau largeursColonnesTotal = [370, 50 , 50, 50] tableau = Table(dataTableau, largeursColonnesTotal) tableau.setStyle(TableStyle(listeStyles)) story.append(tableau) story.append(Spacer(0, 12)) # ---------------------------- Insertion du total du document --------------------------- dataTableau = [] listeLigne = [ Paragraph(_(u"<para align='right'><b>Reste dû :</b></para>"), paraStyle), Paragraph(u"<para align='right'><b>%.02f %s</b></para>" % (total_reste_global, SYMBOLE), paraStyle), ] dataTableau.append(listeLigne) dictChampsFusion["{RESTE_DU}"] = u"%.02f %s" % (total_reste_global, SYMBOLE) listeStyles = [ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('FONT', (0, 0), (-1, -1), "Helvetica", 8), ('GRID', (1, -1), (-1,-1), 0.25, colors.black), ('ALIGN', (-1, -1), (-1, -1), 'CENTRE'), ('BACKGROUND', (-1, 0), (-1, -1), couleur_fond_titre), ] # Création du tableau largeursColonnesTotal = [370, 150] tableau = Table(dataTableau, largeursColonnesTotal) tableau.setStyle(TableStyle(listeStyles)) story.append(tableau) story.append(Spacer(0, 12)) # Vérifie que des prestations ne sont pas présentes dans plusieurs périodes : nbreDoublons = 0 for IDprestation, nbre in dictPrestationsAffichees.iteritems() : if nbre > 1 : nbreDoublons += 1 if nbreDoublons > 0 : if nbreDoublons == 1 : texte = _(u"Une prestation apparaît simultanément dans plusieurs périodes. Vérifiez votre paramétrage des périodes !") else : texte = _(u"%d prestations apparaissent simultanément dans plusieurs périodes. Vérifiez votre paramétrage des périodes !") % nbreDoublons dlg = wx.MessageDialog(None, texte, _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False # Enregistrement et ouverture du PDF try : doc.build(story) except Exception, err : print "Erreur dans ouverture PDF :", err if "Permission denied" in err : dlg = wx.MessageDialog(None, _(u"Noethys ne peut pas créer le PDF.\n\nVeuillez vérifier qu'un autre PDF n'est pas déjà ouvert en arrière-plan..."), _(u"Erreur d'édition"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return