def main(argv):
    """A simple scripts to set baseline grid and matching guides."""

    CurrentUnit = scribus.getUnit() 
    
    scribus.setUnit(0) 
    H_Guides = [] 
    
    GuideHeight = float(scribus.valueDialog('Set BaseLine Grid & Guides', 'Enter value for Grid and Guide Height (pt).', '14.40') )
    GuideOffset = float(scribus.valueDialog('Set Grid & Guide Offsets', 'Enter value for Grid and Guide Offset (pt).', '0.0') )
    
    PageWidth, PageHeight = scribus.getPageSize() 
    
    NumLoops = math.floor(1 + (PageHeight - GuideOffset) / GuideHeight)
    
    for i in range(int(NumLoops)):
    	if i > 0:
    		H_Guides.append(GuideOffset + i * GuideHeight)
    
    scribus.setBaseLine(GuideHeight, GuideOffset)
    scribus.setHGuides(scribus.getHGuides() + H_Guides)
    
    scribus.setUnit(CurrentUnit)
    
    scribus.messageBox('Script', '<h3>Script by ugajin</h3><p>Thanks a bunch for using setBaselineGuides and Scribus!</p><p>[email protected]</p>', scribus.ICON_INFORMATION, scribus.BUTTON_OK, scribus.BUTTON_CANCEL)
def main(argv):
    """A simple scripts to set baseline grid and matching guides."""

    CurrentUnit = scribus.getUnit()

    scribus.setUnit(0)
    H_Guides = []

    GuideHeight = float(
        scribus.valueDialog('Set BaseLine Grid & Guides',
                            'Enter value for Grid and Guide Height (pt).',
                            '14.40'))
    GuideOffset = float(
        scribus.valueDialog('Set Grid & Guide Offsets',
                            'Enter value for Grid and Guide Offset (pt).',
                            '0.0'))

    PageWidth, PageHeight = scribus.getPageSize()

    NumLoops = math.floor(1 + (PageHeight - GuideOffset) / GuideHeight)

    for i in range(int(NumLoops)):
        if i > 0:
            H_Guides.append(GuideOffset + i * GuideHeight)

    scribus.setBaseLine(GuideHeight, GuideOffset)
    scribus.setHGuides(scribus.getHGuides() + H_Guides)

    scribus.setUnit(CurrentUnit)

    scribus.messageBox(
        'Script',
        '<h3>Script by ugajin</h3><p>Thanks a bunch for using setBaselineGuides and Scribus!</p><p>[email protected]</p>',
        scribus.ICON_INFORMATION, scribus.BUTTON_OK, scribus.BUTTON_CANCEL)
Пример #3
0
def drawPlaceholders():
    page = scribus.getPageSize()
    margin = scribus.getPageMargins()

    # add the page margins
    rectangle = scribus.createRect(margin[1], margin[0],
                                   (page[0] - margin[1] - margin[2]),
                                   (page[1] - margin[0] - margin[3]))
    scribus.setFillColor('none', rectangle)
    scribus.setLineColor('Blue', rectangle)
    scribus.setLineWidth(0.4, rectangle)

    # add horizontal and vertical guides
    for item in scribus.getHGuides():
        line = scribus.createLine(0, item, page[0], item)
        scribus.setLineColor('Black', line)
        scribus.setLineWidth(0.6, line)
        scribus.setLineStyle(scribus.LINE_DASHDOT, line)

    for item in scribus.getVGuides():
        line = scribus.createLine(item, 0, item, page[0])
        scribus.setLineColor('Black', line)
        scribus.setLineWidth(0.6, line)
        scribus.setLineStyle(scribus.LINE_DASHDOT, line)

    # add a "crossed frame" for missing images
    for item in scribus.getAllObjects():
        if scribus.getObjectType(item) == 'ImageFrame':
            image = scribus.getImageFile(item)
            if image == '':
                pos = scribus.getPosition(item)
                size = scribus.getSize(item)
                rectangle = scribus.createRect(pos[0], pos[1], size[0],
                                               size[1])
                scribus.setFillColor('none', rectangle)
                scribus.setLineColor('Black', rectangle)
                scribus.setLineWidth(0.4, rectangle)
                line = scribus.createLine(pos[0], pos[1], pos[0] + size[0],
                                          pos[1] + size[1])
                scribus.setLineColor('Black', line)
                scribus.setLineWidth(0.4, line)
                line = scribus.createLine(pos[0], pos[1] + size[1],
                                          pos[0] + size[0], pos[1])
                scribus.setLineColor('Black', line)
                scribus.setLineWidth(0.4, line)
