Making margins in Guttenberg way
(Redirected from Making margins in Gutemberg way)
Jump to navigation
Jump to search
This script makes proportional margins in Gutemberg way, based in left margin value. Scribus automaticaly mirror margin in facing page documents.
Made après Sitespiegel OpenOffice.org macro.
--Meira da Rocha 18:37, 10 Jun 2005 (UTC)
#!/usr/bin/env python2.3 # -*- coding: utf-8 -*- """Generate margins according Gutemberg way. """ import sys """Locale strings to be translated """ TITLE = "Generate margins" noDocMsg = "<h2>First, open a doc</h2>This script only work on opened document.\ <b>Open a document</b> before run this script." runningMsg = "Running script..." noScribusMsg = "This Python script is written for the Scribus scripting interface.\ \nIt can only be run from within Scribus." try: import scribus except ImportError,err: print noScribusMsg sys.exit(1) from scribus import UNIT_POINTS,BUTTON_OK,ICON_WARNING def main(argv): """Generate margins""" if scribus.haveDoc(): scribus.setRedraw(False) unit = scribus.getUnit() # save original unit scribus.setUnit(UNIT_POINTS) # working in points, due a bug in getPageMargins pageWidth, pageHeight = scribus.getPageSize() ratio = pageHeight / pageWidth topMargin, leftMargin, rightMargin, bottomMargin = scribus.getPageMargins() topMargin = leftMargin * ratio rightMargin = leftMargin * 2 bottomMargin = rightMargin * ratio scribus.setMargins(leftMargin, rightMargin, topMargin, bottomMargin) scribus.setUnit(unit) # restore original unit else: scribus.messageBox(TITLE, noDocMsg, ICON_WARNING, BUTTON_OK) def main_wrapper(argv): try: scribus.statusMessage(runningMsg) scribus.progressReset() main(argv) finally: if scribus.haveDoc(): scribus.setRedraw(True) scribus.statusMessage("") scribus.progressReset() if __name__ == '__main__': main_wrapper(sys.argv)