Enlarge2Page

From Scribus Wiki
Revision as of 16:50, 26 March 2011 by Gpittman (talk | contribs) (Created page with "{{Scripting_Index}} <pre> #!/usr/bin/env python # -*- coding: utf-8 -*- # Enlarge2Page.py # this version 2011.03.26 # enlarges a selected object to the # size of the page """...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This article is part of the Scripts series.
#!/usr/bin/env python
# -*- coding: utf-8  -*-

# Enlarge2Page.py
# this version 2011.03.26
# enlarges a selected object to the 
# size of the page
"""
Enlarge2Page.py

(c) 2011 Gregory Pittman 

A devilishly simple script (there are more lines for
detecting errors than for actually manipulating the
object) which enlarges a single selected object to 
size of the page and positions it at 0,0.

Assumes a basepoint in the upper left corner. Error detection
for no selected frame or more than one. Page units do not matter.

"""

import scribus

if scribus.haveDoc():
    if scribus.selectionCount() == 0:
        scribus.messageBox('Scribus - Script Error',
            "There is no object selected.\nPlease select one and try again.",
            scribus.ICON_WARNING, scribus.BUTTON_OK)
        sys.exit(2)
    if scribus.selectionCount() > 1:
        scribus.messageBox('Scribus - Script Error',
            "You have more than one object selected.\nPlease select only one and try again.",
            scribus.ICON_WARNING, scribus.BUTTON_OK)
        sys.exit(2)

    xdimension, ydimension = scribus.getPageSize()
    selectedframe = scribus.getSelectedObject()
    scribus.sizeObject(xdimension, ydimension, selectedframe)
    scribus.moveObjectAbs(0, 0, selectedframe)
    scribus.redrawAll()