Difference between revisions of "Creating Text Frames for Image Captions"
(Created page with "Here are a series of scripts which accomplish the simple task of creating a caption frame for images. You can either do frames one-by-one, or select a number of frames as long...")
Revision as of 16:16, 3 January 2017
Here are a series of scripts which accomplish the simple task of creating a caption frame for images. You can either do frames one-by-one, or select a number of frames as long as you want the captions in the same position relative to the image.
I tend to prefer simple scripts, with little or no input needed, which is why I made individual scripts for each position, but at the bottom, I'll show how to create one script which needs input to state which position to place the caption. The sizes and positions of frames can be changed according to your needs, and like any frame, can be edited afterward.
#!/usr/bin/env python # -*- coding: utf-8 -*- """ © 2017 Gregory Pittman bcaption.py Creates a text frame (caption) below 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) 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) textf = scribus.createText(fx, fy+fheight, fwidth, 24) scribus.setUnit(pageunits) scribus.setRedraw(True)