View Issue Details

IDProjectCategoryView StatusLast Update
0006877ScribusScripterpublic2009-03-29 21:01
Reportergpittman Assigned Tocbradney  
Status closedResolutionfixed 
Product Version1.3.3.12svn 
Target Version1.3.3.13Fixed in Version1.3.3.13svn 
Summary0006877: trying to clean up and standardize the DocInfo in scripts
Descriptionhave developed a pattern to use for scripts for author(s), licensing, synopsis, requirements, usage.
Additional InformationWill gradually try to get all scripts that need this uploaded as they are completed. No changes in script behavior are being made here.
TagsNo tags attached.


2008-03-22 01:42 (2,449 bytes)   
#!/usr/bin/env python
# -*- coding: utf-8 -*-


(C)2006.03.04 Gregory Pittman

(C)2008.02.28 Petr Vanek - fileDialog replaces valueDialog

this version 2008.02.28

This program is free software; you can redistribute it and/or modify
it under the terms of the  GPL, v2 (GNU General Public License as published by
the Free Software Foundation, version 2 of the License), or any later version.
See the Scribus Copyright page in the Help Browser for further informaton 
about GPL, v2.


This script takes the current document and extracts all the text from text frames,
and also gets the pathnames to all images. This is then saved to a file named
by the user.


You must run from Scribus and must have a file open.


Start the script. A file dialog appears for the name of the file 
to save to. The above information is saved to the file.

# Craig Bradney, Scribus Team
# 10/3/08: Added to Scribus distribution "as was" from Scribus wiki for bug #6826, script is GPLd

import scribus

def exportText(textfile):
    page = 1
    pagenum = scribus.pageCount()
    T = []
    content = []
    while (page <= pagenum):
        d = scribus.getPageItems()
        strpage = str(page)
        T.append('Page '+ strpage + '\n\n')
        for item in d:
            if (item[1] == 4):
                contents = scribus.getAllText(item[0])
                if (contents in content):
                    contents = 'Duplication, perhaps linked-to frame'
                T.append(item[0]+': '+ contents + '\n\n')
            elif (item[1] == 2):
                imgname = scribus.getImageFile(item[0])
                T.append(item[0]+': ' + imgname + '\n')
        page += 1
    output_file = open(textfile,'w')
    endmessage = textfile + ' was created'
    scribus.messageBox("Finished", endmessage,icon=0,button1=1)

if scribus.haveDoc():
    textfile = scribus.fileDialog('Enter name of file to save to', \
                                  filter='Text Files (*.txt);;All Files (*)')
        if textfile == '':
            raise Exception
    except Exception, e:
        print e

    scribus.messageBox('Export Error', 'You need a Document open, and a frame selected.', \
                       icon=0, button1=1) (2,449 bytes)   

2008-03-22 01:43 (1,714 bytes)   
#!/usr/bin/env python
# -*- coding: utf-8 -*-


(C) 2007 Jeremy Brown

Craig Bradney, Scribus Team 10/3/08: Added to Scribus distribution 
"as was" from Scribus wiki for bug #6826.

This program is free software; you can redistribute it and/or modify
it under the terms of the  GPL, v2 (GNU General Public License as published by
the Free Software Foundation, version 2 of the License), or any later version.
See the Scribus Copyright page in the Help Browser for further informaton 
about GPL, v2.


Must be run from Scribus. You should have a document open with items selected. 
Script fails with no output if these are not met.


This script unflips all the items by switching their horizontal and vertical flip 
flags to False.  One might typically use this after you have grouped a number of 
items on the page, then flipped the group so the positions are a mirror image of
the original.  Unfortunately this flips the content as well, so this script 
flips the content back.


Select the items you wish to have their content flipped to their original state. If you
also Group them, the script will run more reliably. Run the script.


