Back to index

scribus-ng  1.3.4.dfsg+svn20071115
legende.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 """ When you have an image selected this script creates small text legende
00005 (caption) below the image. The new textframe contains name of the file. """
00006 
00007 import sys
00008 
00009 try:
00010     from scribus import *
00011 except ImportError:
00012     print "This script only runs from within Scribus."
00013     sys.exit(1)
00014 
00015 import os
00016 
00017 def main():
00018     userUnit = getUnit()
00019     setUnit(1)
00020     sel_count = selectionCount()
00021 
00022     if sel_count == 0:
00023         messageBox("legende.py",
00024                 "Please select the object to add a caption to before running this script.",
00025                 ICON_INFORMATION)
00026         sys.exit(1)
00027 
00028     x,y = getPosition()
00029     l,h = getSize()
00030     texte = getImageFile()
00031     image = os.path.basename(texte)
00032     a = createText(x,y+h+2,l,8)
00033     insertText(image,0,a)
00034     setTextAlignment(2,a)
00035     setFontSize(7,a)
00036     setUnit(userUnit)
00037 
00038 if __name__ == '__main__':
00039     main()