def setGuidesColumn(n, gap): print "setGuidesColumn should be a scribus API function" (margin_top, margin_left, margin_right, margin_bottom) = scribus.getPageNMargins(scribus.currentPage()) (width, height) = scribus.getPageNSize(scribus.currentPage()) cell_width = (width - (margin_left + margin_right) - (gap * (n - 1))) / n 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.setVGuides(guide)
def masterPage(): #create day lines scribus.createMasterPage('planner') scribus.editMasterPage('planner') for xend, y in iterDayLines(): line = scribus.createLine(xstart, y, xend, y) scribus.setLineWidth(2, line) for j in range(nSmallLines): smallWidth = (width) / 2 - MARGIN smally = y + (j * smallLineHeight) + smallLineHeight smallLineL = scribus.createLine(xstart, smally, xstart + smallWidth, smally) smallLineR = scribus.createLine(xend - smallWidth, smally, xend, smally) #bonuses scribus.setVGuides([PAPER[1] / 2]) #txt = scribus.createText(300, 300, 100, 100) #scribus.setText('\x1e', txt) #scribus.messageBox('', str(scribus.getAllStyles())) scribus.closeMasterPage()
from __future__ import print_function, division import scribus page_width = scribus.valueDialog('Cover Assistant', 'Page width (mm)', '148') page_height = scribus.valueDialog('Cover Assistant', 'Page height (mm)', '210') spine_width = scribus.valueDialog('Cover Assistant', 'Spine width (mm)', '8') page_width = float(page_width) page_height = float(page_height) spine_width = float(spine_width) cover_width = 2 * page_width + spine_width cover_height = page_height print('Spine width: {} mm'.format(spine_width)) print('Cover width: {} mm'.format(cover_width)) print('Cover height: {} mm'.format(cover_height)) scribus.newDocument((cover_width, cover_height), (0, 0, 0, 0), scribus.PORTRAIT, 1, scribus.UNIT_MILLIMETERS, scribus.PAGE_1, 0, 1) vguides = [page_width, page_width + spine_width] scribus.setVGuides(vguides)
G = float(G) W = scribus.valueDialog('Book Cover Calculator', 'Enter Page Width') W = float(W) H = scribus.valueDialog('Book Cover Calculator', 'Enter Page Height') H = float(H) R = scribus.valueDialog('Book Cover Calculator', 'Enter Cover Paper thickness') R = float(R) W1 = W WW = W + 0.125 S = P / G + (R * 2) S = float(S) W = W + S + W + 0.25 H = H + 0.25 scribus.newDocument((W, H), (0.375, 0.375, 0.375, 0.375), scribus.PORTRAIT, 1, scribus.UNIT_INCHES, scribus.PAGE_1, 0, 1) scribus.setVGuides( [WW, (W1 / 2 + 0.125), (WW + S / 2), (WW + S), (WW + S + W1 / 2)])
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)
def setbleeds(): scribus.setHGuides([document_margin,document_width-document_margin]) scribus.setVGuides([document_margin,document_height-document_margin])
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] #layout_style = "" #frame = 3 #border = 3 # layout style layout_style = scribus.valueDialog("Layout Style", layout_text, mylayout) if layout_style == "h": scribus.messageBox("Help", help_text) sys.exit() if layout_style == "v": createDefaultVal() sys.exit() if layout_style == "": sys.exit() # frame frame_str = scribus.valueDialog( "Set Page Frame", "Set page frame size (" + unitlabel + ") :\n(positive for page margin,\nnegative for page bleed)\n", myframe) if frame_str != "": frame = float(frame_str) else: sys.exit() # border if int(layout_style) > 1: border_str = scribus.valueDialog( "Add Image Border", "Add border around images (" + unitlabel + ") :\n", myborder) if border_str != "": border = float(border_str) else: sys.exit() else: border = 0 bleed = -frame # get page size xysize = scribus.getPageSize() size = (xysize[0] + 2 * bleed, xysize[1] + 2 * bleed) #scribus.createImage(0, 0, size[0]/2, size[1]/2) # layouts # one image on two pages (put it on the left page) if layout_style == "0": scribus.createImage(0 + border - bleed, 0 + border - bleed, (size[0] * 2) - border - bleed * 2, size[1] - border) # one image on one full page if layout_style == "1": scribus.createImage(0 + border - bleed, 0 + border - bleed, size[0] - border * 2, size[1] - border * 2) # two vertical images if layout_style == "2": scribus.createImage(0 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, size[1] - border * 2) scribus.createImage(size[0] / 2 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, size[1] - border * 2) #guides scribus.setVGuides( [size[0] / 2 - border - bleed, size[0] / 2 + border - bleed]) #scribus.setHGuides([size[1]/2-border-bleed, size[1]/2+border-bleed]) # two horizontal images if layout_style == "22": scribus.createImage(0 + border - bleed, 0 + border - bleed, size[0] - border * 2, size[1] / 2 - border * 2) scribus.createImage(0 + border - bleed, size[1] / 2 + border - bleed, size[0] - border * 2, size[1] / 2 - border * 2) #guides #scribus.setVGuides([size[0]/2-border-bleed, size[0]/2+border-bleed]) scribus.setHGuides( [size[1] / 2 - border - bleed, size[1] / 2 + border - bleed]) # one vertical image left, two horizontal images right if layout_style == "3": scribus.createImage(0 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, size[1] - border * 2) scribus.createImage(size[0] / 2 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) scribus.createImage(size[0] / 2 + border - bleed, size[1] / 2 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) #guides scribus.setVGuides( [size[0] / 2 - border - bleed, size[0] / 2 + border - bleed]) scribus.setHGuides( [size[1] / 2 - border - bleed, size[1] / 2 + border - bleed]) # one vertical image left, two horizontal images right if layout_style == "33": scribus.createImage(size[0] / 2 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, size[1] - border * 2) scribus.createImage(0 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) scribus.createImage(0 + border - bleed, size[1] / 2 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) #guides scribus.setVGuides( [size[0] / 2 - border - bleed, size[0] / 2 + border - bleed]) scribus.setHGuides( [size[1] / 2 - border - bleed, size[1] / 2 + border - bleed]) # one image on top, two images on bottom if layout_style == "333": scribus.createImage(0 + border - bleed, 0 + border - bleed, size[0] - border * 2, size[1] / 2 - border * 2) scribus.createImage(0 + border - bleed, size[1] / 2 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) scribus.createImage(size[0] / 2 + border - bleed, size[1] / 2 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) #guides scribus.setVGuides( [size[0] / 2 - border - bleed, size[0] / 2 + border - bleed]) scribus.setHGuides( [size[1] / 2 - border - bleed, size[1] / 2 + border - bleed]) # one image on top, two images on bottom if layout_style == "3333": scribus.createImage(0 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) scribus.createImage(size[0] / 2 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) scribus.createImage(0 + border - bleed, size[1] / 2 + border - bleed, size[0] - border * 2, size[1] / 2 - border * 2) #guides scribus.setVGuides( [size[0] / 2 - border - bleed, size[0] / 2 + border - bleed]) scribus.setHGuides( [size[1] / 2 - border - bleed, size[1] / 2 + border - bleed]) # four horizontal images if layout_style == "4": scribus.createImage(0 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) scribus.createImage(size[0] / 2 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) scribus.createImage(0 + border - bleed, size[1] / 2 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) scribus.createImage(size[0] / 2 + border - bleed, size[1] / 2 + border - bleed, size[0] / 2 - border * 2, size[1] / 2 - border * 2) #guides scribus.setVGuides( [size[0] / 2 - border - bleed, size[0] / 2 + border - bleed]) scribus.setHGuides( [size[1] / 2 - border - bleed, size[1] / 2 + border - bleed]) # six images 3 + 3 if layout_style == "6": scribus.createImage(0 + border - bleed, 0 + border - bleed, size[0] / 3 - border * 2, size[1] / 2 - border * 2) scribus.createImage(size[0] / 3 + border - bleed, 0 + border - bleed, size[0] / 3 - border * 2, size[1] / 2 - border * 2) scribus.createImage((size[0] / 3) * 2 + border - bleed, 0 + border - bleed, size[0] / 3 - border * 2, size[1] / 2 - border * 2) scribus.createImage(0 + border - bleed, size[1] / 2 + border - bleed, size[0] / 3 - border * 2, size[1] / 2 - border * 2) scribus.createImage(size[0] / 3 + border - bleed, size[1] / 2 + border - bleed, size[0] / 3 - border * 2, size[1] / 2 - border * 2) scribus.createImage((size[0] / 3) * 2 + border - bleed, size[1] / 2 + border - bleed, size[0] / 3 - border * 2, size[1] / 2 - border * 2) #guides scribus.setVGuides([ size[0] / 3 - border - bleed, size[0] / 3 - bleed + border, (size[0] / 3) * 2 - border - bleed, (size[0] / 3) * 2 + border - bleed ]) scribus.setHGuides( [size[1] / 2 - border - bleed, size[1] / 2 + border - bleed]) # six images 2 +2 + 2 if layout_style == "66": scribus.createImage(0 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, size[1] / 3 - border * 2) scribus.createImage(size[0] / 2 + border - bleed, 0 + border - bleed, size[0] / 2 - border * 2, (size[1] / 3) - border * 2) scribus.createImage(0 + border - bleed, size[1] / 3 + border - bleed, size[0] / 2 - border * 2, size[1] / 3 - border * 2) scribus.createImage(size[0] / 2 + border - bleed, size[1] / 3 + border - bleed, size[0] / 2 - border * 2, (size[1] / 3) - border * 2) scribus.createImage(0 + border - bleed, (size[1] / 3) * 2 + border - bleed, size[0] / 2 - border * 2, size[1] / 3 - border * 2) scribus.createImage(size[0] / 2 + border - bleed, (size[1] / 3) * 2 + border - bleed, size[0] / 2 - border * 2, (size[1] / 3) - border * 2) #guides scribus.setVGuides( [size[0] / 2 - border - bleed, size[0] / 2 + border - bleed]) scribus.setHGuides([ size[1] / 3 - border - bleed, size[1] / 3 + border - bleed, (size[1] / 3) * 2 - border - bleed, (size[1] / 3) * 2 + border - bleed ]) # nine images if layout_style == "9": scribus.createImage(0 + border - bleed, 0 + border - bleed, size[0] / 3 - border * 2, size[1] / 3 - border * 2) scribus.createImage(size[0] / 3 + border - bleed, 0 + border - bleed, size[0] / 3 - border * 2, size[1] / 3 - border * 2) scribus.createImage((size[0] / 3) * 2 + border - bleed, 0 + border - bleed, size[0] / 3 - border * 2, size[1] / 3 - border * 2) scribus.createImage(0 + border - bleed, size[1] / 3 + border - bleed, size[0] / 3 - border * 2, size[1] / 3 - border * 2) scribus.createImage(size[0] / 3 + border - bleed, size[1] / 3 + border - bleed, size[0] / 3 - border * 2, size[1] / 3 - border * 2) scribus.createImage((size[0] / 3) * 2 + border - bleed, size[1] / 3 + border - bleed, size[0] / 3 - border * 2, size[1] / 3 - border * 2) scribus.createImage(0 + border - bleed, (size[1] / 3) * 2 + border - bleed, size[0] / 3 - border * 2, size[1] / 3 - border * 2) scribus.createImage(size[0] / 3 + border - bleed, (size[1] / 3) * 2 + border - bleed, size[0] / 3 - border * 2, size[1] / 3 - border * 2) scribus.createImage((size[0] / 3) * 2 + border - bleed, (size[1] / 3) * 2 + border - bleed, size[0] / 3 - border * 2, size[1] / 3 - border * 2) #guides scribus.setVGuides([ size[0] / 3 - border - bleed, size[0] / 3 - bleed + border, (size[0] / 3) * 2 - border - bleed, (size[0] / 3) * 2 + border - bleed ]) scribus.setHGuides([ size[1] / 3 - border - bleed, size[1] / 3 + border - bleed, (size[1] / 3) * 2 - border - bleed, (size[1] / 3) * 2 + border - bleed ])
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)