def drawHeaderFooter(pagetitle): """draw some info on the pages""" # get page size pageSize=scribus.getPageSize() pageWidth=pageSize[0] pageHeight=pageSize[1] #pageMargins pageMargins=scribus.getPageMargins() topMargin=pageMargins[0] leftMargin=pageMargins[1] rightMargin=pageMargins[2] bottomMargin=pageMargins[3] #create textbox and insert text for header textbox=scribus.createText(leftMargin, topMargin, pageWidth-leftMargin-rightMargin, HEADERSIZE) #set proper font size and alignment scribus.setFontSize(18, textbox) scribus.setTextAlignment(scribus.ALIGN_CENTERED, textbox) #load the string into the textbox headerstring=pagetitle scribus.insertText(headerstring, 0, textbox) scribus.setTextColor("Black", textbox) #create textbox and insert text for footer textbox=scribus.createText(leftMargin, pageHeight-bottomMargin-FOOTERSIZE, pageWidth-leftMargin-rightMargin, FOOTERSIZE) #set proper font size and alignment scribus.setFontSize(9, textbox) scribus.setTextAlignment(scribus.ALIGN_LEFT, textbox) #load the string into the textbox footerstring="Created using ColorChart.py V %s script for Scribus by Sebastian Stetter - http://www.sebastianstetter.de" % str(__version__) scribus.insertText(footerstring, 0, textbox) scribus.setTextColor("Black", textbox)
def resizeFrame (self, frame) : '''Resize a frame in place so that it fits the text inside it. Code for this was take from: http://wiki.scribus.net/canvas/Adjust_a_text_frame_to_fit_its_content''' # Now adjust the frame to fit the text # get some page and frame measure (x, ph) = scribus.getPageSize(); (x, x, x, pm) = scribus.getPageMargins(); # warning: gets the margins from document setup not for the current page (x, y) = scribus.getPosition(frame) bottom = (ph - pm) - y (w, h) = scribus.getSize(frame) # if the frame doesn't overflow, shorten it to make it overflow while (((scribus.textOverflows(frame) == 0) or (h > bottom)) and (h > 0)) : h -= 10 scribus.sizeObject(w, h, frame) # resize the frame in 10pt steps while ((scribus.textOverflows(frame) > 0) and (h < bottom)) : h += 10 scribus.sizeObject(w, h, frame) # undo the latest 10pt step and fine adjust in 1pt steps h -= 10 scribus.sizeObject(w, h, frame) while ((scribus.textOverflows(frame) > 0) and (h < bottom)) : h += 1 scribus.sizeObject(w, h, frame) # For vertical sizing operations return the frame height return int(scribus.getSize(frame)[1])
def resizeFrame(self, frame): '''Resize a frame in place so that it fits the text inside it. Code for this was take from: http://wiki.scribus.net/canvas/Adjust_a_text_frame_to_fit_its_content''' # Now adjust the frame to fit the text # get some page and frame measure (x, ph) = scribus.getPageSize() (x, x, x, pm) = scribus.getPageMargins() # warning: gets the margins from document setup not for the current page (x, y) = scribus.getPosition(frame) bottom = (ph - pm) - y (w, h) = scribus.getSize(frame) # if the frame doesn't overflow, shorten it to make it overflow while (((scribus.textOverflows(frame) == 0) or (h > bottom)) and (h > 0)): h -= 10 scribus.sizeObject(w, h, frame) # resize the frame in 10pt steps while ((scribus.textOverflows(frame) > 0) and (h < bottom)): h += 10 scribus.sizeObject(w, h, frame) # undo the latest 10pt step and fine adjust in 1pt steps h -= 10 scribus.sizeObject(w, h, frame) while ((scribus.textOverflows(frame) > 0) and (h < bottom)): h += 1 scribus.sizeObject(w, h, frame) # For vertical sizing operations return the frame height return int(scribus.getSize(frame)[1])
def copyPlayer(sourceName, destinationName): if scribus.objectExists(sourceName): doc = scribus.getDocName() unit = scribus.getUnit() (PageWidth, PageHeight) = scribus.getPageSize() (iT, iI, iO, iB) = scribus.getPageMargins() NewPagepoint = PageHeight - iT - iB player = scribus.selectObject(sourceName) #Duplicate the object... scribus.duplicateObject(sourceName) x = scribus.getSelectedObject() newObjectName = str(x) size = scribus.getSize(newObjectName) scribus.moveObject(0, size[1], newObjectName) (x, y) = scribus.getPosition(newObjectName) scribus.setRedraw(1) scribus.docChanged(1) if (y + size[1] > NewPagepoint): currentPage = scribus.currentPage() scribus.newPage(-1) newPage = currentPage + 1 scribus.copyObject(newObjectName) scribus.deleteObject(newObjectName) scribus.gotoPage(newPage) scribus.pasteObject(newObjectName) scribus.moveObjectAbs(iO, iT, newObjectName) scribus.setNewName(destinationName, sourceName) scribus.setNewName(sourceName, newObjectName)
def getCurrentPageMargins(): """This is a fix for the Scribus 'feature' with getPageMargins() Scribus seems to return document margins, not page margins for current page""" (top, left, right, bottom) = scribus.getPageMargins() if scribus.currentPage() % 2 == 1: # odd page return (top,left,right,bottom) else: return (top,right,left,bottom)
def getCurrentPageMargins(): """This is a fix for the Scribus 'feature' with getPageMargins() Scribus seems to return document margins, not page margins for current page""" (top, left, right, bottom) = scribus.getPageMargins() if scribus.currentPage() % 2 == 1: # odd page return (top, left, right, bottom) else: return (top, right, left, bottom)
def main(argv): rectColor = "Black" topMargin, leftMargin, rightMargin, bottomMargin = scribus.getPageMargins() pageWidth, pageHeight = scribus.getPageSize() printAreaWidth = pageWidth - leftMargin - rightMargin printAreaHeight = pageHeight - topMargin - bottomMargin vertRectW = random.randrange(2,4) vertRectH = random.randrange(48,50) horRectW = random.randrange(47,49) horRectH = random.randrange(2,5) startx = leftMargin endx = pageWidth - leftMargin - horRectW starty = topMargin endy = pageHeight - topMargin - vertRectH numberRectVert = random.randrange(400,600) numberRectHor = random.randrange(400,600) opacity = 0 scribus.progressTotal(numberRectVert+numberRectHor) scribus.setRedraw(False) for i in range(1, numberRectVert): opacity = opacity + 0.002 xpos = random.randrange(int(startx),int(endx)) ypos = random.randrange(int(starty),int(endy)) rect = scribus.createRect(xpos, ypos, vertRectW, vertRectH) scribus.setFillColor(rectColor, rect) scribus.setLineColor("None", rect) if opacity < 1: scribus.setFillTransparency(opacity, rect) scribus.progressSet(i*2) for i in range(1, numberRectVert): opacity = opacity + 0.002 xpos = random.randrange(int(startx),int(endx)) ypos = random.randrange(int(starty),int(endy)) recthor = scribus.createRect(xpos, ypos, horRectW, horRectH) scribus.setFillColor(rectColor, recthor) scribus.setLineColor("None", recthor) if opacity < 1: scribus.setFillTransparency(opacity, recthor) scribus.progressReset() scribus.docChanged(True) scribus.statusMessage("Done") scribus.setRedraw(True)
def get_settings_from_document(ignore_margins=True): scribus.setUnit(scribus.UNIT_MILLIMETERS) global page_size, page_margins_right, page_margins_left page_size = scribus.getPageSize() if ignore_margins: page_margins_right = (0, 0, 0, 0) else: page_margins_right = scribus.getPageMargins() page_margins_left = (page_margins_right[0], page_margins_right[2], page_margins_right[1], page_margins_right[3]) calc_max()
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 insert_text_frame(): page_size = scribus.getPageSize() page_margins_right = scribus.getPageMargins() page_margins_left = (page_margins_right[0], page_margins_right[2], page_margins_right[1], page_margins_right[3]) if (scribus.currentPage() % 2) == 1: page_margins = page_margins_right else: page_margins = page_margins_left name = 'test%d' % random.randint(100, 999) # x, y, width, height scribus.createText(page_margins[0], page_margins[1], page_size[0] - (page_margins[0] + page_margins[2]), page_size[1] - (page_margins[1] + page_margins[3]), name) scribus.setText("test", name)
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 createChart(): """actually handles the whole chart creation process""" prepareDocument() # get page size pageSize=scribus.getPageSize() pageWidth=pageSize[0] pageHeight=pageSize[1] #pageMargins pageMargins=scribus.getPageMargins() topMargin=pageMargins[0] leftMargin=pageMargins[1] rightMargin=pageMargins[2] bottomMargin=pageMargins[3] #color field dimensions colorFieldWidth= pageWidth - leftMargin - rightMargin - (TEXT_BOX_WIDTH+HSPACE) #50+5 is the with of the textbox plus the space between textbox and colorfield #how much space does one field use? vSpaceUsedByField = COLOR_FIELD_HEIGHT+VSPACE #how much space is available per row? vSpaceAvailable=pageHeight-topMargin-bottomMargin-HEADERSIZE-FOOTERSIZE #counts the colorFields created for a page. reset this variable after creation of new page colorFieldCounter=0 #get list of all colors in document colorList = scribus.getColorNames() #prepare the progressbar colorNumber=len(colorList) scribus.progressTotal(colorNumber) #@TODO: implement possibility to abort script (button2=scribus.BUTTON_CANCEL) buttons should return int 1 or 2 #scribus.messageBox("ColorChart Script by Sebastian Stetter", "...going to create a chart of "+str(colorNumber)+" colors.\n This may take a while.", button1 = scribus.BUTTON_OK) scribus.statusMessage("Drawing color fields...") stepCompleted=0 #disable redrawing for better performance scribus.setRedraw(False) for color in colorList: if (vSpaceUsedByField * (colorFieldCounter+1)) <= vSpaceAvailable: # when there is enought space left draw a color field... #calculate Position for new colorField h=leftMargin v=topMargin + (vSpaceUsedByField * colorFieldCounter)+HEADERSIZE #draw the colorField drawColor(color, h, v, colorFieldWidth, COLOR_FIELD_HEIGHT) colorFieldCounter = colorFieldCounter+1 #update progressbar stepCompleted = stepCompleted+1 scribus.progressSet(stepCompleted) else: #not enough space? create a new page! createPage() #reset the colorFieldCounter to '0' since we created a new page colorFieldCounter = 0 h=leftMargin v=topMargin + (vSpaceUsedByField * colorFieldCounter)+HEADERSIZE drawColor(color, h, v, colorFieldWidth, COLOR_FIELD_HEIGHT) colorFieldCounter = colorFieldCounter+1 #update progressbar stepCompleted = stepCompleted+1 scribus.progressSet(stepCompleted) #make shure pages are redrawn scribus.setRedraw(True)
def make_textframe (self): margins = scribus.getPageMargins() size = scribus.getPageSize() w = size[0] - margins[1] - margins[3] h = size[1] - margins[0] - margins[2] return scribus.createText (margins[1], margins[0], w, h)
#!/usr/bin/env python ''' Create image like Mondrian drawings ''' import scribus import random rectColor = "Black" topMargin, leftMargin, rightMargin, bottomMargin = scribus.getPageMargins() pageWidth, pageHeight = scribus.getPageSize() printAreaWidth = pageWidth - leftMargin - rightMargin printAreaHeight = pageHeight - topMargin - bottomMargin vertRectW = random.randrange(2,4) vertRectH = random.randrange(48,50) horRectW = random.randrange(47,49) horRectH = random.randrange(2,5) startx = leftMargin endx = pageWidth - leftMargin - horRectW starty = topMargin endy = pageHeight - topMargin - vertRectH numberRectVert = random.randrange(400,600) numberRectHor = random.randrange(400,600) opacity = 0 for i in range(1, numberRectVert): opacity = opacity + 0.002 xpos = random.randrange(int(startx),int(endx))
def main(argv): ########################################### info_text = ''' Welcome to Auto-Photobook! 1. Select the process mode: 9f = creates a 9x9 layout on each page and fill them with images. 4f = creates a 4x4 layout on each page and fill them with images. 9e = creates an empty 9x9 layout on each page. 4e = creates an empty 4x4 layout on each page. 9f+4f = creates a filled 9x9 layout on odd pages and a filled 4x4 layout on even pages. 9e+4e = creates an empty 9x9 layout on odd pages and an empty 4x4 layout on even pages. 9f+4e = creates a filled 9x9 layout on odd pages and an empty 4x4 layout on even pages (default). 9e+4f = creates an empty 9x9 layout on odd pages and a filled 4x4 layout on even pages. 2. Select a document layout, the margins (they need to be equal) and the bleed (if needed). Ignore the number of pages. 3. Define the space between the images (default: 6mm). 4a. If "9f" or "4f" is in your mode, you can choose an image folder and an image filter will be prompted. 4b. Otherwise, set the amount of pages you want to create (default: 10 pages). 5. Wait until it is done... 6. Adjust you layouts and move your images as you need. Process mode:''' # start dialog, choose mode #scribus.messageBox("Auto-Photobook", info_text) todo = scribus.valueDialog("Auto-Photobook", info_text, "9f+4e") todo = list(todo.split("+")) # wrong process mode if "9f" not in todo and "9e" not in todo and "4f" not in todo and "9e" not in todo: scribus.messageBox( "Error", "Wrong process mode. Auto-Photobook was cancelled.") sys.exit() # show new document dialog newdoc = scribus.newDocDialog() # exit if cancelled if newdoc == False: scribus.messageBox("Exit", "Auto-Photobook was cancelled.") sys.exit() if scribus.haveDoc: scribus.setUnit(scribus.UNIT_MILLIMETERS) (w, h) = scribus.getPageSize() ################### # delete all pages except the first: pageamount = scribus.pageCount() while pageamount > 1: scribus.deletePage(pageamount) pageamount = scribus.pageCount() # set image border and bleed border = int( scribus.valueDialog("Space between images", "Define the space between the images (mm).", "6")) #border = 6 # reset image border for easier calculations border = border * 0.75 if "9f" in todo or "4f" in todo: # ask for workdir workdir = scribus.fileDialog("Open directory with images", "", haspreview=False, issave=False, isdir=True) #workdir = "/media/sda7/Programming/Python/scribus_auto_photobook/pics" # file filter filefilter = scribus.valueDialog( "File filter", "File filter examples: \n\n* or *.* = add all files\n*.jpg = add .jpg files only\nIMG_*.* = add all files starting with IMG_\n\nThis filter is case sensitive!", "*.*") # get image paths filelist = sorted(glob.glob(os.path.join(workdir, filefilter))) #filelist = sorted(glob.glob(os.path.join(workdir, "*"))) # count files filesinworkdir = len(filelist) scribus.messageBox( "Files in directory", "Images matched in folder: " + str(filesinworkdir)) #error if filesinworkdir == 0: scribus.messageBox("Error", "This directory is empty.") sys.exit() #messagebar text scribus.messagebarText("Importing images...") #progressbar max scribus.progressTotal(filesinworkdir) # set maxpages (not needed here but needs to be assigned) maxpages = len(filelist) else: # ask for page amount maxpages = int( scribus.valueDialog("Set page amount", "How many pages you want to create?", "10")) #progressbar max scribus.progressTotal(maxpages) # get page size (without bleed) size = scribus.getPageSize() # get margins margins = scribus.getPageMargins()[0] # set page final size final_size = (size[0] - margins, size[1] - margins) # simplify calc for 9x9 layout guide_layout_x = final_size[0] / 3 - margins / 3 guide_layout_y = final_size[1] / 3 - margins / 3 # set indexes page = 1 pic = 0 #create pages, add and load images x = True while x == True: scribus.progressSet(page) scribus.gotoPage(page) # create 9x9 layout if "9f" in todo or "9e" in todo: #guides scribus.setVGuides([ margins + guide_layout_x - border, margins + guide_layout_x + border / 2, margins + guide_layout_x * 2 - border / 2, margins + guide_layout_x * 2 + border ]) scribus.setHGuides([ margins + guide_layout_y - border, margins + guide_layout_y + border / 2, margins + guide_layout_y * 2 - border / 2, margins + guide_layout_y * 2 + border ]) # create images scribus.createImage(margins, margins, guide_layout_x + border - border * 2, guide_layout_y - border, "page" + str(page) + "image1") scribus.createImage(margins + guide_layout_x + border / 2, margins, guide_layout_x + border - border * 2, guide_layout_y - border, "page" + str(page) + "image2") scribus.createImage(margins + guide_layout_x * 2 + border, margins, guide_layout_x + border - border * 2, guide_layout_y - border, "page" + str(page) + "image3") scribus.createImage(margins, margins + guide_layout_y + border / 2, guide_layout_x + border - border * 2, guide_layout_y - border, "page" + str(page) + "image4") scribus.createImage(margins + guide_layout_x + border / 2, margins + guide_layout_y + border / 2, guide_layout_x + border - border * 2, guide_layout_y - border, "page" + str(page) + "image5") scribus.createImage(margins + guide_layout_x * 2 + border, margins + guide_layout_y + border / 2, guide_layout_x + border - border * 2, guide_layout_y - border, "page" + str(page) + "image6") scribus.createImage(margins, margins + guide_layout_y * 2 + border, guide_layout_x + border - border * 2, guide_layout_y - border, "page" + str(page) + "image7") scribus.createImage(margins + guide_layout_x + border / 2, margins + guide_layout_y * 2 + border, guide_layout_x + border - border * 2, guide_layout_y - border, "page" + str(page) + "image8") scribus.createImage(margins + guide_layout_x * 2 + border, margins + guide_layout_y * 2 + border, guide_layout_x + border - border * 2, guide_layout_y - border, "page" + str(page) + "image9") #load and scale images if "9f" in todo: try: scribus.loadImage(filelist[pic], "page" + str(page) + "image1") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image1") scribus.loadImage(filelist[pic + 1], "page" + str(page) + "image2") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image2") scribus.loadImage(filelist[pic + 2], "page" + str(page) + "image3") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image3") scribus.loadImage(filelist[pic + 3], "page" + str(page) + "image4") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image4") scribus.loadImage(filelist[pic + 4], "page" + str(page) + "image5") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image5") scribus.loadImage(filelist[pic + 5], "page" + str(page) + "image6") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image6") scribus.loadImage(filelist[pic + 6], "page" + str(page) + "image7") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image7") scribus.loadImage(filelist[pic + 7], "page" + str(page) + "image8") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image8") scribus.loadImage(filelist[pic + 8], "page" + str(page) + "image9") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image9") except: x = False # increase picture index pic += 9 # add page scribus.newPage(-1) page += 1 # create 4x4 layout if "4f" in todo or "4e" in todo: #guides scribus.setVGuides( [size[0] / 2 - border * 0.75, size[0] / 2 + border * 0.75]) scribus.setHGuides( [size[1] / 2 - border * 0.75, size[1] / 2 + border * 0.75]) # create images scribus.createImage(margins, margins, size[0] / 2 - border * 0.75 - margins, size[1] / 2 - border * 0.75 - margins, "page" + str(page) + "image1") scribus.createImage(size[0] / 2 + border * 0.75, margins, size[0] / 2 - border * 0.75 - margins, size[1] / 2 - border * 0.75 - margins, "page" + str(page) + "image2") scribus.createImage(margins, size[1] / 2 + border * 0.75, size[0] / 2 - border * 0.75 - margins, size[1] / 2 - border * 0.75 - margins, "page" + str(page) + "image3") scribus.createImage(size[0] / 2 + border * 0.75, size[1] / 2 + border * 0.75, size[0] / 2 - border * 0.75 - margins, size[1] / 2 - border * 0.75 - margins, "page" + str(page) + "image4") #load and scale images if "4f" in todo: try: scribus.loadImage(filelist[pic], "page" + str(page) + "image1") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image1") scribus.loadImage(filelist[pic + 1], "page" + str(page) + "image2") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image2") scribus.loadImage(filelist[pic + 2], "page" + str(page) + "image3") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image3") scribus.loadImage(filelist[pic + 3], "page" + str(page) + "image4") scribus.setScaleImageToFrame(True, proportional=True, name="page" + str(page) + "image4") except: x = False # increase picture index pic += 4 # add page scribus.newPage(-1) page += 1 #scribus.setImageOffset(0, 0, "imagename"+str(page)) #scribus.setScaleFrameToImage(name="imagename"+str(page)) # stop if maxpages reached if page > maxpages: x = False #delete last blank page scribus.deletePage(page)
(margin_top, margin_left, margin_right, margin_bottom) = scribus.getPageNMargins(scribus.currentPage()) print "left " + str(margin_left) print "right " + str(margin_right) (width, height) = scribus.getPageNSize(scribus.currentPage()) print "width " + str(width) print "height " + str(height) cell_width = (width - (margin_left + margin_right) - (gap * (n - 1))) / n print cell_width guide = [] previous_guide = margin_left for i in range(0, n - 1): guide.append(previous_guide + cell_width) guide.append(previous_guide + cell_width + gap) previous_guide = previous_guide + cell_width + gap scribus.setHGuides(guide) unit_current=scribus.getUnit() #get unit and change it to mm scribus.setUnit(scribus.UNIT_MILLIMETERS) page = scribus.getPageSize() margin = scribus.getPageMargins() # scribus.setHGuides([10,20,30]) setGuidesColumn(6, 5) setGuidesRow(4, 5) scribus.setUnit(unit_current)
""" from __future__ import division from itertools import cycle import sys try: import scribus except ImportError: print "This script only works from within Scribus" sys.exit(1) unit_current=scribus.getUnit() #get unit and change it to mm scribus.setUnit(scribus.UNIT_MILLIMETERS) page = scribus.getPageSize() margin = scribus.getPageMargins() layer = scribus.getActiveLayer() if ('guides' in scribus.getLayers()) : 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