from __future__ import division import scribus def unlink_pages(firstpage, frame_prefix): scribus.ProgressReset() scribus.ProgressTotal(scribus.PageCount()) scribus.MessagebarText("Unlinking frames...") scribus.SetRedraw(False) pagecount = scribus.PageCount() for pageno in xrange(pagecount, firstpage - 1 , -1): scribus.GotoPage(pageno) frame_name = "%s%08d" % (frame_prefix, pageno) # Create a frame that holds the start of the text in the frame # and the full length of the text in the frame before we copy it. # These frames will probably overlap the main one even though # they start in the margin, but I don't care. scribus.CreateText(0,0,400,100,"ERROR%s" % pageno) ##DEBUG## scribus.SetText("page %s, len %s, initial text:%s" % \ (pageno, scribus.GetTextLength(frame_name),\ scribus.GetText(frame_name)[:50]),\ "ERROR%s" % pageno) ##DEBUG## # Now actually copy, unlink, and restore the text. # Note that we can't discover how much text is visible # in the frame - GetText returns _all_ text including what's # awaiting spilling - so we have to pick an amount to copy # out of the frame. This is an awful hack anyway, # so let's go make it worse! 4000 seems sensible. frame_text = scribus.GetText(frame_name)[:4000] scribus.UnlinkTextFrames(frame_name) scribus.SetText(frame_text, frame_name) scribus.ProgressSet(pagecount - pageno + 1) if __name__ == '__main__': try: unlink_pages(1,"Odyssey_") finally: scribus.SetRedraw(True) scribus.MessagebarText("Ready") scribus.ProgressReset()