[scribus] An idea for a script (or more likely 2 scripts)

Gregory Pittman gpittman at iglou.com
Sun Dec 3 01:01:50 UTC 2017


Something that occurred to me, considering the fact that in the past at
least I have used Scribus for making labels, was that it is not
difficult to conceive of a script that would create guides on a page, to
serve in the way that a template might. You can easily download these
templates in Word or Openoffice.org formats, or even PDFs.

What I did then, was to create two scripts, one designed for US Letter
Shipping labels (Avery 5194), and the other for A4 shipping labels
(EU30007). I arrived at these values for the guides (in points) by
importing the PDF templates, centering them using Align and Distribute,
then placing guides manually to coincide with the borders of the labels.
Anyone can do this, but once you have a script, it works so fast that
for those using labels a lot this would be quite a time-saver.

The idea on a larger scale would be to expand each of these to include a
number of label types. In Python, all you need is a list to plug into
the setHGuides and setVGuides commands, so you would select your label
type and the values selected accordingly.

This isn't difficult Python scripting, though it would be
time-consuming, so I didn't want to proceed further without some
indication from the mail list that it seems to be worth doing.

Here is the US Letter script:

***
#!/usr/bin/env python
"""
Creates guides for Avery 5194 Shipping labels
US Letter Paper
"""
import scribus


if (scribus.haveDoc()):
    pageunits = scribus.getUnit()
    scribus.setUnit(scribus.UNIT_POINTS)
    scribus.setHGuides([37.75,277,517.75,757])
    scribus.setVGuides([11.75,298.25,313.25,600])
    scribus.setUnit(pageunits)

    scribus.setRedraw(1)
    scribus.redrawAll()

else:
    scribus.messageBox('OOPS!','You need to have a document
open',scribus.ICON_NONE,button1=scribus.BUTTON_OK)
    sys.exit(1)

And here is the A4 script:

***
#!/usr/bin/env python
"""
Creates guides for A4 labels
EU30007
"""
import scribus


if (scribus.haveDoc()):
    pageunits = scribus.getUnit()
    scribus.setUnit(scribus.UNIT_POINTS)
    scribus.setHGuides([25,289,553,817])
    scribus.setVGuides([13.25,294.5,301.25,582.5])
    scribus.setUnit(pageunits)

    scribus.setRedraw(1)
    scribus.redrawAll()

else:
    scribus.messageBox('OOPS!','You need to have a document
open',scribus.ICON_NONE,button1=scribus.BUTTON_OK)
    sys.exit(1)

Pretty simple logic, just needing more data and the decision structure
for choosing a particular template.

Greg



More information about the scribus mailing list