Scribus Forums

Scribus => Scripts and Plugins => Topic started by: Rob Dixon on May 09, 2016, 03:04:18 PM

Title: Importing XML into Scribus
Post by: Rob Dixon on May 09, 2016, 03:04:18 PM
Whilst I have plenty of computing experience, I am a total novice when it comes to Scribus, publishing packages in general, Python, Python scripts, etc so would appreciate some help. I wish to import XML into Scribus.

I have tried to create a Python script "FormatXML", taken from the page
https://wiki.scribus.net/canvas/Formatxml

I copied the complete code in the box headed Source, without any change, into a .txt file using notepad and changed the extension to py. I then tried to execute the script in Scribus but got the following error.

Traceback (most recent call last):
  File "<string>", line 8, in <module>
  File "C:\XML script\FormatXML.py", line 179, in <module>
    main_wrapper()
  File "C:\XML script\FormatXML.py", line 165, in main_wrapper
    main()
  File "C:\XML script\FormatXML.py", line 148, in main
    xml_file = getFile("XML File", 'XML (*.xml)')
TypeError: getFile() takes exactly 4 arguments (2 given)

Unfortunately, this means nothing to me. I can only find two references to FormatXML, without the extension .py and cannot find any reference to py

I hope that someone is kind enough to put me out of my misery!

Many thanks

Rob Dixon

Title: Re: Importing XML into Scribus
Post by: Nermander on May 10, 2016, 07:55:45 AM
Quote from: Rob Dixon on May 09, 2016, 03:04:18 PM
  File "C:\XML script\FormatXML.py", line 148, in main
    xml_file = getFile("XML File", 'XML (*.xml)')
TypeError: getFile() takes exactly 4 arguments (2 given)

The above quoted part is the error message. In line 148 in your file there is a call to the getFile() function with to few arguments.

To me it looks as a bug in the code.

The call is
       xml_file = getFile("XML File", 'XML (*.xml)')

but the function is defined as
def getFile(caption, filter, defaultname, issave):

But I don't know enough Python to know if there is some settings telling that some arguments are optional.
Title: Re: Importing XML into Scribus
Post by: Rob Dixon on May 10, 2016, 10:16:14 AM
Many thanks, Nermander. You may well be right that there are too few arguments, but it is way outside my comfort zone! Have you any idea how I might be able to find an answer?
Title: Re: Importing XML into Scribus
Post by: Rob Dixon on May 10, 2016, 07:41:08 PM
Scribus has sent me the code for a new script and this now works. I have actually imported some XML into Scribus. Now I have to learn about Scribus.