[scribus] another senseless script from Greg

"Christoph Schäfer" christoph-schaefer at gmx.de
Mon Aug 20 05:42:22 UTC 2012


Speaking of senseless scripts (sorry, extreme heat and air moisture are obviously taking their tolls), what about a fun tool like this one: http://www.rorohiko.com/wordpress/indesign-downloads/sudoku-generator/ ;)

Christoph


-------- Original-Nachricht --------
> Datum: Sun, 19 Aug 2012 21:29:02 -0400
> Von: Gregory Pittman <gpittman at iglou.com>
> An: Scribus User Mailing List <scribus at lists.scribus.net>
> Betreff: [scribus] another senseless script from Greg

> 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>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net



More information about the scribus mailing list