Scribus Forums

Scribus => Scripts and Plugins => Topic started by: Astroman Pete on June 18, 2012, 08:35:14 PM

Title: Master page not updating in normal view after being edited by Scripter
Post by: Astroman Pete on June 18, 2012, 08:35:14 PM
I'm working on a set of scripts to layout construction drawings for architecture & engineering in Scribus. Right now, I am working on title block functionality. Information is either set page-by-page, or applies to the whole set. Information that applies to the whole set is put on the Master page.

I've gotten everything to work, except text frames that I create on the Master don't show up until the document is closed and reopened, or the Master page is edited. Is there a way to tell Scribus to refresh the master page layers when in normal view? The normal redraw toggling seems to not help.

I've prepared a small script that demonstrates this behavior. Open a blank document and run the script, it will look as if the document is unchanged. If you edit the master page, you will see the "Hello from the Master Page!" text in the upper-left corner. If you then go back to the normal page, you will see the text.

Scribus crashes, sometimes, when leaving the master page editing session.

At work, I'm using Windows 7 and Scribus 1.4.1
At home, I'm using Kubuntu 12.04 and Scribus 1.4.0 and the development PPA.

Let me know if additional information will help, or if I should file this as a bug.

Here's the test code:

import sys

try:
    import scribus
except ImportError,err:
    print "This script must be run within Scribus."
    sys.exit(1)


def main(argv):
    """
    Test function: Master pages not redrawn after the following changes.
    """
    try:
        scribus.editMasterPage(scribus.masterPageNames()[0])
        w, h = scribus.getPageSize()
        scribus.createText(0.0,0.0,w,h,'test_frame')
        scribus.setText('Hello from the Master Page!','test_frame')
    finally:
        scribus.closeMasterPage()


def main_wrapper(argv):
    """ Boiler plate from /share/samples/boilerplate.py """
    try:
        scribus.statusMessage("Running script...")
        scribus.progressReset()
        main(argv)
    finally:
        if scribus.haveDoc():
            scribus.setRedraw(True)
        scribus.statusMessage("")
        scribus.progressReset()

if __name__ == '__main__':
    main_wrapper(sys.argv)

Title: Re: Master page not updating in normal view after being edited by Scripter
Post by: jlpoole on June 20, 2012, 06:04:15 AM
I tried your script using Scribus 1.5 SVN (v. 17561 6/13/2012 -- slightly customized for Scripter) and it duly terminated Scribus.  I pasted your code in the the Script Editor "Python" and Ctrl+R to run it.

I rem'd  the "sys.exit(1)" and received your programmed error message: "This script must be run..." without Scribus terminating.  So what may appear to be a crash, may be, in fact the termination by your call to sys.exit. 

Note:  I've found if I exit Scribus by clicking File-Quit I get an error message:
Scribus Crash
-------------
Scribus crashes due to Signal #11

This may be due to the customization I made on the build, or it may be a misleading message.
Title: Re: Master page not updating in normal view after being edited by Scripter
Post by: a.l.e on June 20, 2012, 11:18:43 AM
yep, the master page information is not updated when leaving the master page mode in the scripter.

can you please post a bug report?

http://bugs.scribus.net

ciao
a.l.e
Title: Re: Master page not updating in normal view after being edited by Scripter
Post by: Astroman Pete on June 20, 2012, 03:08:57 PM
Yeah. I found that my Scribus console got confused with the indentation when I pasted that code snippet into the console, it had to be run from a separate "PY" file. Also, I was remiss in not mentioning that this applies to the old Scripter interface, not the new one, perhaps that's why you're not able to import the scribus module.

I haven't used the new Scripter interface, yet. I look forward to using it. I'm going to be careful to encapsulate all of the Scribus functionality in my application so that I can gracefully transition to the new interface. Things are in flux, and I'm totally cool with that.

I will certainly file a bug, in the meantime, I can simply create text boxes on all the pages for "global" fields. It's a little painful to violate D.R.Y. in that way, but it's only temporary.