tools/pythonpoint/demos/examples.py
branchpy33
changeset 3794 398ea04239b5
parent 3723 99aa837b6703
child 3800 e8547b00eb59
equal deleted inserted replaced
3793:cc3f9cc828f7 3794:398ea04239b5
     1 import string
       
     2 
       
     3 testannotations="""
     1 testannotations="""
     4 def annotations(canvas):
     2 def annotations(canvas):
     5     from reportlab.lib.units import inch
     3     from reportlab.lib.units import inch
     6     canvas.drawString(inch, 2.5*inch,
     4     canvas.drawString(inch, 2.5*inch,
     7        "setAuthor, setTitle, setSubject have no visible effect")
     5        "setAuthor, setTitle, setSubject have no visible effect")
   363 and she made 50 million when Hugh Hefner
   361 and she made 50 million when Hugh Hefner
   364 bought up the rights now
   362 bought up the rights now
   365 and she'll have fun fun fun
   363 and she'll have fun fun fun
   366 til her Daddy takes the keyboard away'''
   364 til her Daddy takes the keyboard away'''
   367 
   365 
   368 lyrics = string.split(lyrics, "\n")
   366 lyrics = lyrics.split("\n")
   369 testtextsize = """
   367 testtextsize = """
   370 def textsize(canvas):
   368 def textsize(canvas):
   371     from reportlab.lib.units import inch
   369     from reportlab.lib.units import inch
   372     from reportlab.lib.colors import magenta, red
   370     from reportlab.lib.colors import magenta, red
   373     canvas.setFont("Times-Roman", 20)
   371     canvas.setFont("Times-Roman", 20)
   784 
   782 
   785 # D = dir()
   783 # D = dir()
   786 g = globals()
   784 g = globals()
   787 Dprime = {}
   785 Dprime = {}
   788 from types import StringType
   786 from types import StringType
   789 from string import strip
       
   790 for a,b in g.items()):
   787 for a,b in g.items()):
   791     if a[:4]=="test" and type(b) is StringType:
   788     if a[:4]=="test" and type(b) is StringType:
   792         #print 'for', a
   789         #print 'for', a
   793         #print b
   790         #print b
   794         b = strip(b)
   791         b = b.strip()
   795         exec(b+'\n')
   792         exec(b+'\n')
   796 
   793 
   797 platypussetup = """
   794 platypussetup = """
   798 from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
   795 from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
   799 from reportlab.lib.styles import getSampleStyleSheet
   796 from reportlab.lib.styles import getSampleStyleSheet
   834 """
   831 """
   835 
   832 
   836 if __name__=="__main__":
   833 if __name__=="__main__":
   837     # then do the platypus hello world
   834     # then do the platypus hello world
   838     for b in platypussetup, platypusfirstpage, platypusnextpage, platypusgo:
   835     for b in platypussetup, platypusfirstpage, platypusnextpage, platypusgo:
   839         b = strip(b)
   836         b = b.strip()
   840         exec(b+'\n')
   837         exec(b+'\n')
   841     go()
   838     go()