def get_new_image_name(self):
     count = 0
     while True:
         name = 'latex-image-%d' % count
         try:
             scribus.getImageFile(name)
         except scribus.NoValidObjectError:
             return name
         count += 1
    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 exportText(textfile):
    page = 1
    pagenum = scribus.pageCount()
    T = []
    content = []
    while (page <= pagenum):
        scribus.gotoPage(page)
        d = scribus.getPageItems()
        strpage = str(page)
        T.append('Page ' + strpage + '\n\n')
        for item in d:
            if (item[1] == 4):
                contents = scribus.getAllText(item[0])
                if (contents in content):
                    contents = 'Duplication, perhaps linked-to frame'
                T.append(item[0] + ': ' + contents + '\n\n')
                content.append(contents)
            elif (item[1] == 2):
                imgname = scribus.getImageFile(item[0])
                T.append(item[0] + ': ' + imgname + '\n')
        page += 1
        T.append('\n')
    output_file = open(textfile, 'w')
    output_file.writelines(T)
    output_file.close()
    endmessage = textfile + ' was created'
    scribus.messageBox("Finished", endmessage, scribus.ICON_NONE,
                       scribus.BUTTON_OK)
def main():
    # haben wir ein Dokument geoeffnet
    if scribus.haveDoc():
        # haben wir in diesem Dokument genau *ein* Objekt markiert
        if (scribus.selectionCount() == 1):
            # Ist dieses Objekt ein Bild, dann
            if (scribus.getObjectType() == "ImageFrame"):
                # lese den vollstaendigen Namen der datei (inkl. Pfad) in die Variable name
                name = scribus.getImageFile()
                # bastele einen neuen Namen aus dem Pfad, %VAR_ und dem Objektnamen und schreibe ihn als Standardwert in den Dialog
                newname = scribus.valueDialog(
                    os.path.split(name)[1] +
                    " wird ersetzt durch %VAR_[name]%",
                    "Variablenname ergänzen: ",
                    os.path.split(name)[0] + "/%VAR_" +
                    scribus.getSelectedObject() + "%")
                # uebernehme den Wert aus dem Dialogfenster (keine plausibilitaetspruefung. das ist ein beliebiger String
                scribus.loadImage(newname)
            else:
                scribus.messageBox("Fehler",
                                   "markierter Frame ist kein Bildrahmen",
                                   scribus.ICON_CRITICAL)
        else:
            scribus.messageBox("Fehler", "bitte *einen* Bildrahmen markieren",
                               scribus.ICON_CRITICAL)
    else:
        scribus.messageBox("Fehler", "kein Dokument geöffnet",
                           scribus.ICON_CRITICAL)
def exportText(textfile):
    page = 1
    pagenum = scribus.pageCount()
    T = []
    content = []
    while (page <= pagenum):
        scribus.gotoPage(page)
        d = scribus.getPageItems()
        strpage = str(page)
        T.append('Page '+ strpage + '\n\n')
        for item in d:
            if (item[1] == 4):
                contents = scribus.getAllText(item[0])
                if (contents in content):
                    contents = 'Duplication, perhaps linked-to frame'
                T.append(item[0]+': '+ contents + '\n\n')
                content.append(contents)
            elif (item[1] == 2):
                imgname = scribus.getImageFile(item[0])
                T.append(item[0]+': ' + imgname + '\n')
        page += 1
        T.append('\n')
    output_file = open(textfile,'w')
    output_file.writelines(T)
    output_file.close()
    endmessage = textfile + ' was created'
    scribus.messageBox("Finished", endmessage,icon=0,button1=1)
Exemple #6
0
def fill_image_placeholders(frame, fields, row):
    filename = scribus.getImageFile(frame)
    for field in fields:
        print(field)
        new_filename = filename[0:field['start']] + \
            row[field['key']] + \
            filename[field['end'] + 1:]
        scribus.loadImage(new_filename, frame)
