home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / beeld / teken / scribus-1.3.3.9-win32-install.exe / share / samples / legende.py < prev    next >
Text File  |  2004-12-14  |  907b  |  40 lines

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. """ When you have an image selected this script creates small text legende
  5. (caption) below the image. The new textframe contains name of the file. """
  6.  
  7. import sys
  8.  
  9. try:
  10.     from scribus import *
  11. except ImportError:
  12.     print "This script only runs from within Scribus."
  13.     sys.exit(1)
  14.  
  15. import os
  16.  
  17. def main():
  18.     userUnit = getUnit()
  19.     setUnit(1)
  20.     sel_count = selectionCount()
  21.  
  22.     if sel_count == 0:
  23.         messageBox("legende.py",
  24.                 "Please select the object to add a caption to before running this script.",
  25.                 ICON_INFORMATION)
  26.         sys.exit(1)
  27.  
  28.     x,y = getPosition()
  29.     l,h = getSize()
  30.     texte = getImageFile()
  31.     image = os.path.basename(texte)
  32.     a = createText(x,y+h+2,l,8)
  33.     insertText(image,0,a)
  34.     setTextAlignment(2,a)
  35.     setFontSize(7,a)
  36.     setUnit(userUnit)
  37.  
  38. if __name__ == '__main__':
  39.     main()
  40.