[scribus] another senseless script from Greg

Gregory Pittman gpittman at iglou.com
Mon Aug 20 01:29:02 UTC 2012


Here is an intellectual exercise. Let's imagine you want to play with a 
layout by swapping images from one frame and another, maybe even frames 
on different pages.

Here is a script that does just that. If you don't like what you get, 
just run it again -- Undo seems to work, but AFAICT you have to undo 
twice to reverse the effects of the script. Note that the frames are not 
swapped, just the image content.

Greg

****script follows****

#!/usr/bin/env python
# -*- coding: utf-8  -*-


"""

© 2012 Gregory Pittman

swapimage.py

USAGE

Select 2 image frames, no more, no less, both must be image frames. Can 
be on different
pages.

Run the script, the images are swapped.

"""

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)

scribus.setRedraw(False)

if scribus.selectionCount() != 2:
     scribus.messageBox('Selection Count', "You must have 2 image frames 
selected",
                        scribus.ICON_WARNING, scribus.BUTTON_OK)
     sys.exit(2)

frame1 = scribus.getSelectedObject(0)
frame2 = scribus.getSelectedObject(1)

ftype1 = scribus.getObjectType(frame1)
ftype2 = scribus.getObjectType(frame2)
if ((ftype1 != "ImageFrame") or (ftype2 != "ImageFrame")):
     scribus.messageBox('Object Type', "Both selected objects must be 
image frames",
                        scribus.ICON_WARNING, scribus.BUTTON_OK)
     sys.exit(2)

filename1 = scribus.getImageFile(frame1)
filename2 = scribus.getImageFile(frame2)

scribus.loadImage(filename2, frame1)
scribus.loadImage(filename1, frame2)

scribus.setRedraw(True)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20120819/d983eb14/attachment.html>


More information about the scribus mailing list