[scribus] resizing objects script

Gregory Pittman gpittman at iglou.com
Fri Aug 3 00:22:58 UTC 2012


Here is a simple script I wrote to a simple task: resize an object, 
width and height, by a specified amount.
The default is 0.5, but you can do multiples, like 2.37

Seems to work on a variety of objects, including vector images, shapes, 
Bezier curves, arcs. It worked with a spiral, but had a redraw issue...?

Here it is:

****script follows********

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

# 
****************************************************************************
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
USA.
#
# 
****************************************************************************


"""

© 2012 by Gregory Pittman

Select an object, start script.

Enter a value to shrink/enlarge by, click Ok.



"""

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)

if not scribus.haveDoc():
     scribus.messageBox('Scribus - Script Error', "No document open", 
scribus.ICON_WARNING, scribus.BUTTON_OK)
     sys.exit(1)

if scribus.selectionCount() == 0:
     scribus.messageBox('Scribus - Script Error',
             "There is no object selected.\nPlease select a text frame 
and try again.",
             scribus.ICON_WARNING, scribus.BUTTON_OK)
     sys.exit(2)
if scribus.selectionCount() > 1:
     scribus.messageBox('Scribus - Script Error',
             "You have more than one object selected.\nPlease select one 
text frame and try again.",
             scribus.ICON_WARNING, scribus.BUTTON_OK)
     sys.exit(2)
selected_frame = scribus.getSelectedObject()
pageitems = scribus.getPageItems()
scribus.setRedraw(False)

dimensions = scribus.getSize(selected_frame) # (width, height)
factor = scribus.valueDialog("Resize Object", "Resize by multiple or 
decimal fraction", "0.5")
factor = float(factor)
newwidth = dimensions[0]*factor
newheight = dimensions[1]*factor
scribus.sizeObject(newwidth, newheight)

scribus.setRedraw(True)
scribus.redrawAll()


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


More information about the scribus mailing list