Caption
Jump to navigation
Jump to search
caption.py
Here is a script which allows you to choose the caption position in a dialog. If you enter something other than b/t/r/l it shouldn't do anything. This script is now included with versions 1.4.7svn and 1.5.3svn as Caption.py.
#!/usr/bin/env python # -*- coding: utf-8 -*- """ © 2017 Gregory Pittman caption.py Creates a text frame (caption) in selected location relative to one or more selected frames. """ try: import scribus except ImportError: print "Unable to import the 'scribus' module. This script will only run within" print "the Python interpreter embedded in Scribus. Try Script->Execute Script." sys.exit(1) numselect = scribus.selectionCount() count = 0 frames = [] if numselect == 0: scribus.messageBox('Selection Count', "You must have at least one image frame selected", scribus.ICON_WARNING, scribus.BUTTON_OK) sys.exit(2) captionloc = scribus.valueDialog("Caption Location","Where to put the caption(s) -\n B/T/R/L?", "b") captionloc = captionloc[0] location = captionloc.upper() pageunits = scribus.getUnit() scribus.setUnit(scribus.UNIT_POINTS) while count < numselect: frames.append(scribus.getSelectedObject(count)) count += 1 for frame in frames: fwidth, fheight = scribus.getSize(frame) fx, fy = scribus.getPosition(frame) if location == "B": textf = scribus.createText(fx, fy+fheight, fwidth, 24)# frame height set at 24 points elif location == "T": textf = scribus.createText(fx, fy-24, fwidth, 24) # frame height set at 24 points elif location == "R": textf = scribus.createText(fx + fwidth, fy, 150, 40)# frame width set at 150, height at 40 points elif location == "L": textf = scribus.createText(fx-150, fy + fheight - 40, 150, 40) # frame width set at 150, height at 40 points scribus.setUnit(pageunits) scribus.setRedraw(True)