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 getPosition(): if scribus.selectionCount() == 1: areaname = scribus.getSelectedObject() position = scribus.getPosition(areaname) vpos = position[1] hpos = position[0] scribus.deleteObject(areaname) return vpos, hpos else: scribus.messageBox("csv2table", "please select ONE Object to mark the drawing area for the table") sys.exit()
def getPosition(): if scribus.selectionCount() == 1: areaname = scribus.getSelectedObject() position= scribus.getPosition(areaname) vpos = position[1] hpos = position[0] scribus.deleteObject(areaname) return vpos, hpos else: scribus.messageBox("csv2table", "please select ONE Object to mark the drawing area for the table") sys.exit()
def fileMatchingTextFrame(sampleFrameName, pattern): pagenum = scribus.pageCount() for page in range(1, pagenum + 1): scribus.gotoPage(page) d = scribus.getPageItems() for item in d: # print(item) frameName = item[0] if (item[1] == 4): if frameName != sampleFrameName and remove_copy_prefix(frameName).startswith(pattern): print(frameName + " found") position = scribus.getPosition(frameName) scribus.selectObject(sampleFrameName) scribus.duplicateObject() #duplicateFrameName = scribus.getSelectedObject() scribus.moveObjectAbs(position[0], position[1]) scribus.deleteObject(frameName)
def fileMatchingTextFrame(sampleFrameName, pattern): pagenum = scribus.pageCount() for page in range(1, pagenum + 1): scribus.gotoPage(page) d = scribus.getPageItems() for item in d: # print(item) frameName = item[0] if (item[1] == 4): if frameName != sampleFrameName and remove_copy_prefix( frameName).startswith(pattern): print(frameName + " found") position = scribus.getPosition(frameName) scribus.selectObject(sampleFrameName) scribus.duplicateObject() #duplicateFrameName = scribus.getSelectedObject() scribus.moveObjectAbs(position[0], position[1]) scribus.deleteObject(frameName)
def main(): pass n = scribus.selectionCount() if n == 0: scribus.messageBox('Error', 'No item selected') return items = [] for i in range(n): items.append(scribus.getSelectedObject(i)) for item in items: pos = scribus.getPosition(item) dx, dy = pos scribus.pasteObject() new_item = scribus.getSelectedObject() pos = scribus.getPosition(new_item) dx, dy = dx - pos[0], dy - pos[1] scribus.moveObject(dx, dy, new_item) scribus.deleteObject(item)
working = scribus.getActiveLayer() page = 1 pagenum = scribus.pageCount() while (page <= pagenum): scribus.gotoPage(page) scribus.setActiveLayer(working) # maybe not necessary? pageitems = scribus.getPageItems() for item in pageitems: if (item[1] == 2): imagebox = item[0] scribus.selectObject(imagebox) scribus.copyObject(imagebox) scribus.setActiveLayer(fantome) scribus.pasteObject(imagebox) scribus.deleteObject(imagebox) scribus.setActiveLayer(working) page += 1 scribus.setLayerPrintable(fantome, 0) # comment this out to do manually later scribus.setLayerVisible(fantome, 0) # comment this out to do manually later scribus.setRedraw(1) scribus.docChanged(1) scribus.messageBox("Finished", "That should do it!", icon=0, button1=1) else: scribus.messageBox('Usage Error', 'You need a Document open', icon=0, button1=1)
checkForOneFrameSelected() currentFrameName = scribus.getSelectedObject() print(currentFrameName) if (scribus.getObjectType(currentFrameName) == 4): scribus.messageBox('Scribus - Usage Error', "You did not select a textframe. Try again.", scribus.ICON_WARNING, scribus.BUTTON_OK) sys.exit(2) # the pattern is the name of the current frame up to the first digit # and with the "Copy of " at the beginning stripped away. matchNonDigit = re.compile(r'(^\D+)') matchResult = matchNonDigit.search(currentFrameName) pattern = matchResult.group(1) pattern = remove_copy_prefix(pattern) pattern = remove_copy_prefix(pattern) print("pattern: " + pattern) scribus.duplicateObject() duplicateFrameName = scribus.getSelectedObject() print(duplicateFrameName) fileMatchingTextFrame(duplicateFrameName, pattern) scribus.deleteObject(duplicateFrameName)
fantome = "Ghostlayer" scribus.createLayer(fantome) working = scribus.getActiveLayer() page = 1 pagenum = scribus.pageCount() while (page <= pagenum): scribus.gotoPage(page) scribus.setActiveLayer(working) # maybe not necessary? pageitems = scribus.getPageItems() for item in pageitems: if (item[1] == 2): imagebox = item[0] scribus.selectObject(imagebox) scribus.copyObject(imagebox) scribus.setActiveLayer(fantome) scribus.pasteObject(imagebox) scribus.deleteObject(imagebox) scribus.setActiveLayer(working) page += 1 scribus.setLayerPrintable(fantome, 0) # comment this out to do manually later scribus.setLayerVisible(fantome, 0) # comment this out to do manually later scribus.setRedraw(1) scribus.docChanged(1) scribus.messageBox("Finished", "That should do it!",icon=0,button1=1) else: scribus.messageBox('Usage Error', 'You need a Document open', icon=0, button1=1) sys.exit(2)
scribus.moveObjectAbs(position[0], position[1]) scribus.deleteObject(frameName) # TODO: rename the duplicate to the old frameName checkForOneFrameSelected() currentFrameName = scribus.getSelectedObject() print(currentFrameName) if (scribus.getObjectType(currentFrameName) == 4): scribus.messageBox('Scribus - Usage Error', "You did not select a textframe. Try again.", scribus.ICON_WARNING, scribus.BUTTON_OK) sys.exit(2) # the pattern is the name of the current frame up to the first digit # and with the "Copy of " at the beginning stripped away. matchNonDigit = re.compile(r'(^\D+)') matchResult = matchNonDigit.search(currentFrameName) pattern = matchResult.group(1) pattern = remove_copy_prefix(pattern) pattern = remove_copy_prefix(pattern) print("pattern: " + pattern) scribus.duplicateObject() duplicateFrameName = scribus.getSelectedObject() print(duplicateFrameName) fileMatchingTextFrame(duplicateFrameName, pattern) scribus.deleteObject(duplicateFrameName)
sys.exit(1) print(filename_png) filename_svg = os.path.splitext(filename_png)[0] + '.svg' print(filename_svg) scratchblocks_svg = os.path.join(download_path, 'scratchblocks.svg') print(scratchblocks_svg + ' >> ' + filename_svg) if os.path.isfile(scratchblocks_svg): os.rename(scratchblocks_svg, filename_svg) else: scribus.messageBox('Error:', 'Cannot find ' + filename_svg) # https://gitlab.com/inkscape/inbox/issues/405 # FitCanvasToDrawing cannot be run without a GUI call([ 'inkscape', '--verb=FitCanvasToDrawing', '--verb=FileSave', '--verb=FileQuit', filename_svg ]) call(['inkscape', '-z', '--export-dpi=300', filename_svg, '-e', filename_png]) if (scribus.getObjectType(item) == 'TextFrame'): (x, y) = scribus.getPosition() (w, h) = scribus.getSize() scribus.deleteObject() name = scribus.createImage(x, y, w, h) scribus.selectObject(name) scribus.loadImage(filename_png)