def drawPlaceholders():
    page = scribus.getPageSize()
    margin = scribus.getPageMargins()

    # add the page margins
    rectangle = scribus.createRect(margin[1], margin[0], (page[0] - margin[1] - margin[2]), (page[1] - margin[0] - margin[3]))
    scribus.setFillColor('none', rectangle)
    scribus.setLineColor('Blue', rectangle)
    scribus.setLineWidth(0.4, rectangle)

    # add horizontal and vertical guides
    for item in scribus.getHGuides():
        line = scribus.createLine(0, item , page[0], item)
        scribus.setLineColor('Black', line)
        scribus.setLineWidth(0.6, line)
        scribus.setLineStyle(scribus.LINE_DASHDOT, line)

    for item in scribus.getVGuides():
        line = scribus.createLine(item, 0 , item, page[0])
        scribus.setLineColor('Black', line)
        scribus.setLineWidth(0.6, line)
        scribus.setLineStyle(scribus.LINE_DASHDOT, line)

    # add a "crossed frame" for missing images
    for item in scribus.getAllObjects():
        if scribus.getObjectType(item) == 'ImageFrame':
            image = scribus.getImageFile(item)
            if image == '':
                pos = scribus.getPosition(item)
                size = scribus.getSize(item)
                rectangle = scribus.createRect(pos[0], pos[1], size[0], size[1])
                scribus.setFillColor('none', rectangle)
                scribus.setLineColor('Black', rectangle)
                scribus.setLineWidth(0.4, rectangle)
                line = scribus.createLine(pos[0], pos[1] , pos[0] + size[0], pos[1] + size[1])
                scribus.setLineColor('Black', line)
                scribus.setLineWidth(0.4, line)
                line = scribus.createLine(pos[0], pos[1] + size[1], pos[0] + size[0], pos[1])
                scribus.setLineColor('Black', line)
                scribus.setLineWidth(0.4, line)
    scribus.setActiveLayer('guides')
else:
    scribus.createLayer('guides')


# add the baseline grid (when it's not too close to a guide)
baseline_start = 0 # in mm
baseline = 14.4 # in pt

multiplicator = 10000
baseline = int(baseline * 0.352777 * multiplicator) # 14.4 pt in mm
#baseline = int(baseline * 0.351459 * multiplicator) # 14.4 pt in mm

if baseline > 0 :
  guide_i = 0
  guide_list = scribus.getHGuides()
  guide_list.append(page[1])
  guide = guide_list[guide_i]
  guide_n = len(guide_list)
  if not 'Gray' in scribus.getColorNames() :
      scribus.defineColor('Gray', 10, 10, 10, 10)
  for item in range(baseline + baseline_start*multiplicator, int(page[1] * multiplicator + baseline_start*multiplicator), baseline) :
    # print item/multiplicator
    while guide_i < guide_n - 1 and item/multiplicator > guide + 0.15 :
        guide_i = guide_i + 1
        guide = guide_list[guide_i]
    if item/multiplicator < guide - 0.15 :
        line = scribus.createLine(0, item/multiplicator , page[0], item/multiplicator)
        scribus.setLineColor('Gray', line)
        scribus.setLineWidth(0.6, line)
        # scribus.setLineStyle(scribus.LINE_DASHDOT, line)
Пример #6
0
def main(argv):
    unit = scribus.getUnit()
    units = ['pts', 'mm', 'inches', 'picas', 'cm', 'ciceros']
    unitlabel = units[unit]

    # get page size
    xysize = scribus.getPageSize()

    # ask for layout style
    layout_style = scribus.valueDialog("Guides Layout", layout_text, "1")
    if layout_style == "":
        sys.exit()