Exemple #7
0
 def __init__(self, *args):
     """
     Optional argument "name" 
     """
     if len(args) > 0:
         self.name = args[0]
         self.path = sc.getImageFile(self.name)
         self.width, self.height = sc.getSize(self.name)
         self.offset_x, self.offset_y = sc.getImageOffset(self.name)
         self.scale_x, self.scale_y = sc.getImageScale(self.name)
Exemple #8
0
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  #
    #########################
    #copyPlayer("__player__","PLAYER 1")
    #copyPlayer("__player__","PLAYER 2")
    #copyPlayer("__player__","PLAYER 3")
    csv = scribus.fileDialog('Open input', 'CSV files (*.csv)')
    stuff = {
        'NAME': 'Mike Hingley',
        'ADDRESS': '22 Trinity Street, Cradley Heath, West Midlands',
        'PHOTO': '128.jpg'
    }
    print(os.path.dirname(os.path.realpath(sys.argv[0])))
    print os.getcwd()
    print(sys.path[0])
    print(os.path.abspath(''))
    sourceName = "__player__"
    if scribus.objectExists(sourceName):
        scribus.selectObject(sourceName)
        scribus.unGroupObject()
        childObjectCount = scribus.selectionCount()
        for x in range(0, childObjectCount):
            element = scribus.getSelectedObject(x)
            if scribus.getObjectType(str(element)) == 'TextFrame':
                current = scribus.getAllText(element)
                if current in stuff:
                    fontsize = scribus.getFontSize(element)
                    font = scribus.getFont(element)
                    scribus.setText(stuff[current], element)
                    scribus.setFont(font)
                    scribus.setFontSize(fontsize)
            if scribus.getObjectType(str(element)) == 'ImageFrame':
                current = scribus.getImageFile(element)
                currentName = os.path.basename(os.path.normpath(current))
                print current
                print currentName
                if currentName in stuff:
                    ExistingFolder = os.path.split(current)
                    print ExistingFolder[0]
                    newFile = os.path.join(ExistingFolder[0],
                                           stuff[currentName])
                    print newFile
                    scribus.loadImage(newFile, element)
            print scribus.getObjectType(str(element))
            print str(scribus.getSelectedObject(x))
        scribus.groupObjects()
        print "name = " + scribus.getSelectedObject()
        scribus.setNewName("__player__", scribus.getSelectedObject())
    def slotOkClicked(self):
        global CWD

        text = self.text.text()
        preamble = self.preamble.text()
        scale = self.scale.value()
        CWD = self.cwd.text()

        DPI = 600.0
        os.chdir(CWD)

        try:
            img = scribus.getSelectedObject()
            scribus.getImageFile(img)
        except scribus.NoValidObjectError:
            img = self.get_new_image_name()
            scribus.createImage(0, 0, 10, 10, img)

        img_file = os.path.abspath('%s.png' % img)
        self.generate_latex(text, preamble, scale, img_file, DPI*scale)

        info = open(img_file + '.info', 'w')
        info.write("%s\n" % preamble)
        info.write("%g\n" % scale)
        info.write(text)
        info.close()

        x = Image.open(img_file, 'r')
        w, h = x.size
        del x

        scribus.setUnit(scribus.UNIT_MILLIMETERS)
        scribus.loadImage(img_file, img)
        scribus.setScaleImageToFrame(True, True, img)
        x, y = scribus.getPosition(img)
        scribus.sizeObject(x + w*25.4/DPI, y + h*25.4/DPI, img)
        
        self.accept()
def listImages(filename):

    file_content = []
    for page in range(1, scribus.pageCount() + 1):
        scribus.gotoPage(page)
        file_content.append('Page ' + str(page) + '\n\n')
        for item in scribus.getPageItems():
            if item[1] == 2:
                file_content.append(scribus.getImageFile(item[0]) + '\n')

        file_content.append('\n')
    output_file = open(filename, 'w')
    output_file.writelines(file_content)
    output_file.close()
