Advertisement
Guest User

Python n°24 - Tableaux pyRTF

a guest
Aug 3rd, 2011
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. from PyRTF import *
  4.  
  5. def ExempleTableau():
  6.   docu = Document()
  7.   ss = docu.StyleSheet
  8.   section = Section()
  9.   docu.Sections.append(section)
  10.  
  11.   cote_fin  = BorderPS( width=20, style=BorderPS.SINGLE )
  12.   cote_epais = BorderPS( width=80, style=BorderPS.SINGLE )
  13.   bord_fin  = FramePS( cote_fin,    cote_fin,   cote_fin,   cote_fin )
  14.   bord_epais = FramePS( cote_epais, cote_epais, cote_epais, cote_epais )
  15.   bord_mixte = FramePS( cote_fin,   cote_epais, cote_fin,   cote_epais )
  16.  
  17.   tableau = Table(TabPS.DEFAULT_WIDTH * 3, TabPS.DEFAULT_WIDTH * 3, TabPS.DEFAULT_WIDTH * 3)
  18.   c1 = Cell( Paragraph( 'L1C1' ), bord_fin )
  19.   c2 = Cell( Paragraph( 'L1C2' ) )
  20.   c3 = Cell( Paragraph( 'L1C3' ), bord_epais )
  21.   tableau.AddRow( c1, c2, c3 )
  22.  
  23.   c1 = Cell( Paragraph( 'L2C1' ) )
  24.   c2 = Cell( Paragraph( 'L2C2' ) )
  25.   c3 = Cell( Paragraph( 'L2C3' ) )
  26.   tableau.AddRow( c1, c2, c3 )
  27.  
  28.   c1 = Cell( Paragraph( 'L3C1' ), bord_mixte )
  29.   c2 = Cell( Paragraph( 'L3C2' ) )
  30.   c3 = Cell( Paragraph( 'L3C3' ), bord_mixte )
  31.   tableau.AddRow( c1, c2, c3 )
  32.  
  33.   section.append(tableau)
  34.  
  35.   return docu
  36.  
  37. def OuvreFichier(nom):
  38.     return file('%s.rtf' % nom, 'w')
  39.  
  40. if __name__ == '__main__':
  41.     DR = Renderer()
  42.     docu = ExempleTableau()
  43.     DR.Write(docu, OuvreFichier('rtftable-a'))
  44.     print "Fini"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement