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 on_privmsg(self, nick, chan, msg): if chan == "#osp" and msg.startswith("!"): p = r"^([a-zA-Z]+)\((.+)*\)" r = re.search(p, msg[1:]) if r is None: return else: cmd, args = r.groups() if cmd in methodList: scribus.setRedraw(False) try: if args is None: r = getattr(scribus, cmd)() elif type(ast.literal_eval(args)) is tuple: r = getattr(scribus, cmd)(*ast.literal_eval(args)) else: r = getattr(scribus, cmd)(ast.literal_eval(args)) self.privmsg(chan, "called %s" % cmd) self.privmsg(chan, "returned %s" % r if r is not None else "nothing") # Ugly workaround to force scribus refreshing scribus.zoomDocument(101) scribus.zoomDocument(100) except TypeError: self.privmsg(chan, "%s" % getattr(scribus, cmd).__doc__) scribus.setRedraw(True) elif cmd == "help": for i in info(scribus): self.privmsg(chan, "%s" % i) else: self.privmsg(chan, "No such a command: %s" % cmd)
def run(self): selCount = scribus.selectionCount() if selCount == 0: scribus.messageBox('Scribus Data Merger- Usage Error', "There is no objects selected.\nPlease try again.", scribus.ICON_WARNING, scribus.BUTTON_OK) sys.exit(2) csvData = self.loadCsvData() # Create a list with the names of the selected objects: selectedObjects = [] # Loop through the selected objects and put their names into the list selectedObjects o = 0 while (o < selCount): selectedObjects.append(scribus.getSelectedObject(o)) o = o + 1 startingPage = scribus.currentPage() lastRow = len(csvData) if(self.__dataObject.getNumberOfLinesToMerge() != 'All'): lastRow = int(self.__dataObject.getNumberOfLinesToMerge()) lastRow = min(lastRow, len(csvData)) # This will prevent the script from trying to merge data from non-existing rows in the data file currentPage = scribus.currentPage() rowNumber = 0 insertPageBeforeThis = -1 while (rowNumber < lastRow): if(scribus.pageCount() > currentPage): insertPageBeforeThis = currentPage + 1 scribus.newPage(insertPageBeforeThis) # Inserts a page before the page given as an argument currentPage = currentPage + 1 for selectedObject in selectedObjects: # Loop through the names of all the selected objects scribus.gotoPage(startingPage) # Set the working page to the one we want to copy objects from scribus.copyObject(selectedObject) scribus.gotoPage(currentPage) scribus.pasteObject() # Paste the copied object on the new page scribus.docChanged(1) scribus.gotoPage(currentPage) # Make sure ware are on the current page before we call getAllObjects() newPageObejcts = scribus.getAllObjects() for pastedObject in newPageObejcts: # Loop through all the items on the current page objType = scribus.getObjectType(pastedObject) text = CONST.EMPTY if(objType == 'TextFrame'): text = scribus.getAllText(pastedObject) # This should have used getText but getText does not return the text values of just pasted objects text = self.replaceText(csvData[rowNumber], text) scribus.setText(text, pastedObject) if(objType == 'ImageFrame'): text = scribus.getImageFile(pastedObject) # self.info("Image text", text) # Todo: Find out if it is possible to replace text in the ImageFile property rowNumber = rowNumber + 1 scribus.setRedraw(1) scribus.docChanged(1) scribus.messageBox("Merge Completed", "Merge Completed", icon=scribus.ICON_INFORMATION, button1=scribus.BUTTON_OK)
def main(): text_frames, image_frames = get_placeholders() sla_template_filename = scribus.getDocName() sla_template_path = Path(sla_template_filename) if 'file' in CONFIGURATION['data'] and CONFIGURATION['data']['file']: data_path = str( sla_template_path.parent.joinpath(CONFIGURATION['data']['file'])) elif CONFIGURATION['data']['format'] == 'json': data_path = sla_template_path.with_suffix('.json') else: data_path = sla_template_path.with_suffix('.csv') if not os.path.isfile(data_path): sys.exit() if CONFIGURATION['data']['format'] == 'json': pass else: data_file = open(data_path, 'rt') reader = csv.DictReader(data_file) pdf_base_filename = sla_template_path.stem pdf_path = Path(sla_template_path.parent) if CONFIGURATION['output']['pdf']: pdf = scribus.PDFfile() pdf.quality = 0 pdf.fontEmbedding = 0 pdf.version = 14 scribus.setRedraw(False) for row in reader: for frame, placeholders in text_frames: fill_text_placeholders(frame, placeholders, row) for frame, placeholders in image_frames: fill_image_placeholders(frame, placeholders, row) pdf.file = str( pdf_path.joinpath(pdf_base_filename + '-' + next(iter(row.items()))[1].lower() + '.pdf')) pdf.save() scribus.docChanged(True) scribus.revertDoc() scribus.setRedraw(True) elif CONFIGURATION['output']['single-sla']: original_pages = list(range(1, scribus.pageCount() + 1)) for row in reader: new_frames = duplicate_content( original_pages, [i[0] for i in text_frames + image_frames]) for frame, placeholders in text_frames: fill_text_placeholders(new_frames[frame], placeholders, row) for frame, placeholders in image_frames: fill_image_placeholders(new_frames[frame], placeholders, row) for page in original_pages: scribus.deletePage(page)
def main_wrapper(argv): try: scribus.statusMessage("Running script...") scribus.progressReset() main(argv) finally: if scribus.haveDoc(): scribus.setRedraw(True) scribus.statusMessage("") scribus.progressReset()
def main(): cache = defaultdict(dict) try: with open(CACHE_FILE, "rb") as cache_file: cache = defaultdict(dict, json.load(cache_file)) except: pass with open(DATA_FILE, "rb") as data_file: songs_data = json.load(data_file) with open(MANUEL_PROCESSING_FILE, "rb") as manual_file: manual_processing = defaultdict(dict, json.load(manual_file)) scribus.statusMessage("Running script...") scribus.progressReset() scribus.progressTotal(len(songs_data)) init() front_matter() add_page_number() # trying to get the best sorting # setting all songs to the max height all_songs = dict(zip(songs_data.keys(), [EFFECTIVE_PAGE_HEIGHT] * len(songs_data))) # update according to cache for song_name, data in cache.iteritems(): all_songs[song_name] = min(data.get("height", EFFECTIVE_PAGE_HEIGHT), EFFECTIVE_PAGE_HEIGHT) # let's see which songs should be set on a double sided page: songs_double_page = filter(lambda x: manual_processing[x].get("double_page", False), manual_processing) for double_page in songs_double_page: all_songs[double_page] = EFFECTIVE_PAGE_HEIGHT # all double page songs should get a whole page despite their height appendix_filter = lambda a_s, boolean : {k:v for k,v in a_s.iteritems() if manual_processing[k].get("appendix", False) == boolean} main_songs = appendix_filter(all_songs, False) add_songs(main_songs, songs_double_page, manual_processing, songs_data, cache) appendix_songs = appendix_filter(all_songs, True) add_songs(appendix_songs, songs_double_page, manual_processing, songs_data, cache) toc = [] for filename in filter(lambda s: manual_processing[s].get("show", True), all_songs.keys()): toc.append((songs_data[filename]["name"], cache[filename].get("page", "XX"))) toc.sort(key=lambda (x,y): x) create_toc(toc) if scribus.haveDoc(): scribus.setRedraw(True) scribus.statusMessage("") scribus.progressReset() with open(CACHE_FILE, "wb") as cache_file: json.dump(cache, cache_file, indent=2)
def main(argv): """This is a documentation string. Write a description of what your code does here. You should generally put documentation strings ("docstrings") on all your Python functions.""" ######################### # YOUR CODE GOES HERE # ######################### userdim = scribus.getUnit() # get unit and change it to mm scribus.setUnit(scribus.UNIT_MILLIMETERS) cellwidthleft = 0 cellwidthright = 0 cellHeight = 0 pos = getPosition() while cellwidthleft <= 0: cellwidthL = scribus.valueDialog("Left Cell Width", "How wide (mm) do you wish left cells to be?", "30.0") cellwidthleft = float(cellwidthL) while cellwidthright <= 0: cellwidthR = scribus.valueDialog("Right Cell Width", "How wide (mm) do you wish right cells to be?", "30.0") cellwidthright = float(cellwidthR) while cellHeight <= 0: cellheight = scribus.valueDialog("Cell Height", "How tall (mm) do you wish cells to be?", "10.0") cellHeight = float(cellheight) data = getCSVdata() di = getDataInformation(data) hposition = pos[1] vposition = pos[0] objectlist = [] # here we keep a record of all the created textboxes so we can group them later i = 0 scribus.progressTotal(len(data)) scribus.setRedraw(False) for row in data: c = 0 for cell in row: cell = cell.strip() cellsize = cellwidthleft if c == 1: cellsize = cellwidthright textbox = scribus.createText(hposition, vposition, cellsize, cellHeight) # create a textbox objectlist.append(textbox) scribus.insertText(cell, 0, textbox) # insert the text into the textbox hposition = hposition + cellwidthleft # move the position for the next cell c = 1 vposition = vposition + cellHeight # set vertical position for next row hposition = pos[1] # reset vertical position for next row i = i + 1 scribus.progressSet(i) scribus.groupObjects(objectlist) scribus.progressReset() scribus.setUnit(userdim) # reset unit to previous value scribus.docChanged(True) scribus.statusMessage("Done") scribus.setRedraw(True)
def main_wrapper(argv): try: scribus.statusMessage("Importing .csv table...") scribus.progressReset() main(argv) finally: #exit if scribus.haveDoc() > 0: scribus.setRedraw(True) scribus.statusMessage("") scribus.progressReset()
def main_wrapper(argv): try: scribus.statusMessage("Running script...") scribus.progressReset() main(argv) finally: # Exit neatly even if the script terminated with an exception, # so we leave the progress bar and status bar blank and make sure # drawing is enabled. if scribus.haveDoc(): scribus.setRedraw(True) scribus.statusMessage("") scribus.progressReset()
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 main_wrapper(argv): try: if(scribus.haveDoc()): scribus.setRedraw(False) scribus.statusMessage(CONST.APP_NAME) scribus.progressReset() main(argv) finally: # Exit neatly even if the script terminated with an exception, # so we leave the progress bar and status bar blank and make sure # drawing is enabled. if(scribus.haveDoc()): scribus.setRedraw(True) scribus.statusMessage('') scribus.progressReset()
def main(): config = prepare_config(get_config()) new_images = get_images(config['image_dir'], config['images']) image_frames = get_sff_image_frames_details(0, empty_only=True) if len(image_frames) > 0: if len(new_images) < len(image_frames): max_imports = len(new_images) else: max_imports = len(image_frames) import_text = [ 'Found {} empty image frames on the current page.'.format( len(image_frames)), 'Following Images will be imported:' ] import_text.extend(new_images[:max_imports]) import_text.extend( ['', 'Click "Retry" to get further configuation options.']) answer = sc.messageBox('Image import', '\n'.join(import_text), button1=sc.BUTTON_OK | sc.BUTTON_DEFAULT, button2=sc.BUTTON_RETRY, button3=sc.BUTTON_ABORT | sc.BUTTON_ESCAPE) if answer == sc.BUTTON_OK: stored_images = store_images(new_images[:max_imports]) image_frame_names = [] for idx in image_frames: image_frame_names.append(image_frames[idx].name) logging.debug("image frame: {}".format(image_frames[idx].name)) fill_frames(image_frame_names, stored_images) config['images'].extend(stored_images) write_config(config) elif answer == sc.BUTTON_ABORT: sys.exit(0) elif answer == sc.Retry: print("Sorry not implemented jet :-(") sys.exit(0) else: sc.messageBox('Script failed', "Current page, doesn't contain empty image frames.", sc.ICON_CRITICAL) sys.exit(1) sc.docChanged(1) sc.setRedraw(True)
def main_wrapper(argv): try: if (scribus.haveDoc()): scribus.setRedraw(False) scribus.statusMessage(CONST.APP_NAME) scribus.progressReset() main(argv) finally: # Exit neatly even if the script terminated with an exception, # so we leave the progress bar and status bar blank and make sure # drawing is enabled. if (scribus.haveDoc()): scribus.setRedraw(True) scribus.statusMessage('') scribus.progressReset()
def alignImage(self): if scribus.haveDoc(): restore_units = scribus.getUnit( ) # since there is an issue with units other than points, scribus.setUnit(0) # we switch to points then restore later. nbrSelected = scribus.selectionCount() objList = [] for i in range(nbrSelected): objList.append(scribus.getSelectedObject(i)) scribus.deselectAll() for i in range(nbrSelected): try: obj = objList[i] scribus.selectObject(obj) frameW, frameH = scribus.getSize(obj) saveScaleX, saveScaleY = scribus.getImageScale(obj) scribus.setScaleImageToFrame(1, 0, obj) fullScaleX, fullScaleY = scribus.getImageScale(obj) scribus.setScaleImageToFrame(0, 0, obj) scribus.setImageScale(saveScaleX, saveScaleY, obj) imageW = frameW * (saveScaleX / fullScaleX) imageH = frameH * (saveScaleY / fullScaleY) imageX = 0.0 imageY = 0.0 if self.alignVar.get()[0] == "T": imageY = 0.0 elif self.alignVar.get()[0] == "M": imageY = (frameH - imageH) / 2.0 elif self.alignVar.get()[0] == "B": imageY = (frameH - imageH) if self.alignVar.get()[1] == "L": imageX = 0.0 elif self.alignVar.get()[1] == "C": imageX = (frameW - imageW) / 2.0 elif self.alignVar.get()[1] == "R": imageX = (frameW - imageW) scribus.setImageOffset(imageX, imageY, obj) scribus.docChanged(1) scribus.setRedraw(True) scribus.deselectAll() except: nothing = "nothing" scribus.setUnit(restore_units) self.master.destroy()
def alignImage(self): if scribus.haveDoc(): restore_units = scribus.getUnit() # since there is an issue with units other than points, scribus.setUnit(0) # we switch to points then restore later. nbrSelected = scribus.selectionCount() objList = [] for i in range(nbrSelected): objList.append(scribus.getSelectedObject(i)) scribus.deselectAll() for i in range(nbrSelected): try: obj = objList[i] scribus.selectObject(obj) frameW, frameH = scribus.getSize(obj) saveScaleX, saveScaleY = scribus.getImageScale(obj) scribus.setScaleImageToFrame(1, 0, obj) fullScaleX, fullScaleY = scribus.getImageScale(obj) scribus.setScaleImageToFrame(0, 0, obj) scribus.setImageScale(saveScaleX, saveScaleY, obj) imageW = frameW * (saveScaleX / fullScaleX) imageH = frameH * (saveScaleY / fullScaleY) imageX = 0.0 imageY = 0.0 if self.alignVar.get()[0] == "T": imageY = 0.0 elif self.alignVar.get()[0] == "M": imageY = (frameH - imageH) / 2.0 elif self.alignVar.get()[0] == "B": imageY = (frameH - imageH) if self.alignVar.get()[1] == "L": imageX = 0.0 elif self.alignVar.get()[1] == "C": imageX = (frameW - imageW) / 2.0 elif self.alignVar.get()[1] == "R": imageX = (frameW - imageW) scribus.setImageOffset(imageX, imageY, obj) scribus.docChanged(1) scribus.setRedraw(True) scribus.deselectAll() except: nothing = "nothing" scribus.setUnit(restore_units) self.master.destroy()
def main_wrapper(argv): """The main_wrapper() function disables redrawing, sets a sensible generic status bar message, and optionally sets up the progress bar. It then runs the main() function. Once everything finishes it cleans up after the main() function, making sure everything is sane before the script terminates.""" try: #scribus.statusMessage("Running script...") scribus.progressReset() main(argv) finally: # Exit neatly even if the script terminated with an exception, # so we leave the progress bar and status bar blank and make sure # drawing is enabled. if scribus.haveDoc(): scribus.setRedraw(True) scribus.statusMessage("") scribus.progressReset()
def main_wrapper(argv): try: if(scribus.haveDoc()): scribus.setRedraw(False) scribus.statusMessage(CONST.APP_NAME) scribus.progressReset() main(argv) else: scribus.messageBox('Usage Error', 'You need a Document open', icon=scribus.ICON_WARNING, button1=scribus.BUTTON_OK) sys.exit(2) finally: # Exit neatly even if the script terminated with an exception, # so we leave the progress bar and status bar blank and make sure # drawing is enabled. if scribus.haveDoc(): scribus.setRedraw(True) scribus.statusMessage("") scribus.progressReset()
def main_wrapper(): """The main_wrapper() function disables redrawing, sets a sensible generic status bar message, and optionally sets up the progress bar. It then runs the main() function. Once everything finishes it cleans up after the main() function, making sure everything is sane before the script terminates.""" scribus.messageBox("Version", SCRIPT_VERSION) if not scribus.haveDoc(): scribus.messageBox("Bwaaaahaha", "Need a base document open") else: scribus.setRedraw(False) try: scribus.statusMessage("Running script...") scribus.progressReset() main() finally: # Exit neatly even if the script terminated with an exception, # so we leave the progress bar and status bar blank and make sure # drawing is enabled. if scribus.haveDoc(): scribus.setRedraw(True) scribus.docChanged(True) scribus.statusMessage("") scribus.progressReset()
def main(argv): """The main() function disables redrawing, sets a sensible generic status bar message, and optionally sets up the progress bar. It then runs the main() function. Once everything finishes it cleans up after the create() function, making sure everything is sane before the script terminates.""" currentDoc = scribus.getDocName() try: scribus.statusMessage("Importing .csv table...") scribus.progressReset() create(argv) if scribus.haveDoc(): scribus.closeDoc() scribus.openDoc(currentDoc) finally: # Exit neatly even if the script terminated with an exception, # so we leave the progress bar and status bar blank and make sure # drawing is enabled. if scribus.haveDoc(): scribus.setRedraw(True) scribus.closeDoc() scribus.openDoc(currentDoc) scribus.statusMessage("") scribus.progressReset()
def main_wrapper(): """The main_wrapper() function disables redrawing, sets a sensible generic status bar message, and optionally sets up the progress bar. It then runs the main() function. Once everything finishes it cleans up after the main() function, making sure everything is sane before the script terminates.""" scribus.messageBox("Version",SCRIPT_VERSION) if not scribus.haveDoc(): scribus.messageBox("Bwaaaahaha","Need a base document open") else: scribus.setRedraw(False) try: scribus.statusMessage("Running script...") scribus.progressReset() main() finally: # Exit neatly even if the script terminated with an exception, # so we leave the progress bar and status bar blank and make sure # drawing is enabled. if scribus.haveDoc(): scribus.setRedraw(True) scribus.docChanged(True) scribus.statusMessage("") scribus.progressReset()
def slotDoIt(self): nfs = self.val.value() obj = scribus.getSelectedObject(0) t = scribus.getText(obj) scribus.deselectAll() t0 = scribus.getText(obj) fs = scribus.getFontSize(obj) tl = scribus.getTextLength(obj) idx = t0.find(t) + (len(t) / 2) base = fs #print t0 #print t #print "FS %i NFS %i IDX %i START %i" % (fs,nfs,idx,idx - int((nfs - fs) / 0.1)) for i in xrange(max(idx - int((nfs - fs) * 10), 0), idx): scribus.selectText(i, 1, obj) base += 0.1 scribus.setFontSize(base,obj) for i in xrange(idx, min(idx + int((nfs - fs) * 10), tl - 1)): scribus.selectText(i, 1, obj) base -= 0.1 scribus.setFontSize(base,obj) scribus.setRedraw(True) scribus.selectObject(obj)
def create(argv): """ - create a page using the "badge" master page. - add the text field with the name - add the text with the role in the project """ ######################### # YOUR CODE GOES HERE # ######################### userdim=scribus.getUnit() #get unit and change it to mm scribus.setUnit(scribus.UNIT_POINTS) data = getCSVdata() scribus.progressTotal(len(data)+1) scribus.setRedraw(False) i = 0; #Select Output Directory and define some Vars based on it. #baseDirName = scribus.fileDialog("Rosenlehrpfad - Wahl des Ausgabeverzeichnisses", "*","./" ,False, False, True) baseDirName = os.path.abspath("./output") tmpFileName = os.path.join(baseDirName, "tmp.sla") idtextstring = "Rosenid" gertextstring = "RosentextDeutsch" lattextstring = "RosentextLatein" if not os.path.exists(baseDirName): os.makedirs(baseDirName) else: for the_file in os.listdir(baseDirName): file_path = os.path.join(baseDirName, the_file) try: if os.path.isfile(file_path): os.unlink(file_path) except Exception, e: print e
contents = scribus.getTextLength(textbox) while 1: if ((c == contents) or (c > contents)): break if ((c + 1) > contents - 1): nextchar = ' ' else: scribus.selectText(c + 1, 1, textbox) nextchar = scribus.getText(textbox) scribus.selectText(c, 1, textbox) char = scribus.getText(textbox) if (len(char) != 1): c += 1 continue alpha = random.randint(1, 26) letter = chr(alpha + 96) LETTER = chr(alpha + 64) if ((ord(char) > 96) and (ord(char) < 123)): scribus.deleteText(textbox) scribus.insertText(letter, c, textbox) if ((ord(char) > 64) and (ord(char) < 91)): scribus.deleteText(textbox) scribus.insertText(LETTER, c, textbox) c += 1 contents = scribus.getTextLength(textbox) scribus.setRedraw(1) scribus.docChanged(1) scribus.messageBox("Finished", "That should do it!", icon=0, button1=1)
else: scribus.deleteText(textbox) scribus.insertText(follow_double, c, textbox) if ((ord(char) == 39) and (c == 0)): scribus.deleteText(textbox) scribus.insertText(lead_single, c, textbox) elif (ord(char) == 39): if ((prevchar == '.') or (prevchar == ',') or (prevchar == '?') or (prevchar == '!')): scribus.deleteText(textbox) scribus.insertText(follow_single, c, textbox) elif ((ord(prevchar) == 34) and ((nextchar != ' ') and (nextchar != ',') and (nextchar != '.'))): scribus.deleteText(textbox) scribus.insertText(lead_single, c, textbox) elif ((prevchar != ' ') and (ord(prevchar) != 34) and (nextchar != ' ')): scribus.deleteText(textbox) scribus.insertText(follow_single, c, textbox) elif ((prevchar == ' ') or ((nextchar != ' ') and (ord(nextchar) != 34))): scribus.deleteText(textbox) scribus.insertText(lead_single, c, textbox) else: scribus.deleteText(textbox) scribus.insertText(follow_single, c, textbox) c += 1 prevchar = char scribus.setRedraw(1) scribus.docChanged(1) endmessage = 'Successfully ran script\n Last character read was '+str(char) # Change this message to your liking scribus.messageBox("Finished", endmessage,icon=0,button1=1)
scribus.setColumns(1, new_textbox) scribus.textFlowMode(new_textbox, 1) else: if (frametype == 'imageL'): imageload = scribus.fileDialog('Load image','Images(*.jpg *.png *.tif *.JPG *.PNG *.jpeg *.JPEG *.TIF)',haspreview=1) new_image = scribus.createImage(new_left, float(new_top), new_width, float(new_height),framename) scribus.loadImage(imageload, new_image) scribus.messageBox('Please Note',"Your frame will be created once you click OK.\n\nUse the Context Menu to Adjust Frame to Image.\n\nIf your image does not fill the width completely,\nstretch the frame vertically first.",scribus.BUTTON_OK) else: new_image = scribus.createImage(new_left, float(new_top), new_width, float(new_height),framename) scribus.textFlowMode(new_image, 1) scribus.setScaleImageToFrame(scaletoframe=1, proportional=1, name=new_image) if __name__ == '__main__': # This script makes no sense without a document open if not scribus.haveDoc(): scribus.messageBox('Scribus - Script Error', "No document open", scribus.ICON_WARNING, scribus.BUTTON_OK) sys.exit(1) # Disable redraws scribus.setRedraw(False) # Run the main script, ensuring redraws are re-enabled even if the # script aborts with an exception, and don't fail with an exception # even if the document is closed while the script runs. try: main(sys.argv) finally: try: scribus.setRedraw(True) except: pass
def main(argv): """This is a documentation string. Write a description of what your code does here. You should generally put documentation strings ("docstrings") on all your Python functions.""" ######################### # YOUR CODE GOES HERE # ######################### userdim = scribus.getUnit() #get unit and change it to mm scribus.setUnit(scribus.UNIT_MILLIMETERS) cellwidthleft = 0 cellwidthright = 0 cellHeight = 0 pos = getPosition() while cellwidthleft <= 0: cellwidthL = scribus.valueDialog( 'Left Cell Width', 'How wide (mm) do you wish left cells to be?', '30.0') cellwidthleft = float(cellwidthL) while cellwidthright <= 0: cellwidthR = scribus.valueDialog( 'Right Cell Width', 'How wide (mm) do you wish right cells to be?', '30.0') cellwidthright = float(cellwidthR) while cellHeight <= 0: cellheight = scribus.valueDialog( 'Cell Height', 'How tall (mm) do you wish cells to be?', '10.0') cellHeight = float(cellheight) data = getCSVdata() di = getDataInformation(data) hposition = pos[1] vposition = pos[0] objectlist = [ ] # here we keep a record of all the created textboxes so we can group them later i = 0 scribus.progressTotal(len(data)) scribus.setRedraw(False) for row in data: c = 0 for cell in row: cell = cell.strip() cellsize = cellwidthleft if c == 1: cellsize = cellwidthright textbox = scribus.createText(hposition, vposition, cellsize, cellHeight) #create a textbox objectlist.append(textbox) scribus.insertText(cell, 0, textbox) #insert the text into the textbox hposition = hposition + cellwidthleft #move the position for the next cell c = 1 vposition = vposition + cellHeight #set vertical position for next row hposition = pos[1] #reset vertical position for next row i = i + 1 scribus.progressSet(i) scribus.groupObjects(objectlist) scribus.progressReset() scribus.setUnit(userdim) # reset unit to previous value scribus.docChanged(True) scribus.statusMessage("Done") scribus.setRedraw(True)
currwidth, currheight = scribus.getSize(new_image) Xscale, Yscale = scribus.getImageScale(new_image) if (Xscale != Yscale): scribus.sizeObject(currwidth, currheight * Xscale / Yscale, new_image) scribus.setScaleImageToFrame(1, 1, new_image) else: new_image = scribus.createImage(new_left, float(new_top), new_width, float(new_height), framename) scribus.textFlowMode(new_image, 1) scribus.setScaleImageToFrame(1, 1, new_image) if __name__ == '__main__': # This script makes no sense without a document open if not scribus.haveDoc(): scribus.messageBox('Scribus - Script Error', "No document open", scribus.ICON_WARNING, scribus.BUTTON_OK) sys.exit(1) # Disable redraws scribus.setRedraw(False) # Run the main script, ensuring redraws are re-enabled even if the # script aborts with an exception, and don't fail with an exception # even if the document is closed while the script runs. try: main(sys.argv) finally: try: scribus.setRedraw(True) except: pass
scribus.messageBox('Selection Count', "You must have at least one object selected", scribus.ICON_WARNING, scribus.BUTTON_OK) sys.exit(2) captionloc = scribus.valueDialog("Caption Location","Where to put the caption(s) -\n B/T/R/L?", "b") captionloc = captionloc[0] location = captionloc.upper() pageunits = scribus.getUnit() scribus.setUnit(scribus.UNIT_POINTS) while count < numselect: frames.append(scribus.getSelectedObject(count)) count += 1 for frame in frames: fwidth, fheight = scribus.getSize(frame) fx, fy = scribus.getPosition(frame) if location == "B": textf = scribus.createText(fx, fy+fheight, fwidth, 24) elif location == "T": textf = scribus.createText(fx, fy-24, fwidth, 24) elif location == "R": textf = scribus.createText(fx + fwidth, fy, 150, 40) elif location == "L": textf = scribus.createText(fx-150, fy + fheight - 40, 150, 40) scribus.setUnit(pageunits) scribus.setRedraw(True)
def main(): cache = defaultdict(dict) try: with open(CACHE_FILE, "rb") as cache_file: cache = defaultdict(dict, json.load(cache_file)) except: pass with open(DATA_FILE, "rb") as data_file: songs_data = json.load(data_file) with open(MANUEL_PROCESSING_FILE, "rb") as manual_file: manual_processing = defaultdict(dict, json.load(manual_file)) scribus.statusMessage("Running script...") scribus.progressReset() scribus.progressTotal(len(songs_data)) init() front_matter() add_page_number() # trying to get the best sorting # setting all songs to the max height all_songs = dict( zip(songs_data.keys(), [EFFECTIVE_PAGE_HEIGHT] * len(songs_data))) # update according to cache for song_name, data in cache.iteritems(): all_songs[song_name] = min(data.get("height", EFFECTIVE_PAGE_HEIGHT), EFFECTIVE_PAGE_HEIGHT) # let's see which songs should be set on a double sided page: songs_double_page = filter( lambda x: manual_processing[x].get("double_page", False), manual_processing) for double_page in songs_double_page: all_songs[ double_page] = EFFECTIVE_PAGE_HEIGHT # all double page songs should get a whole page despite their height appendix_filter = lambda a_s, boolean: { k: v for k, v in a_s.iteritems() if manual_processing[k].get("appendix", False) == boolean } main_songs = appendix_filter(all_songs, False) add_songs(main_songs, songs_double_page, manual_processing, songs_data, cache) appendix_songs = appendix_filter(all_songs, True) add_songs(appendix_songs, songs_double_page, manual_processing, songs_data, cache) toc = [] for filename in filter(lambda s: manual_processing[s].get("show", True), all_songs.keys()): toc.append( (songs_data[filename]["name"], cache[filename].get("page", "XX"))) toc.sort(key=lambda (x, y): x) create_toc(toc) if scribus.haveDoc(): scribus.setRedraw(True) scribus.statusMessage("") scribus.progressReset() with open(CACHE_FILE, "wb") as cache_file: json.dump(cache, cache_file, indent=2)
# it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. import scribus as sc if sc.haveDoc(): nbrSelected = sc.selectionCount() objList = [] for i in range(nbrSelected): objList.append(sc.getSelectedObject(i)) for i in range(nbrSelected): try: obj = objList[i] sc.setScaleImageToFrame(True, False, obj) scaleX, scaleY = sc.getImageScale(obj) sc.setScaleImageToFrame(False, False, obj) if scaleX > scaleY: scale = scaleX sc.setImageScale(scale, scale, obj) elif scaleY > scaleX: scale = scaleY sc.setImageScale(scale, scale, obj) sc.docChanged(1) sc.setRedraw(True) except Exception: pass
def main(argv): userdim = scribus.getUnit() # get unit and change it to mm scribus.setUnit(scribus.UNIT_MILLIMETERS) cellwidthleft = 0 cellwidthright = 0 # Set starting position hposition = 28 vposition = 20 data = getCSVdata() di = getDataInformation(data) ncol = len(data[0]) nrow = len(data) scribus.messageBox("Table", " " + str(ncol) + " columns, " + str(nrow) + " rows ") #jpg ColWidthList = [] TableWidth = 0 RowHeightList = [] TableHeight = 0 i = 0 for row in data: if i == 0: c = 0 for cell in row: ColWidth = 40 ColWidthList.append(ColWidth) TableWidth = TableWidth + ColWidth c = c + 1 RowHeight = 15 RowHeightList.append(RowHeight) TableHeight = TableHeight + RowHeight i = i + 1 objectlist = [ ] # here we keep a record of all the created textboxes so we can group them later i = 0 scribus.progressTotal(len(data)) scribus.setRedraw(False) rowindex = 0 new_row_indication = 1 new_page_indication = 1 firstorigin_indicator = 1 while rowindex < len(data): c = 0 origin_cd = data[rowindex][0].strip() origin = data[rowindex][1].strip() origin_complete = origin + ' (' + origin_cd + ")" headerorigin = origin_complete origin_added = 0 destination_cd = data[rowindex][2].strip() destination = data[rowindex][3].strip() destination_complete = destination + ' (' + destination_cd + ")" fareplan = data[rowindex][4].strip() fareplan_type = data[rowindex][5].strip() fareplan_complete = fareplan + ' ' + fareplan_type[:1] fare = data[rowindex][6].strip() fare = float(fare) fare = "{0:.2f}".format(fare) fare_onboard = data[rowindex][7].strip() fare_onboard = float(fare_onboard) fare_onboard = "{0:.2f}".format(fare_onboard) cellheight_market = 5 cellheight_market_dos = 5 try: last_origin = data[rowindex - 1][1].strip() except: last_origin = origin try: last_destination = data[rowindex - 1][3].strip() except: last_destination = destination cellsize = ColWidthList[c] cellHeight = RowHeightList[i] # Check to see if near bottom of the page, if so wrap it over if (vposition > 227): hposition = hposition + cellsize vposition = 20 new_row_indication = 1 # If at end, reset and create new page if (hposition > 174): scribus.newPage(-1) hposition = 28 vposition = 20 new_page_indication = 1 firstorigin_indicator = 0 if new_row_indication == 1: textbox = scribus.createText(hposition, 16, cellsize / 2, 4) # create a textbox. objectlist.append(textbox) scribus.setStyle('FareplanHeader', textbox) scribus.insertText('Fareplan', 0, textbox) c = c + 1 textbox = scribus.createText(hposition + (cellsize / 2), 16, cellsize / 2, 4) # create a textbox. objectlist.append(textbox) scribus.setStyle('FareplanHeader', textbox) scribus.insertText('Amount', 0, textbox) c = c + 1 # if (firstorigin_indicator == 1): # headerorigin = origin_complete # textbox = scribus.createText(20, 10, cellsize*4, 4) # create a textbox. # objectlist.append(textbox) # scribus.setStyle('HeaderOrigin', textbox) # scribus.insertText(headerorigin, 0, textbox) # c = c + 1 # Origin textbox if (rowindex < len(data)): if ((origin != last_origin) or (rowindex == 0)): # Add 'btwn' text textbox = scribus.createText(hposition, vposition, cellsize, 4) # create a textbox. objectlist.append(textbox) scribus.setStyle( 'Headings', textbox ) # set it in the style 'Headings' as defined in Scribus. scribus.insertText( 'btwn', 0, textbox) # insert the origin into the textbox. # scribus.setDistances(1,1,1,1) # set the distances. vposition = vposition + 4 # Shift position of cell down. c = c + 1 textbox = scribus.createText( hposition, vposition, cellsize, cellheight_market_dos) # create a textbox. objectlist.append(textbox) scribus.setStyle( 'Headings', textbox ) # set it in the style 'Headings' as defined in Scribus. scribus.insertText( origin_complete, 0, textbox) # insert the origin into the textbox. while (scribus.textOverflows(textbox) > 0): cellheight_market_dos += 1 scribus.sizeObject(cellsize, cellheight_market_dos, textbox) vposition = vposition + cellheight_market_dos # Shift position of cell down. c = c + 1 # Add 'and' text textbox = scribus.createText(hposition, vposition, cellsize, 4) # create a textbox. objectlist.append(textbox) scribus.setStyle( 'andStyle', textbox ) # set it in the style 'andStyle' as defined in Scribus. scribus.insertText( 'and', 0, textbox) # insert the origin into the textbox. vposition = vposition + 4 # Shift position of cell down. c = c + 1 origin_added = 1 firstorigin_indicator = firstorigin_indicator + 1 # Insert the origin at the top margin if (firstorigin_indicator == 1 or rowindex == 0): headerorigin = origin_complete textbox = scribus.createText(28, 10, cellsize * 4, 4) # create a textbox. objectlist.append(textbox) scribus.setStyle('HeaderOrigin', textbox) scribus.insertText(headerorigin, 0, textbox) c = c + 1 # Destination textbox if ((destination != last_destination) or (rowindex == 0) or (origin_added == 1)): textbox = scribus.createText( hposition, vposition, cellsize, cellheight_market) # create a textbox. objectlist.append(textbox) scribus.setStyle( 'Headings', textbox ) # set it in the style 'Headings' as defined in Scribus. scribus.insertText( destination_complete, 0, textbox) # insert the destination into the textbox. while (scribus.textOverflows(textbox) > 0): cellheight_market += 1 scribus.sizeObject(cellsize, cellheight_market, textbox) vposition = vposition + cellheight_market # Shift position of cell down. c = c + 1 rowindex = rowindex + 1 # Fareplan textbox fareplan_box_height = 5 if fare_onboard != '0.00': fareplan_box_height = 10 textbox = scribus.createText(hposition, vposition, cellsize / 2, fareplan_box_height) # create a textbox. objectlist.append(textbox) scribus.insertText(fareplan_complete, 0, textbox) # insert the fareplan into the textbox. hposition = hposition + (cellsize / 2) # Shift position of cell right. c = c + 1 # Fare textbox textbox = scribus.createText(hposition, vposition, cellsize / 2, 5) # create a textbox. objectlist.append(textbox) scribus.insertText(fare, 0, textbox) # insert the fare into the textbox. c = c + 1 if fare_onboard != '0.00': vposition = vposition + 5 # Shift position of cell down. textbox = scribus.createText(hposition, vposition, cellsize / 2, 5) # create a textbox. objectlist.append(textbox) scribus.setStyle('OnBoard', textbox) scribus.insertText(fare_onboard, 0, textbox) # insert the fare into the textbox. hposition = hposition - (cellsize / 2 ) # Shift position of cell back. vposition = vposition + 5 # Shift position of cell down. c = c + 1 else: hposition = hposition - (cellsize / 2 ) # Shift position of cell back. vposition = vposition + 5 # Shift position of cell down. i = i + 1 new_row_indication = 0 new_page_indication = 0 scribus.deselectAll() scribus.groupObjects(objectlist) scribus.progressReset() scribus.setUnit(userdim) # reset unit to previous value scribus.docChanged(True) scribus.statusMessage("Done") scribus.setRedraw(True)
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 generateContent(string, window): #generates all the elements/only one element start = 0 end = 0 if string == "all": #dont include the first line to make the data sort work [1:] #sort the the elements by date data = sorted(getCSVdata()[1:], key=lambda row: dateFun(str.strip(row[5])), reverse=True) end = len(data) print(str(end) + " " + str(start)) print("generating elements from all lines") window.destroy() elif RepresentsInt(string): start = int(string) - 1 #index shifting end = int(string) print("only generating line " + string) data = getCSVdata() window.destroy() else: print(string + " is not a valid value") print("exiting") window.destroy() sys.exit() if not scribus.haveDoc() > 0: #do we have a doc? scribus.messageBox("importcvs2table", "No opened document.\nPlease open one first.") sys.exit() userdim = scribus.getUnit() #get unit and change it to mm scribus.setUnit(scribus.UNIT_MILLIMETERS) lineWidth = 3.92 #aka 1.383mm, kp warum rowDate = "" for i in range(start, end): rowName = str.strip(data[i][0]) rowCategory = str.strip(data[i][1]) rowDescription = str.strip(data[i][2]) rowPrice = str.strip(data[i][3]) rowPlace = str.strip(data[i][4]) rowDate = str.strip(data[i][5]) rowTime = str.strip(data[i][6]) if rowName == "": #skip empty csv lines continue print("add element: " + rowName) #random values hpos = 120.0 vpos = 200.0 hposition = 120.0 vposition = 200.0 objectlist = [] #list for all boxes x = 0 #sets the progress #create the blue box print("create the blue line") blueBox = scribus.createLine(hposition + 1, vposition, hposition + 1, vposition + 5.863) scribus.setLineColor("Cyan", blueBox) scribus.setLineWidth(lineWidth, blueBox) objectlist.append(blueBox) scribus.progressSet(x) x = 1 #create the data character box #these are the width values for the numbers zero = 4.608 one = 2.839 two = 4.724 three = 4.393 four = 4.625 five = 4.261 six = 4.278 seven = 4.261 eight = 4.625 nine = 4.708 lenArray = [zero, one, two, three, four, five, six, seven, eight, nine] marginleft = 1.3 margintop = 0.519 #substract, cause the box is heigher that the blue line cellwidthright = 10.951 cellHeight = 8.282 hposition = hposition + marginleft + 1 textbox = scribus.createText(hposition, vposition - margintop, cellwidthright, cellHeight) scribus.setFont("Quicksand Regular", textbox) scribus.setFontSize(20.0, textbox) finalDate = "" rowDateLength = 0 #checks if the rowDate is from 01-09, in that case remove the zero if rowDate[0] == '0': finalDate = rowDate[1] rowDateLength = lenArray[int(rowDate[1])] else: finalDate = rowDate[:2] rowDateLength = lenArray[int(rowDate[0])] + lenArray[int( rowDate[1])] scribus.insertText(finalDate, 0, textbox) print("day: " + finalDate) objectlist.append(textbox) scribus.progressSet(x) x = 2 #create the month/day box print("create the box with the day and month") width = 19.447 height = 8.025 marginleft = rowDateLength #gain that from the calculations above, depends on the width of the rowDate characters monthBox = scribus.createText(hposition + marginleft + 0.7, vposition, width, height) scribus.setFont("Quicksand Regular", monthBox) scribus.setFontSize(8.5, monthBox) month = "" m = rowDate[3:5] if m == '01': month = "Januar" elif m == '02': month = "Februar" elif m == '03': month = "März" elif m == '04': month = "April" elif m == '05': month = "Mai" elif m == '06': month = "Juni" elif m == '07': month = "Juli" elif m == '08': month = "August" elif m == '09': month = "September" elif m == '10': month = "Oktober" elif m == '11': month = "November" elif m == '12': month = "Dezember" else: print("cant determine month!") day = datetime.date(int(rowDate[6:]), int(m), int(rowDate[:2])).weekday() dayName = "" if day == 0: dayName = "Montag" elif day == 1: dayName = "Dienstag" elif day == 2: dayName = "Mittwoch" elif day == 3: dayName = "Donnerstag" elif day == 4: dayName = "Freitag" elif day == 5: dayName = "Samstag" elif day == 6: dayName = "Sonntag" else: print("cant determine day!") text = month + "\n" + dayName scribus.setStyle("Kalender_neu_Monat und Tag", monthBox) scribus.insertText(text, 0, monthBox) print("month: " + month + " day: " + dayName) objectlist.append(monthBox) scribus.progressSet(x) x = 3 #create the main text box print("create the main text box") margintop = 5.5 hpos = hpos - 0.383 #i dont know why but scribus always places the element 0.383 right than it should be :/ mainTextBox = scribus.createText( hpos, vposition + margintop, 43.0, 45.0) #minus eins weil der blaue balken seinen kasten overflowed #insert category print("insert the category: " + rowCategory) scribus.insertText(rowCategory, 0, mainTextBox) endCategory = scribus.getTextLength(mainTextBox) scribus.selectText(0, endCategory, mainTextBox) scribus.setFontSize(10.5, mainTextBox) scribus.selectText(0, endCategory, mainTextBox) scribus.setStyle("Kalender_Eventname", mainTextBox) #insert main text print("insert the main text") scribus.insertText("\n" + rowDescription, endCategory, mainTextBox) endMainText = scribus.getTextLength(mainTextBox) - endCategory scribus.selectText(endCategory, endMainText, mainTextBox) scribus.setStyle("Kalender_Eventbeschreibung", mainTextBox) #get start length to color everything black and set font size startAll = scribus.getTextLength(mainTextBox) createPlaceTimePrice(mainTextBox, "\n| Ort: ", "", "Kalender_Eventname") #insert value for place createPlaceTimePrice(mainTextBox, rowPlace, "Heuristica Regular", "") #insert time letters createPlaceTimePrice(mainTextBox, " | Zeit: ", "Quicksand Regular", "") #insert time value createPlaceTimePrice(mainTextBox, rowTime, "Heuristica Regular", "") #insert price letters createPlaceTimePrice(mainTextBox, " | Eintritt: ", "Quicksand Regular", "") #insert price value createPlaceTimePrice(mainTextBox, rowPrice, "Heuristica Regular", "") #setFontSize and black color for the whole detail box endAll = scribus.getTextLength(mainTextBox) - startAll scribus.selectText(startAll, endAll, mainTextBox) scribus.setFontSize(8.5, mainTextBox) scribus.selectText(startAll, endAll, mainTextBox) scribus.setTextColor("Black", mainTextBox) objectlist.append(mainTextBox) scribus.progressSet(x) #do some generell stuff scribus.groupObjects(objectlist) scribus.progressReset() scribus.setUnit(userdim) # reset unit to previous value scribus.docChanged(True) scribus.statusMessage("Done") scribus.setRedraw(True) print("done") return 0