View Issue Details

IDProjectCategoryView StatusLast Update
0016947ScribusScripterpublic2023-05-28 23:43
ReporterDavidMiller Assigned Tojghali  
Status closedResolutionno change required 
PlatformMacintoshOSmacOSOS Version11.7.6
Summary0016947: Scribus text export script not working
DescriptionHello, relative newbie to Scribus here with a problem exporting text from a file using the script here ( This is in Scribus 1.5.8. I copied and pasted the script into a text file (attached) and saved it to the Scribus scripts folder and I can see it in the Scripts menu. But when I try running it, it returns the following error. I'm no Python export so have no idea how to fix this or even if it can be fixed. I'd be grateful for any pointers on how to fix (apart from learning Python which I will get round to).

Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "<string>", line 50
    except Exception, e: # in case of syntax error, rather use : "except Exception as e :"
SyntaxError: invalid syntax
Additional InformationI wonder if this may have something to do with installing Scribus from a DMG file. Maybe some Python dependency isn't included by that particular method. Although some of the pre-installed scripts work, I get "This script will not work without tkinter Please install and try again" with FontSample, for example.
TagsNo tags attached.



2023-05-25 10:01

reporter (1,982 bytes)   
#!/usr/bin/env python
# File: - Extracts the text from a document, saving to a text file
# also lists image files with pathnames
# 2006.03.04 Gregory Pittman
# 2008.02.28 Petr Vanek - fileDialog replaces valueDialog
# 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.

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:  # in case of syntax error, rather use : "except Exception as e :"
        print e

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


2023-05-28 23:41

administrator   ~0050193

Last edited: 2023-05-28 23:42

The version of the script you have downlaoded is an old script for an unmaintained version of Scribus. This scripts requires Python 2, Scribus now uses Python 3. You have another version of the script updated for 1.5.x in the "Version of script as of 1.5.x series" section of same page.

As following line mentions it, you may have to change the script depending on 1.5.x version and Python version you are using:
except Exception, e: # in case of syntax error, rather use : "except Exception as e :"

Afaik, Scribus 1.5.8 now also uses Python 3 on Mac OS. So you have to change this line to:
except Exception as e :

Issue History

Date Modified Username Field Change
2023-05-25 10:01 DavidMiller New Issue
2023-05-25 10:01 DavidMiller File Added:
2023-05-28 23:24 jghali Project Contributor Builds => Scribus
2023-05-28 23:25 jghali Priority high => none
2023-05-28 23:25 jghali Category General => -
2023-05-28 23:25 jghali Category - => Scripter
2023-05-28 23:41 jghali Note Added: 0050193
2023-05-28 23:42 jghali Note Edited: 0050193
2023-05-28 23:43 jghali Assigned To => jghali
2023-05-28 23:43 jghali Status new => resolved
2023-05-28 23:43 jghali Resolution open => no change required
2023-05-28 23:43 jghali Status resolved => closed