<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="Liberation Serif">Here is a script I wrote which
accomplishes this task, albeit with some limitations.<br>
The main one is that you must be using fixed linespacing. This
seems to be because when you use the getLineSpacing(), Scribus has
no idea you are using anything else.<br>
<br>
The script works by getting the linespacing, the number of lines
of text, the height of the frame, then using 1/2 the difference
between the frame height and total space taken by lines, resets
the Top distance.<br>
<br>
The other curious thing I haven't figured out is that when the
script runs it dutifully makes the new Top distance, but the text
stays put. I couldn't figure out any command in Scripter that
would fix this. What I did find out is that if you save the file,
close it, and reload, the text has moved to the middle. But it's
not just a display issue, since if you save to PDF before fixing
in some way, the PDF shows the text unshifted.<br>
I did find other workarounds, such as setting the Line Color or
Fill Color to something else, then back to where it was, then the
frame is redrawn and the text moves like it's should have.<br>
Also, clicking the Edit Shape button in Properties, then closing
fixed it.<br>
<br>
In the end, the simplest thing to do which works is to just run
the script again, in which case THEN the text is shifted. (weird)<br>
<br>
So, try it out, find other ways it doesn't work (I'm sure if you
have mixed up fonts in the frame it won't do a very good job then
either).<br>
<br>
Greg<br>
<br>
*****script below*****<br>
#!/usr/bin/env python<br>
# -*- coding: utf-8 -*-<br>
# centervert.py<br>
<br>
try:<br>
import scribus<br>
except ImportError:<br>
print "Unable to import the 'scribus' module. This script will
only run within"<br>
print "the Python interpreter embedded in Scribus. Try
Script->Execute Script."<br>
sys.exit(1)<br>
<br>
if not scribus.haveDoc():<br>
scribus.messageBox('Scribus - Script Error', "No document
open", scribus.ICON_WARNING, scribus.BUTTON_OK)<br>
sys.exit(1)<br>
<br>
if scribus.selectionCount() == 0:<br>
scribus.messageBox('Scribus - Script Error',<br>
"There is no object selected.\nPlease select a text
frame and try again.",<br>
scribus.ICON_WARNING, scribus.BUTTON_OK)<br>
sys.exit(2)<br>
if scribus.selectionCount() > 1:<br>
scribus.messageBox('Scribus - Script Error',<br>
"You have more than one object selected.\nPlease
select one text frame and try again.",<br>
scribus.ICON_WARNING, scribus.BUTTON_OK)<br>
sys.exit(2)<br>
textbox = scribus.getSelectedObject()<br>
pageitems = scribus.getPageItems()<br>
scribus.setRedraw(False)<br>
<br>
for item in pageitems:<br>
if (item[0] == textbox):<br>
if (item[1] != 4):<br>
scribus.messageBox('Scribus - Script Error', <br>
"This is not a textframe. Try again.",
scribus.ICON_WARNING, scribus.BUTTON_OK)<br>
sys.exit(2)<br>
<br>
lines = scribus.getTextLines(textbox)<br>
distances = scribus.getTextDistances(textbox)<br>
linespace = scribus.getLineSpacing(textbox)<br>
dimensions = scribus.getSize(textbox) # (width, height)<br>
if (scribus.textOverflows(textbox, 1) > 0):<br>
scribus.messageBox('User Error', "This frame is
already overflowing", scribus.ICON_WARNING, scribus.BUTTON_OK)<br>
sys.exit(2)<br>
newtopdist = (dimensions[1] - linespace * lines)/2<br>
scribus.setTextDistances(distances[0],distances[1],newtopdist,distances[3],textbox)<br>
<br>
scribus.setRedraw(True)<br>
<br>
<br>
</font>
</body>
</html>