[scribus] Text Column Styles

Gregory Pittman gregp_ky at yahoo.com
Mon Jul 4 22:09:11 UTC 2011


On 07/04/2011 01:14 AM, Nik Trevallyn-Jones wrote:
>
> As an example, for a newsletter project that I have been involved with,
> we have determined that for the A4 pages we use, most frames (and almost
> *all* text frames) should have widths in multiples of 65mm - which
> comprises 60mm for the text, and 5mm for the gap between the text and
> the left and right borders (ie, two 2.5mm gaps); and therefore
> multi-column frames should have the column gap set to 5mm.
> And from this along with desired gaps to page edges, comes the 'correct'
> X-pos settings for most frames: 7.5mm, 72.5mm, or 137.5mm (this gives us
> a total gap of 10mm from page edge to left edge of the text).
>
> Hence for any frame (text or image) a single-column frame should be
> 65mm, a double-column frame should be 130mm, and a triple-column frame
> should be 195mm; and should have its X-pos set to one of 7.5mm, 72.5mm
> or 137.5mm.
>
Hi Nik,

I've taken your measurements here and made a script, appended to this 
note at the bottom, since it seemed like something others might be able 
to use and modify to their needs.

This only creates columns, sets the gaps and distances, and changes the 
width as needed. It adjusts the X-Pos according to the number of columns 
as you indicated above. It does not alter height or Y-Pos, and can be 
used with text already in the frame or none.

Various other things can be added, including more choices for the user. 
You might of course have a family of different scripts for different 
purposes or even different skills of the users. The getUnit/setUnit bits 
are because I generally don't use millimeters for my units.

Greg

I've appended as text, since sometimes attached files get removed. Just 
copy/paste to a new file so that the '#!/usr/bin/env python' is the 
first line of the file.

====script follows====

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

# news_frame.py
# 2011.07.04
# made for Nik Trevallyn-Jones
#
"""
This script will convert a selected text frame
to 1, 2 or 3-columns, with gap(s) of 5mm, text
distances of 2.5mm.

Does not check if selected object is text frame
or something else.

"""

import scribus

if scribus.haveDoc():
     if scribus.selectionCount() == 0:
         scribus.messageBox('Scribus - Script Error',
             "There is no object selected.\nPlease select one 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 
only one and try again.",
             scribus.ICON_WARNING, scribus.BUTTON_OK)
         sys.exit(2)
     units = scribus.getUnit()
     scribus.setUnit(1) # millimeters = 1
     selectedframe = scribus.getSelectedObject()
     xpos,ypos = scribus.getPosition(selectedframe)
     width,height = scribus.getSize(selectedframe)
     columns = 0
     while (columns < 1) or (columns > 3):
         columns = scribus.valueDialog('No. of Columns','How many 
columns?\n(1-3)','3')
         columns = int(columns)
     if (columns == 1):
         scribus.setTextDistances(2.5,2.5,0,0,selectedframe)
         scribus.setColumns(1,selectedframe)
         scribus.moveObjectAbs(137.5,ypos,selectedframe)
         scribus.sizeObject(65,height,selectedframe)
     if (columns == 2):
         scribus.setTextDistances(2.5,2.5,0,0,selectedframe)
         scribus.setColumns(2,selectedframe)
         scribus.setColumnGap(5,selectedframe)
         scribus.moveObjectAbs(72.5,ypos,selectedframe)
         scribus.sizeObject(130,height,selectedframe)
     if (columns == 3):
         scribus.setTextDistances(2.5,2.5,0,0,selectedframe)
         scribus.setColumns(3,selectedframe)
         scribus.setColumnGap(5,selectedframe)
         scribus.moveObjectAbs(7.5,ypos,selectedframe)
         scribus.sizeObject(195,height,selectedframe)
     scribus.setUnit(units)
     scribus.redrawAll()




More information about the scribus mailing list