from scribus import *
if haveDoc():
    nbrSelected = selectionCount()
    objList = []
    for i in range(nbrSelected):
    for i in range(nbrSelected):
            obj = objList[i]
            setProperty(obj, "m_ImageIsFlippedH", False)
            setProperty(obj, "m_ImageIsFlippedV", False)
            moveObject(1, 0, obj)
            moveObject(-1, 0, obj)
            nothing = "nothing" (1,714 bytes)   

2008-03-22 02:33 (5,542 bytes)   
#!/usr/bin/env python
# -*- coding: utf-8 -*-



(C) 2006 Rüdiger Härtel <r_haertel [at] gmx [dot] de>

Craig Bradney, Scribus Team
10/3/08: Added to Scribus distribution "as was" from Scribus wiki for bug #6826, script is GPLd

This program is free software; you can redistribute it and/or modify
it under the terms of the  GPL, v2 (GNU General Public License as published by
the Free Software Foundation, version 2 of the License), or any later version.
See the Scribus Copyright page in the Help Browser for further informaton 
about GPL, v2.


This script draws a grid-like structure, specifically in this case a grid formed
from individual horizontal and vertical lines.


You must run this from Scribus, and have a document open. You must also have tkinter
installed on your system.


You are presented with a Tk dialog in which there are default values for X-Pos, Y-Pos 
of the left upper corner, the overall width and height of the grid, and the x and y 
spacing (X-step and Y-step). 


Since the same defaults are used regardless of page units, for some units these may 
be unrealistic. The numbers are defined as integers, so decimals cannot be entered - 
the script stalls in this case. The grid is made up of individual lines, so be 
sure to group them to move the grid en bloc.


import sys

    import scribus
except ImportError,err:
    print 'This Python script is written for the Scribus scripting interface.'
    print 'It can only be run from within Scribus.'

    # I wish PyQt installed everywhere :-/
    from Tkinter import *
    from tkFont import Font
except ImportError:
    print "This script requires Python's Tkinter properly installed."
    messageBox('Script failed',
               'This script requires Python\'s Tkinter properly installed.',

def grid(x,y,width,height,xstep,ystep,color):
    """ """
    xend = x + width
    yend = y + height
    for _x in range(x,xend+1,xstep):
         line = scribus.createLine(_x,y,_x,yend)
         scribus.setLineColor(color, line)
    for _y in range(y,yend+1,ystep):
         line = scribus.createLine(x,_y,xend,_y)
         scribus.setLineColor(color, line)

class TkGrid(Frame):
    """ GUI interface for Scribus calendar wizard.
        It's ugly and very simple. I can say I hate Tkinter :-/"""
    def __init__(self, master=None):
        """ Setup the dialog """
        # reference to the localization dictionary
        self.key = 'default'
        Frame.__init__(self, master)
        self.master.title('Scribus Grid Wizard')
        #define variables
        self.x = IntVar()
        self.y = IntVar()
        self.w = IntVar()
        self.h = IntVar()
        self.xs = IntVar()
        self.ys = IntVar()
        # default values
        #define widgets
        self.xLabel = Label(self, text='x-Pos')
        self.yLabel = Label(self, text='y-Pos')
        self.wLabel = Label(self, text='Width')
        self.hLabel = Label(self, text='Height')
        self.xsLabel = Label(self, text='x-Step')
        self.ysLabel = Label(self, text='y-Step')
        self.xEntry = Entry(self, textvariable=self.x, width=4)
        self.yEntry = Entry(self, textvariable=self.y, width=4)
        self.wEntry = Entry(self, textvariable=self.w, width=4)
        self.hEntry = Entry(self, textvariable=self.h, width=4)
        self.xsEntry = Entry(self, textvariable=self.xs, width=4)
        self.ysEntry = Entry(self, textvariable=self.ys, width=4)
        self.okButton = Button(self, text="   OK   ", width=6, command=self.okButon_pressed)
        self.cancelButton = Button(self, text="Cancel", command=self.quit)

    def okButon_pressed(self):

    def quit(self):

def main():
    """ Application/Dialog loop with Scribus sauce around """
    if scribus.haveDoc() == 0:
        scribus.messageBox("Error", "Please create a Document", ICON_WARNING, BUTTON_OK)
        scribus.statusMessage('Running script...')
        root = Tk()
        app = TkGrid(root)
        if scribus.haveDoc():

if __name__ == '__main__':
    main() (5,542 bytes)   


2008-03-22 02:34

developer   ~0019258

for added a new category: LIMITATIONS


2008-03-22 14:27

developer   ~0019260

Will add
This one also needed some fixes for 1.3.3.x -- file dialog did not appear.
Also changed "from scribus import *" to "import scribus"

2008-03-22 14:28 (3,028 bytes)   
#!/usr/bin/env python
# -*- coding: utf-8 -*-


(C)2006 Konrad Stania

(C)2008 Gregory Pittman - fixes for version 1.3.3.x

This program is free software; you can redistribute it and/or modify
it under the terms of the  GPL, v2 (GNU General Public License as published by
the Free Software Foundation, version 2 of the License), or any later version.
See the Scribus Copyright page in the Help Browser for further informaton 
about GPL, v2.


You must run from Scribus, and have a document open.


This script will do an automatic import of an image to a frame, with standard settings.

Original German: 
Diese Skript importiert ein Bild und setzt es auf die akutelle Seite.
Der Bildrahmen wird dem Bild angepasst und in den nicht-proportionalen Modus
gesetzt, das heisst, beliebige Verzerrungen sind moeglich.

Um das Bild proportional zu vergroessern, die STRG-Taste beim Bearbeiten druecken.


Start script. A file dialog appears for selecting your image. Save to select -- if no file 
is selected or you click Cancel, a frame is created with no image.


Some adjustments may be made in the height of your frame in order to make X- and Y-scaling 
the same - width will remain 80% of page size. This is because Scripter does not have a 
command for Adjust Frame to Image. Note that Scale Image to Frame is set, but 
Proportional is not, in case you decide to resize the frame.


# Craig Bradney, Scribus Team
# 10/3/08: Added to Scribus distribution "as was" from Scribus wiki for bug #6826, script is GPLd

import sys

    import scribus
except ImportError:
    print "This script only runs from within Scribus."
def main():

    pageX,pageY = scribus.getPageSize()
    ImageFileName = scribus.fileDialog("Image Import", 'Images(*.jpg *.png *.tif *.pdf *.JPG *.PNG *.TIF *.PDF *.jpeg *.JPEG)',"" ,haspreview=1, issave = 0)
    Breite = pageX*0.8
    Hoehe = Breite
    if pageX >= pageY:
       Breite = pageY*0.8
       Hoehe = Breite

    ImageFrame = scribus.createImage(pageX/2 - Breite/2, pageY/2 - Hoehe/2, Breite, Hoehe)
    scribus.loadImage(ImageFileName, ImageFrame)
    scribus.setScaleImageToFrame(True, False,ImageFrame)
    scribus.setFillColor("None", ImageFrame)
    scribus.setLineColor("None", ImageFrame)
    scaleX,scaleY = scribus.getImageScale(ImageFrame)

    if scaleX > scaleY:
       Breite = Breite * scaleY / scaleX
       scribus.sizeObject(Breite, Hoehe, ImageFrame)
       scribus.setScaleImageToFrame(True, False,ImageFrame)

    if scaleX < scaleY:
       Hoehe = Hoehe * scaleX / scaleY
       scribus.setScaleImageToFrame(True, False,ImageFrame)
       scribus.sizeObject(Breite, Hoehe, ImageFrame)

if __name__ == '__main__':
    if scribus.haveDoc():
        scribus.messageBox("Image Import", "You need to have a document open <i>before</i> you can run this script succesfully.", scribus.ICON_INFORMATION) (3,028 bytes)   


2008-03-22 14:38

developer   ~0019261

Someone please delete so I can change to the file dialog to select more image types.
Also, would it be useful to adopt Konrad Stania's work around for Adjust Frame to Image using image scaling? I think that's pretty clever.


2008-03-22 19:10

developer   ~0019265

Ok, I've modified the script to automatically adjust infobox height for images. Waiting for to be deleted so I can upload the new version.

2008-03-22 23:08 (8,499 bytes)   
#!/usr/bin/env python
# -*- coding: utf-8  -*-


(C) 2005 by Thomas R. Koll, <>,
Craig Bradney, Scribus Team 10/3/08: Added to Scribus distribution "as was" from Scribus wiki for bug #6826

(c) 2008 modifications, additional features by Gregory Pittman
Craig Bradney, Scribus Team
20/3/08: Replaced previous version in Scribus distribution from Scribus wiki for bug #6869

This program is free software; you can redistribute it and/or modify
it under the terms of the  GPL, v2 (GNU General Public License as published by
the Free Software Foundation, version 2 of the License), or any later version.
See the Scribus Copyright page in the Help Browser for further informaton 
about GPL, v2.


A simple script for exact placement and sizing of a frame (infobox)
over the current textbox, asking the user for the width
of the infobox (number of columns) and in which column to place it.

Some enhancements (2008):

* You can now create a text frame or an image frame, and also load
an image.

* More than one infobox can be added to a text frame (related to change
in the naming scheme).

* Height and Y-Pos of top of infobox can be specified.

* Works with any page unit - pts, mm, in, picas, cm, or ciceros.

* Infobox has Text Flows Around Frame activated, also 
Scale Image to Frame for images. 

* In addition, the script also has a workaround for Adjust Frame to Image, 
so that a loaded image will adjust frame height automatically.


Must be used in Scribus and must have document open with text frame selected. 
Frame can have one or more columns, and is not required to have content.


Select a textframe, start the script.

Default name for the infobox is "'infobox' + index + name_of_selected_frame", 
but this can be changed.

Select height (defaults to height of selected frame), then Y-Pos distance 
from top of page (defaults to top of selected frame).

In the dialog titled "Frame Type"

* Enter 'text' (no quotes) for a text infobox - this is the default.

* Enter 'imageL' for an image infobox AND to bring up a file dialog to load an image.

* Enter anything else, even blank, for empty image infobox.

Since a unique name is generated for each infobox, you can run this again for 
the same selected frame.


    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."

def main(argv):
    unit = scribus.getUnit()
    units = [' pts','mm',' inches',' picas','cm',' ciceros']
    unitlabel = units[unit]
    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)
    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)
    textbox = scribus.getSelectedObject()
    pageitems = scribus.getPageItems()
    boxcount = 1
    for item in pageitems:
        if (item[0] == textbox):
            if (item[1] != 4):
                scribus.messageBox('Scribus - Script Error', 
                          "This is not a textframe. Try again.", scribus.ICON_WARNING, scribus.BUTTON_OK)

