import scribus import re from pathlib import Path # If MAX_PAGES is not 0, the script terminates when reaching the number of pages MAX_PAGES = 0 # Constants missing in scribus.* MARGIN_TOP = 0 MARGIN_LEFT = 1 MARGIN_RIGHT = 2 MARGIN_BOTTOM = 3 PAGE_WIDTH = 0 PAGE_HEIGHT = 1 def pickFont(): """Try to pick a vaguely sensible font and return the font name""" fonts = scribus.getFontNames() preferences = ["Liberation Sans Regular", "Utopia Regular", "Luxi Serif Regular", "Nimbus Roman No9 L Regular", "Bitstream Vera Serif Regular", "Courier Regular" ] for pref in preferences: if pref in fonts: return pref raise Exception("Could not find any suitable font.") def main(): # Grab all our settings etc, retaining defaults. try: # We need to make sure we turn redrawing back on at the end scribus.messagebarText("Loading text...") with Path(__file__).with_name('odyssey.txt').open('r') as f: full_text = f.read() # replace single newlines by spaces full_text = re.sub(r'(? 0 and page_number == MAX_PAGES: break scribus.messagebarText("Done") except Exception as e: scribus.messageBox('hey', 'failed' + e) finally: # Turn redraw back on and do other # cleanups, even if something goes horribly wrong. scribus.setRedraw(True) scribus.progressReset() scribus.messagebarText("Ready") if __name__ == '__main__': main()