def cleanup_dead_images(self):
    os.chdir(CWD)
    files = glob.glob('latex-image-*.png')
    for filename in files:
        imgname = filename[:-4]
        try:
            img_file = scribus.getImageFile(imgname)
            continue
        except scribus.NoValidObjectError:
            pass
        
        if os.path.exists(filename):
            os.remove(filename)
        if os.path.exists(filename + '.info'):
            os.remove(filename + '.info')
def get_all_empty_images_frames():
    image_frames = []
    for page in range(1, scribus.pageCount() + 1):
        page_image_frames = []
        scribus.gotoPage(page)
        # get all empty image frames on the page
        for item in scribus.getPageItems():
            if item[1] == 2:
                if scribus.getImageFile(item[0]) == "":
                    x, y = scribus.getPosition(item[0])
                    page_image_frames.append((item[0], x, y))
        # sort the frames by position
        page_image_frames.sort(key=lambda k: [k[2], k[1]])
        image_frames += [i[0] for i in page_image_frames]
    return image_frames
Exemple #13
0
def main():
    if sc.selectionCount() == 2:
        images = ( sc.getSelectedObject(0), sc.getSelectedObject(1) )
        for image in images:
            if sc.getObjectType(image) != "ImageFrame":
                logging.debug(f"Image type {sc.getObjectType(image)}, but 'ImageFrame' expected")
                error_msg(f'{image} not an image frame. But type {sc.getObjectType(image)}')
        image_files = (sc.getImageFile(images[0]), sc.getImageFile(images[1]))
        # keep Scale and Offset, before reset by image load
        image_0_offset = sc.getImageOffset(images[0])
        image_0_scale  = sc.getImageScale(images[0])
        image_1_offset = sc.getImageOffset(images[1])
        image_1_scale  = sc.getImageScale(images[1])
        sc.loadImage(image_files[1], images[0]) 
        sc.loadImage(image_files[0], images[1]) 
        if sc.getSize(images[0]) == sc.getSize(images[1]):
            # Frames have the same size swap scale and offset
            logging.debug(f"Frames have the same size {sc.getSize(images[0])}, swap offset and scale")
            logging.debug(f"Image 0: {images[0]}, Image 1: {images[1]}")
            logging.debug(f"Image properties: offset {sc.getImageOffset(images[0])}, scale {image_0_scale}")

            sc.setImageOffset(*image_1_offset, images[0])
            sc.setImageScale(*image_1_scale, images[0])
            sc.setImageOffset(*image_0_offset, images[1])
            sc.setImageScale(*image_0_scale, images[1])
        else:
            # scale and center
            logging.debug("Different size scale and center, both.")
            for name in images:
                x, y = sff.scale_to_frame(name)
                sff.center_image(name, x, y)


    else:
        logging.debug(f"{sc.selectionCount()} frames selected.")
        error_msg(f'{sc.selectionCount()} frames selected')
Exemple #14
0
def drawPlaceholders():
    page = scribus.getPageSize()
    margin = scribus.getPageMargins()

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

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

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

    # add a "crossed frame" for missing images
    for item in scribus.getAllObjects():
        if scribus.getObjectType(item) == 'ImageFrame':
            image = scribus.getImageFile(item)
            if image == '':
                pos = scribus.getPosition(item)
                size = scribus.getSize(item)
                rectangle = scribus.createRect(pos[0], pos[1], size[0],
                                               size[1])
                scribus.setFillColor('none', rectangle)
                scribus.setLineColor('Black', rectangle)
                scribus.setLineWidth(0.4, rectangle)
                line = scribus.createLine(pos[0], pos[1], pos[0] + size[0],
                                          pos[1] + size[1])
                scribus.setLineColor('Black', line)
                scribus.setLineWidth(0.4, line)
                line = scribus.createLine(pos[0], pos[1] + size[1],
                                          pos[0] + size[0], pos[1])
                scribus.setLineColor('Black', line)
                scribus.setLineWidth(0.4, line)
    def fetch_info(self):
        try:
            name = scribus.getImageFile()
            info_name = '%s.info' % name

            if os.path.exists(info_name):
                f = open(info_name, 'r')
                try:
                    preamble = f.readline().strip()
                    scale = float(f.readline().strip())
                    text = f.read()

                    self.text.setText(text)
                    self.scale.setValue(scale)
                    self.preamble.setText(preamble)
                finally:
                    f.close()
        except scribus.NoValidObjectError:
            return
def exportText(filename):
    file_content = []
    content = []
    for page in range(1, scribus.pageCount() + 1):
        scribus.gotoPage(page)
        file_content.append('Page ' + str(page) + '\n\n')
        for item in scribus.getPageItems():
            if item[1] == 4:
                contents = scribus.getAllText(item[0])
                if contents in content:
                    contents = 'Duplication, perhaps linked-to frame'
                file_content.append(item[0] + ': ' + contents + '\n\n')
                content.append(contents)
            elif item[1] == 2:
                imgname = scribus.getImageFile(item[0])
                file_content.append(item[0] + ': ' + imgname + '\n')
        file_content.append('\n')
    output_file = open(filename, 'w')
    output_file.writelines(file_content)
    output_file.close()
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)
import scribus
import os.path

page_n = scribus.pageCount()
item_missing = []

# create a list of items with a brokein link
for page_i in range(0, page_n) :
    scribus.gotoPage(page_i + 1)
    item_list = scribus.getPageItems()
    #print(item_list)
    for item in item_list :
        if item[1] == 2 :
            image_filepath = ""
            image_filepath = scribus.getImageFile(item[0])
            print(image_filepath)
            if image_filepath != "" and not os.path.isfile(image_filepath) :
                item_missing.append((item[0], image_filepath))
# print(item_missing)

# read the link for the first image with a broken link and try to apply the path
# to each other image with a broken link
if item_missing :
    if scribus.messageBox("Missing images", "There are missing images. Do you want to look for them?", scribus.ICON_WARNING, scribus.BUTTON_YES, scribus.BUTTON_NO) == scribus.BUTTON_YES:
        filename_found = scribus.fileDialog("Find "+os.path.basename(item_missing[0][1]), "Image files (*."+os.path.splitext(item_missing[0][1])[1][1:]+")")
        # print(filename_found)

        if filename_found:
            path_found = os.path.dirname(filename_found)
            # print("path_found "+path_found)
## contribution from jvr14115, https://github.com/berteh/ScribusGenerator/issues/116
## run from within Scribus > Script > run Script

import os
import re
import scribus

Edoc = scribus.getDocName()
Edoc = Edoc.replace('.sla', '')
file_name = Edoc + 'Elements.csv'
Edoc = Edoc.replace('Elements.csv', '')
Edoc = re.search(r'(.*)/(.*)', Edoc).group(2)
f = open(file_name, 'w+')
f.write('Template,Element,ElementType')
f.write('\n')
objL = scribus.getAllObjects()
for obj in objL:
    objT = scribus.getObjectType(obj)
    Evar = ''
    if objT == 'ImageFrame':
        Etype = 'image'
        Evar = scribus.getImageFile(obj)
    if objT == 'TextFrame':
        Etype = 'text'
        Evar = scribus.getAllText(obj)
    if '%VAR_' in Evar:
        Evar = re.sub('^[^%VAR_]*%VAR_', '', Evar)
        Evar = Evar[:-1]
        f.write(Edoc + ';"' + Evar + '";' + Etype + '\n')
f.close
Exemple #20
0
def get_image_placeholders(frame):
    filename = scribus.getImageFile(frame)
    return get_placeholders_from_string(filename)
Exemple #21
0
import scribus
import os.path

page_n = scribus.pageCount()
item_missing = []