# While we're finding out what kind of frame is selected, we'll also make sure we
# will come up with a unique name for our infobox frame - it's possible we may want
# more than one for a multicolumn frame.
        if (item[0] == ("infobox" + str(boxcount) + textbox)):
                boxcount += 1
    left, top = scribus.getPosition(textbox)
    o_width, o_height = scribus.getSize(textbox)
    o_cols = int(scribus.getColumns(textbox))
    o_gap = scribus.getColumnGap(textbox)
    columns_width = 0
    column_pos = -1
    o_colwidth = (o_width - ((o_cols - 1) * o_gap)) / o_cols
    if (o_cols > 1):
        while (columns_width > o_cols or columns_width < 1):
            columns_width = scribus.valueDialog('Width',
                                            'How many columns width shall the '+
                                            'box be (max ' + str(o_cols) + ')?','1')
            columns_width = int(columns_width)
        if (columns_width < o_cols):
            max = o_cols - columns_width
            while (column_pos > max or column_pos < 0):
                column_pos = scribus.valueDialog('Placement',
                                         'In which column do you want '
                                         'to place the box (1 to ' +
                                         str(o_cols) + ')?','1')
                column_pos = int(column_pos) - 1 
    if (o_cols == 1):
	columns_width = 1
        column_pos = 0
    new_height = 0
    while (new_height == 0):
        new_height = scribus.valueDialog('Height','Your frame height is '+ str(o_height) +
                                                 unitlabel +'. How tall\n do you want your ' +
                                                 'infobox to be in '+ unitlabel +
                                         '?\nIf you are going to load an image,\nno need to change this setting',
    new_height_float = float(new_height)
    new_top = -1
    while (new_top < 0):
        new_top = scribus.valueDialog('Y-Pos','The top of your infobox is currently\n'+ str(top) +
                                                 unitlabel +'. Where do you want \n' +
                                                 'the top to be in '+ unitlabel +'?', str(top))
    framename = scribus.valueDialog('Name of Frame','Name your frame or use this default name',"infobox" + str(boxcount) + textbox)
    frametype = 'text'
    frametype = scribus.valueDialog('Frame Type',
                                    'Change to anything other\n than "text" for image frame.\nEnter "imageL" to also load an image',
    new_width = columns_width * o_colwidth + (columns_width-1) * o_gap
    new_left = left + ((column_pos) * o_colwidth) + ((column_pos) * o_gap)
    if (frametype == 'text'):
        new_textbox = scribus.createText(new_left, float(new_top), new_width, new_height_float, framename)
        scribus.setColumnGap(0, new_textbox)
        scribus.setColumns(1, new_textbox)
        scribus.textFlowsAroundFrame(new_textbox, 1)
        new_image = scribus.createImage(new_left, float(new_top), new_width, new_height_float, framename)
        if (frametype == 'imageL'):
            imageload = scribus.fileDialog('Load image','Images(*.jpg *.png *.tif *.pdf *.JPG *.PNG *.TIF *.PDF *.jpeg *.JPEG)',haspreview=1)
            scribus.loadImage(imageload, new_image)
        scribus.textFlowsAroundFrame(new_image, 1)
        scribus.setScaleImageToFrame(scaletoframe=1, proportional=0, name=new_image)
        scaleX,scaleY = scribus.getImageScale(new_image)
# this was borrowed from as a workaround for Adjust Frame to Image,
# modified to maintain the width as determined by column specs
        if (scaleX > scaleY):
            new_height_float = new_height_float * scaleX / scaleY
            scribus.sizeObject(new_width, new_height_float, new_image)
            scribus.setScaleImageToFrame(True, False, new_image)

        if (scaleX < scaleY):
            new_height_float = new_height_float * scaleX / scaleY
            scribus.setScaleImageToFrame(True, False, new_image)
            scribus.sizeObject(new_width, new_height_float, new_image)

if __name__ == '__main__':
    # This script makes no sense without a document open
    if not scribus.haveDoc():
        scribus.messageBox('Scribus - Script Error', "No document open", scribus.ICON_WARNING, scribus.BUTTON_OK)
    # Disable redraws
    # Run the main script, ensuring redraws are re-enabled even if the
    # script aborts with an exception, and don't fail with an exception
    # even if the document is closed while the script runs.
            pass (8,499 bytes)   


2008-03-22 23:09

developer   ~0019269

New uploaded


2009-02-22 23:08

administrator   ~0021197

[00:07] <MrB> FeistyDragoon, can u please check 0006877 and the included scripts in 1.3.3.x svn? the bug has been resolved however I dont believe the files were ever updated from the bug into svn
[00:07] <FeistyDragoon> k
[00:07] <MrB> FeistyDragoon, and if u have 1.3.5svn compatible versions, add those too?


2009-02-23 00:08

developer   ~0021199

Yes, you are right, MrB.
Either these weren't updated or were reverted. The exception is, which is the correct one in both 1.3.3.xsvn and 1.3.5svn.

I think we may have decided to delete, since it was not felt to be such an especially useful script.

I will have to check to see if the others work in 1.3.5svn.


2009-02-23 00:26

developer   ~0021201 seems to work Ok in 1.3.5svn. does not work in 1.3.5svn -- will see if I can figure out why.


2009-02-23 00:50

developer   ~0021202 does indeed work in, and curiously when the image is imported, Proportional is set, while it isn't in 1.3.3.xsvn (maybe different default behavior).

This having been said, the script is a bit clumsy in the way it adjusts the size of the frame to the image. It would be better, I think, to use the PIL method I used in This way, you can center every picture. Right now, they don't get centered when the picture is taller than it is wide.

Will work on this.


2009-03-28 14:29

developer   ~0021432

I have reworked (
1. Use PIL to get image size
2. Fix a problem with frames when image taller than wide
3. Got rid of readjustment of frame size - no longer needed
4. Made Doc Info more informative

This also works in 1.3.5svn

2009-03-28 14:29



2009-03-28 15:45

developer   ~0021433

I cannot seem to get to work in 1.3.5svn.

I think the problem is with setProperty, which seems to be nonfunctional in 1.3.5svn.


2009-03-28 15:55

developer   ~0021434


1. Except for, the above scripts have not been added to current svn of 1.3.3.x and 1.3.5
2. is not felt to be needed in either version
3. needs to be replaced by above version in both versions
3. should be replaced by in both versions
4. does not work in 1.3.5svn, so should not be included in that version at this time, but can replace it in 1.3.3.x

Issue History

Date Modified Username Field Change
2008-03-22 01:42 gpittman New Issue
2008-03-22 01:42 gpittman File Added:
2008-03-22 01:43 gpittman File Added:
2008-03-22 01:43 gpittman File Added:
2008-03-22 01:45 christoph_s Status new => assigned
2008-03-22 01:45 christoph_s Assigned To => plinnell
2008-03-22 02:33 gpittman File Added:
2008-03-22 02:34 gpittman Note Added: 0019258
2008-03-22 14:27 gpittman Note Added: 0019260
2008-03-22 14:28 gpittman File Added:
2008-03-22 14:38 gpittman Note Added: 0019261
2008-03-22 19:10 gpittman Note Added: 0019265
2008-03-22 20:23 plinnell File Deleted:
2008-03-22 23:08 gpittman File Added:
2008-03-22 23:09 gpittman Note Added: 0019269
2009-01-01 21:58 plinnell Status assigned => resolved
2009-01-01 21:58 plinnell Fixed in Version =>
2009-01-01 21:58 plinnell Resolution open => fixed
2009-02-22 23:08 cbradney Assigned To plinnell =>
2009-02-22 23:08 cbradney Note Added: 0021197
2009-02-22 23:08 cbradney Status resolved => feedback
2009-02-22 23:08 cbradney Resolution fixed => reopened
2009-02-23 00:08 gpittman Note Added: 0021199
2009-02-23 00:26 gpittman Note Added: 0021201
2009-02-23 00:50 gpittman Note Added: 0021202
2009-03-15 01:36 christoph_s Target Version =>
2009-03-28 14:29 gpittman Note Added: 0021432
2009-03-28 14:29 gpittman File Added:
2009-03-28 15:45 gpittman Note Added: 0021433
2009-03-28 15:55 gpittman Note Added: 0021434
2009-03-29 20:22 cbradney Status feedback => assigned
2009-03-29 20:22 cbradney Assigned To => cbradney
2009-03-29 20:59 cbradney Status assigned => resolved
2009-03-29 20:59 cbradney Resolution reopened => fixed
2009-03-29 21:01 cbradney Status resolved => closed