# 0 = erase all guides
    if layout_style == "0":
        #guides
        scribus.setVGuides([])
        scribus.setHGuides([])
        sys.exit()

# 1 = guides around page
    if layout_style == "1":
        # set guides distance
        pageguides_str = scribus.valueDialog(
            "Create Guides around Page",
            "Set distance to page borders (" + unitlabel +
            ") :\n\n- positive (e.g. 3) for page margin\n\n- negative (e.g. -3) for page bleed\n",
            "3")
        if pageguides_str != "":
            pageguides = float(pageguides_str)
        else:
            sys.exit()

        #set guides
        scribus.setVGuides(scribus.getVGuides() +
                           [pageguides, xysize[0] - pageguides])
        scribus.setHGuides(scribus.getHGuides() +
                           [pageguides, xysize[1] - pageguides])

# 2 = guides around selected object
    if layout_style == "2":
        # set guides distance
        objectguides_str = scribus.valueDialog(
            "Create Guides around selected Objects",
            "Set distance to object borders (" + unitlabel +
            ") :\n\n- 0 for around the object borders\n\n- positive (e.g. 3) towards inside the object\n\n- negative (e.g. -3) towards outside the object\n",
            "0")
        if objectguides_str != "":
            objectguides = float(objectguides_str)
        else:
            sys.exit()

        if scribus.selectionCount() == 0:
            scribus.messageBox("Error",
                               "Select an object first !",
                               icon=scribus.ICON_WARNING)
            sys.exit()

        #get selected object
        selection_name = scribus.getSelectedObject(0)
        objectpos = scribus.getPosition(selection_name)
        objectsize = scribus.getSize(selection_name)

        #set guides
        scribus.setVGuides(scribus.getVGuides() + [
            objectpos[0] + objectguides, objectpos[0] + objectsize[0] -
            objectguides
        ])
        scribus.setHGuides(scribus.getHGuides() + [
            objectpos[1] + objectguides, objectpos[1] + objectsize[1] -
            objectguides
        ])
def main(argv):
    unit = scribus.getUnit()
    units = ['pts','mm','inches','picas','cm','ciceros']
    unitlabel = units[unit]
    
# get page size
    pagesize = scribus.getPageSize()

    
# ask for layout style
    layout_style = scribus.valueDialog("Select Mirror", layout_text, "v")
    if layout_style == "":
        sys.exit()

        

# v = vertical mirror
    if layout_style == "v":            
        # warn and exit if no selection
        if scribus.selectionCount() == 0:
            scribus.messageBox("Error", "Select an object first!", icon=scribus.ICON_WARNING)
            sys.exit()
        
        #create mirror guides
        scribus.setVGuides(scribus.getHGuides() + [pagesize[0]/2])
        
        #get selected object
        selection_name = scribus.getSelectedObject(0)
        objectpos = scribus.getPosition(selection_name)
        objectsize = scribus.getSize(selection_name)
        
        #duplicate object
        scribus.duplicateObject(selection_name)
        
        #move object
        newobjectpos = (pagesize[0] - (objectpos[0] + objectsize[0]) , objectpos[1])
        scribus.moveObjectAbs(newobjectpos[0], objectpos[1], selection_name)
        
        #flip object
        scribus.flipObject(1,0,selection_name)

        

# h = horizontal mirror
    if layout_style == "h":            
        # warn and exit if no selection
        if scribus.selectionCount() == 0:
            scribus.messageBox("Error", "Select an object first!", icon=scribus.ICON_WARNING)
            sys.exit()
        
        #create mirror guides
        scribus.setHGuides(scribus.getHGuides() + [pagesize[1]/2])
        
        #get selected object
        selection_name = scribus.getSelectedObject(0)
        objectpos = scribus.getPosition(selection_name)
        objectsize = scribus.getSize(selection_name)
        
        #duplicate object
        scribus.duplicateObject(selection_name)
        
        #move object
        newobjectpos = (objectpos[0] , pagesize[1] - (objectpos[1] + objectsize[1]))
        scribus.moveObjectAbs(objectpos[0], newobjectpos[1], selection_name)
        
        #flip object
        scribus.flipObject(0,1,selection_name)