# create a list of items with a brokein link
for page_i in range(0, page_n):
    scribus.gotoPage(page_i + 1)
    item_list = scribus.getPageItems()
    #print(item_list)
    for item in item_list:
        if item[1] == 2:
            image_filepath = ""
            image_filepath = scribus.getImageFile(item[0])
            print(image_filepath)
            if image_filepath != "" and not os.path.isfile(image_filepath):
                item_missing.append((item[0], image_filepath))
# print(item_missing)

# read the link for the first image with a broken link and try to apply the path
# to each other image with a broken link
if item_missing:
    if scribus.messageBox(
            "Missing images",
            "There are missing images. Do you want to look for them?",
            scribus.ICON_WARNING, scribus.BUTTON_YES,
            scribus.BUTTON_NO) == scribus.BUTTON_YES:
        filename_found = scribus.fileDialog(
            "Find " + os.path.basename(item_missing[0][1]), "Image files (*." +
if not scribus.haveDoc():
    scribus.messageBox('Usage Error',
                       'You need a Document open',
                       icon=0,
                       button1=1)
    sys.exit(2)

# TODO: ask for the range of pages (current page if empty)

unit = scribus.getUnit()
scribus.setUnit(unit)
scribus.setUnit(scribus.UNIT_MILLIMETERS)

item = scribus.getSelectedObject()

path = scribus.getImageFile(item)
if path == '':
    scribus.messageBox('Usage Error',
                       'You need to first load an image',
                       icon=0,
                       button1=1)
    sys.exit(2)

scribus.setScaleImageToFrame(True, False, item)
scribus.setScaleImageToFrame(False, False, item)
scale = scribus.getImageScale(item)
max_scale = max(scale)
scribus.setImageScale(max_scale, max_scale, item)

scribus.setUnit(unit)
Exemple #23
0
def is_imageframe_empty(name):
    file = sc.getImageFile(name)
    if len(file) > 0:
        return False
    return True
    for i in range(n):
        scribus.selectText(i, 1)
        original = scribus.getText()
        if original not in charsIgnore and len(original) > 0:
            shuffled = chars.pop(0)
            if original.isupper():
                shuffled = shuffled.upper()
            scribus.insertText(shuffled, i)
            scribus.selectText(i + 1, 1)
            scribus.deleteText()

for item in imageFrame:
    print item
    scribus.messagebarText("Processing image frame " + item)
    scribus.redrawAll()
    imageFile = scribus.getImageFile(item)
    fileName, fileExtension = os.path.splitext(imageFile)
    imageFileBlurred = fileName + "_blurred" + fileExtension
    # TODO: instead of using image magick we should expos scribus' own blur to the scripter
    if distutils.spawn.find_executable("convert") != "":
        command = "identify " + imageFile
        result = os.popen(command).read()
        if result != "":
            size = max(
                result.split(" ")[2].split("x"))  # extract max(width, height)
            command = "convert " + imageFile + " -blur 0x" + str(
                int(size) / 50) + " " + imageFileBlurred
            # print  command
            os.system(command)
            scribus.loadImage(imageFileBlurred, item)
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[1])
    scribus.setLineColor('Black', line)
    scribus.setLineWidth(0.6, line)
    scribus.setLineStyle(scribus.LINE_DASHDOT, line)

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

scribus.setActiveLayer(layer)
Exemple #26
0
    sys.exit(1)

item = scribus.getSelectedObject(0)

path_images = None
filename_png = None
path_png = None
path_svg = None

if (scribus.getObjectType(item) == 'TextFrame'):
    path = scribus.getAllText()
    if path != '':
        base_path = os.path.dirname(scribus.getDocName())
        filename_png = os.path.join(base_path, path)
elif (scribus.getObjectType(item) == 'ImageFrame'):
    filename_png = scribus.getImageFile()

if path_png == '':
    filename_png = None

if filename_png == None:
    scribus.messageBox(
        'Error:',
        'You need to select a text frame containing the path to the image or an image frame with an old version of the image'
    )
    sys.exit(1)

print(filename_png)

filename_svg = os.path.splitext(filename_png)[0] + '.svg'