예제 #1
0
def newWikiTextBlock(cont, x, y, w):
    h = 0
    #title
    title = scribus.createText(x, y, w, 1)
    scribus.setText(cont["wp"].title, title)
    scribus.setTextAlignment(scribus.ALIGN_LEFT, title)
    scribus.setFont("Open Sans Bold", title)
    scribus.setFontSize(14, title)
    scribus.setLineSpacing(14, title)

    tw, th = scribus.getSize(title)
    while scribus.textOverflows(title):
        scribus.sizeObject(tw, th + 1, title)
        tw, th = scribus.getSize(title)

    h = th

    #content
    content = scribus.createText(x, y + h + 1, w, 1)
    scribus.setText(cont["summary"], content)
    scribus.setTextAlignment(scribus.ALIGN_LEFT, content)
    scribus.setFont("Open Sans Regular", content)
    scribus.setFontSize(10, content)

    tw, th = scribus.getSize(content)
    while scribus.textOverflows(content):
        scribus.sizeObject(tw, th + 1, content)
        tw, th = scribus.getSize(content)
        if h + th > bH:
            break

    h = h + th

    return h
    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)
예제 #3
0
def importData(filename, idxPro):
    (nbLogo, nbImg, nbChange, nbPro, nbCol, nbCat) =(0,0,0,0,0,0)

    global filParam
    strDir = os.path.dirname(filename)
    if os.path.isfile(filParam):
            nbCol=importParametres(filParam, idxPro)

    if idxPro==1: 
        if os.path.isfile(strDir+LOGO) and scribus.objectExists("imgLogo"): #Logo de la première page lorsque le document est entièrement plié en huit
            scribus.loadImage(strDir+LOGO, "imgLogo")
            nbLogo+=1

        if os.path.isfile(strDir+LOGO) and scribus.objectExists("imgSmallLogo"): #Petit logo de la dernière page lorsque le document est entièrement plié en huit
            scribus.loadImage(strDir+SMALL_LOGO, "imgSmallLogo")
            nbLogo+=1

        if os.path.isfile(strDir+QRCODE) and scribus.objectExists("imgQrcode"): #QR code de la dernière page
            scribus.loadImage(strDir+QRCODE, "imgQrcode")
            nbImg=1

        for img in range(1,5):
            if os.path.isfile(strDir+("/image%d.png"%img)): #images facultatives
                scribus.loadImage(strDir+("/image%d.png"%img), "img%d"%img)
                nbImg+=1
                
            
    datJ=datetime.date.today() # Date de l'importation comme date de l'annuaire
    scribus.setText(datJ.strftime("%B %Y"), "txtDate")
    scribus.setStyle("styleDate","txtDate")
    if os.path.isfile(filename):  #Sociétés de l'annuaire et les noms des catégories
        (nbChange, nbPro, nbCat)=importSocietes(filename, strDir+CATEGORIE, idxPro)

    return (nbLogo, nbImg, nbCol, nbChange, nbPro, nbCat)
예제 #4
0
def getColorsFromCsv(filename, idxPro):
    csvreader=csv.reader(file(filename))
    csvcolors=[]
    for row in csvreader:
        if len(row)>1 and idxPro==1:
          name=row[0].strip()
          if len(row)>4 and name[0:7]=='couleur': 
            c=int(row[1] )* 2.55
            c=int(c)
            m=int(row[2] )* 2.55
            m=int(m)
            y=int(row[3] )* 2.55
            y=int(y)
            k=int(row[4] )* 2.55
            k=int(k)        
            if checkValue(c, m, y, k) ==False:
                scribus.messageBox("importerPros", "At least one CMYK value in your csv file is not correct \n(must be between 0 and 100)\nAborting script - nothing imported.",  icon=scribus.ICON_WARNING)
                sys.exit()

            color=(name, c, m, y, k)
            csvcolors.append(color)
          elif name[0:3]=='txt':
            if scribus.objectExists(name):
                scribus.setText(row[1].replace("\\n","\n"), name)
                nbContent=scribus.getTextLength(name)
                scribus.selectText(0, nbContent, name)
                scribus.setStyle("style"+name[3:], name)
            else:
                scribus.messageBox("Objet non trouvé","Aucun objet correspondant au paramètre %s n'a été trouvé dans le document vierge"%name)

        readGlobalParameter(row)

    return csvcolors
예제 #5
0
    def addWatermark(self):
        '''Create a Draft watermark layer. This was taken from:
			http://wiki.scribus.net/canvas/Adding_%27DRAFT%27_to_a_document'''

        L = len(self.watermark)  # The length of the word
        # will determine the font size
        scribus.defineColor("gray", 11, 11, 11, 11)  # Set your own color here

        u = scribus.getUnit()  # Get the units of the document
        al = scribus.getActiveLayer()  # Identify the working layer
        scribus.setUnit(
            scribus.UNIT_MILLIMETERS)  # Set the document units to mm,
        (w, h) = scribus.getPageSize()  # needed to set the text box size

        scribus.createLayer("c")
        scribus.setActiveLayer("c")

        T = scribus.createText(w / 6, 6 * h / 10, h,
                               w / 2)  # Create the text box
        scribus.setText(self.watermark, T)  # Insert the text
        scribus.setTextColor("gray", T)  # Set the color of the text
        scribus.setFontSize(
            (w / 210) * (180 - 10 * L),
            T)  # Set the font size according to length and width

        scribus.rotateObject(45, T)  # Turn it round antclockwise 45 degrees
        scribus.setUnit(u)  # return to original document units
        # FIXME: It would be nice if we could move the watermark box down to the lowest layer so
        # that it is under all the page text. Have not found a method to do this. For now we just
        # plop the watermark on top of everything else.
        scribus.setActiveLayer(al)  # return to the original active layer
예제 #6
0
    def addWatermark (self) :
        '''Create a Draft watermark layer. This was taken from:
            http://wiki.scribus.net/canvas/Adding_%27DRAFT%27_to_a_document'''

        L = len(self.watermark)                         # The length of the word 
                                                        # will determine the font size
        scribus.defineColor("gray", 11, 11, 11, 11)     # Set your own color here

        u  = scribus.getUnit()                          # Get the units of the document
        al = scribus.getActiveLayer()                   # Identify the working layer
        scribus.setUnit(scribus.UNIT_MILLIMETERS)       # Set the document units to mm,
        (w,h) = scribus.getPageSize()                   # needed to set the text box size

        scribus.createLayer("c")
        scribus.setActiveLayer("c")

        T = scribus.createText(w/6, 6*h/10 , h, w/2)    # Create the text box
        scribus.setText(self.watermark, T)              # Insert the text
        scribus.setTextColor("gray", T)                 # Set the color of the text
        scribus.setFontSize((w/210)*(180 - 10*L), T)    # Set the font size according to length and width

        scribus.rotateObject(45, T)                     # Turn it round antclockwise 45 degrees
        scribus.setUnit(u)                              # return to original document units
# FIXME: It would be nice if we could move the watermark box down to the lowest layer so 
# that it is under all the page text. Have not found a method to do this. For now we just
# plop the watermark on top of everything else.
        scribus.setActiveLayer(al)                      # return to the original active layer
예제 #7
0
def newWikiTextBlock(cont,x,y,w):
  h = 0
  #title
  title = scribus.createText(x, y, w, 1)
  scribus.setText(cont["wp"].title, title)
  scribus.setTextAlignment(scribus.ALIGN_LEFT, title)
  scribus.setFont("Open Sans Bold", title)
  scribus.setFontSize(14, title)
  scribus.setLineSpacing(14, title)

  tw,th = scribus.getSize(title)
  while scribus.textOverflows(title):
    scribus.sizeObject(tw, th+1, title)
    tw,th = scribus.getSize(title)

  h = th

  #content
  content = scribus.createText(x, y+h+1, w, 1)
  scribus.setText(cont["summary"], content)
  scribus.setTextAlignment(scribus.ALIGN_LEFT, content)
  scribus.setFont("Open Sans Regular", content)
  scribus.setFontSize(10, content)

  tw,th = scribus.getSize(content)
  while scribus.textOverflows(content):
    scribus.sizeObject(tw, th+1, content)
    tw,th = scribus.getSize(content)
    if h+th > bH:
      break

  h = h+th

  return h
예제 #8
0
파일: hd.py 프로젝트: fleshgordo/HDbuch
def textframes(text_id, x, y, width, height, bg_colour, text_colour, fontsize, font, spacing, parsedtext, layer, linespacing=0, resize=0):
	scribus.createText(x, y, width, height, text_id)
#scribus.text_id = scribus.createText(120, 10, 200, 20)
	scribus.setText(parsedtext, text_id)
	scribus.setFont(font, text_id)
	scribus.setTextColor(text_colour, text_id)
	scribus.setTextDistances(3*spacing, spacing, 0, spacing, text_id)
	scribus.sentToLayer(layer, text_id)
	scribus.setFontSize(fontsize, text_id)
예제 #9
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())
예제 #10
0
def drawNameTag(xOff, yOff, participant):
    firstNamePos = {"x": xOff+5.0, "y": yOff+12.5}
    lastNamePos = {"x": xOff+5.0, "y": yOff+20.5}

    drawNameTagBox(xOff, yOff)

    firstName = scribus.createText(firstNamePos["x"], firstNamePos["y"], 70, 9)
    scribus.setText(participant["Vorname"], firstName)
    scribus.setStyle(STYLE_FIRST_NAME, firstName)

    lastName = scribus.createText(lastNamePos["x"], lastNamePos["y"], 70, 9)
    scribus.setText(participant["Nachname"], lastName)
    scribus.setStyle(STYLE_LAST_NAME, lastName)
예제 #11
0
    def setPageNumber (self, crds, pageSide, row, pageNumber) :
        '''Place the page number on the page if called for.'''

        if self.pageNumbers :
            # Make the page number box
            pNumBox = scribus.createText(crds[row]['pageNumXPos' + pageSide], crds[row]['pageNumYPos'], crds[row]['pageNumWidth'], crds[row]['pageNumHeight'])
            # Put the page number in it and format according to the page we are on
            scribus.setText(`pageNumber`, pNumBox)
            if pageSide == 'Odd' :
                scribus.setTextAlignment(scribus.ALIGN_RIGHT, pNumBox)
            else:
                scribus.setTextAlignment(scribus.ALIGN_LEFT, pNumBox)

            scribus.setFont(self.fonts['pageNum']['bold'], pNumBox)
            scribus.setFontSize(self.fonts['pageNum']['size'], pNumBox)
예제 #12
0
def trovasostituisci(text_to_find,text_to_replace):
#itero tutti gli oggetti presenti in Scribus
  for obj in scribus.getAllObjects():
    #ottengo il tipo di oggetto di tutti gli elementi della pagina
    obj_type = scribus.getObjectType(obj)
    #controllo che il tipo di oggetto scribus sia TextFrame
    if obj_type == "TextFrame":
        #ottengo il testo contenuto in tutti gli oggetti
        obj_text = scribus.getText(obj)
        #text_to_find = "_F6%"
        #text_to_replace = "123 TESTO SOSTITUITO 123456789"
        #cerco la variabile text_to_find
        if text_to_find in obj_text:
          #se la trovo la sostituisco
          text_to_find = obj_text.replace(text_to_find, text_to_replace)
          scribus.setText(text_to_find, obj)
          scribus.setFontSize(8, obj)
예제 #13
0
def fill_page(contacts):
    #where contacts is an array or at most max_contact contacts
    assert(len(contacts) < MAX_PAGE_CONTACTS)
    
    nb_lines = (len(contacts) / (CONST_COL_NUMBER))  
    if((len(contacts) % CONST_COL_NUMBER) != 0):
        nb_lines = nb_lines+1
    for curline in range (0, nb_lines):
        nb_col = min(len(contacts) - (curline * CONST_COL_NUMBER), CONST_COL_NUMBER) 
        for curcol in range (0, nb_col):
            x = CONST_TOP_MARGIN + CONST_COL_SIZE * curline
            y = CONST_LEFT_MARGIN + CONST_LINE_SIZE * curcol
            txtFrameName= "etiketo"+str(curline)+str(curcol)
            scribus.createText(y, x, CONST_LINE_SIZE, CONST_COL_SIZE, txtFrameName)
            contact_idx=curline*CONST_COL_NUMBER+curcol
            scribus.setText(contacts[contact_idx].print_contact(), txtFrameName)
            scribus.setTextDistances(6, 0, 3, 0, txtFrameName) 
            scribus.setFontSize(10, txtFrameName)
            scribus.setFont("Liberation Serif Regular", txtFrameName)
def insert_text_frame():
    page_size = scribus.getPageSize()

    page_margins_right = scribus.getPageMargins()
    page_margins_left = (page_margins_right[0], page_margins_right[2], page_margins_right[1], page_margins_right[3])

    if (scribus.currentPage() % 2) == 1:
        page_margins = page_margins_right
    else:
        page_margins = page_margins_left

    name = 'test%d' % random.randint(100, 999)

    # x, y, width, height
    scribus.createText(page_margins[0],
                       page_margins[1],
                       page_size[0] - (page_margins[0] + page_margins[2]),
                       page_size[1] - (page_margins[1] + page_margins[3]),
                       name)
    scribus.setText("test", name)
예제 #15
0
def drawNameTagBox(xOff, yOff):
    logoPos = {"x": xOff+75.0-LOGO_WIDTH, "y": yOff+10.5}
    metaEventPos = {"x": xOff+5.0, "y": yOff+39.795}
    metaLocationPos = {"x": xOff+5.0, "y": yOff+43.6}

    #swkLogo = scribus.createImage(xOff+5.0, yOff+5.0, 70, 40)
    #scribus.loadImage("softwerkskammer.png", swkLogo)
    #scribus.setScaleImageToFrame(scaletoframe=1, proportional=1, name=swkLogo)
    #scribus.setProperty(swkLogo, "fillTransparency", 0.9)

    metaEvent = scribus.createText(metaEventPos["x"], metaEventPos["y"], 70, 9)
    scribus.setText(EVENT_NAME, metaEvent)
    scribus.setStyle(STYLE_META, metaEvent)

    metaLocation = scribus.createText(metaLocationPos["x"], metaLocationPos["y"], 70, 9)
    scribus.setText(EVENT_LOCATION, metaLocation)
    scribus.setStyle(STYLE_META, metaLocation)

    metaLogo = scribus.createImage(logoPos["x"], logoPos["y"], LOGO_WIDTH, LOGO_HEIGHT)
    scribus.loadImage("logo.png", metaLogo)
    scribus.setScaleImageToFrame(scaletoframe=1, proportional=1, name=metaLogo)
예제 #16
0
def fill_page(contacts):
    #where contacts is an array or at most max_contact contacts
    assert (len(contacts) < MAX_PAGE_CONTACTS)

    nb_lines = (len(contacts) / (CONST_COL_NUMBER))
    if ((len(contacts) % CONST_COL_NUMBER) != 0):
        nb_lines = nb_lines + 1
    for curline in range(0, nb_lines):
        nb_col = min(
            len(contacts) - (curline * CONST_COL_NUMBER), CONST_COL_NUMBER)
        for curcol in range(0, nb_col):
            x = CONST_TOP_MARGIN + CONST_COL_SIZE * curline
            y = CONST_LEFT_MARGIN + CONST_LINE_SIZE * curcol
            txtFrameName = "etiketo" + str(curline) + str(curcol)
            scribus.createText(y, x, CONST_LINE_SIZE, CONST_COL_SIZE,
                               txtFrameName)
            contact_idx = curline * CONST_COL_NUMBER + curcol
            scribus.setText(contacts[contact_idx].print_contact(),
                            txtFrameName)
            scribus.setTextDistances(6, 0, 3, 0, txtFrameName)
            scribus.setFontSize(10, txtFrameName)
            scribus.setFont("Liberation Serif Regular", txtFrameName)
예제 #17
0
	scribus.createLayer("randomcircles")
	scribus.createLayer("textlayer")


distros.keys().sort()

for distro in sorted(distros.iterkeys()):
	# extract the dictionary content
	description = distros[distro][0]
	filesizeiso = distros[distro][1]
	md5sum = distros[distro][2]
	modified = distros[distro][3]

	# create page title/header
	B = scribus.createText(left_page_x, 10, 100, 10)
	scribus.setText(distro, B)
	scribus.setFont("Gentium Plus Compact Regular", B)
	scribus.setTextAlignment(scribus.ALIGN_LEFT, B)
	scribus.setFontSize(18, B)
	
	# load small-logo into page
	imagedir = "./logos/"
	f = scribus.createImage(left_page_x, 23, 65, 65)
	scribus.loadImage(imagedir + distro + ".png", f)
	scribus.setScaleImageToFrame(1,1,f)
	scribus.sentToLayer("textlayer", f)

	# get description text for each distro
	scribus.createText(left_page_x, 92, 120, 80,distro)
	scribus.setText(description, distro)
	scribus.setLineSpacing(12,distro)
예제 #18
0
    def main (self) :

        # Load up all the file and record information.
        # Use CSV reader to build list of record dicts
        records         = self.loadCSVData(self.dataFile)
        totalRecs       = len(records)

        # Reality check first to see if we have anything to process
        if totalRecs <= 0 :
            scribus.messageBox('Not Found', 'No records found to process!')
            sys.exit()

        pageNumber      = 1
        recCount        = 0
        row             = 0
        pageSide        = 'Odd'
        scribus.progressTotal(totalRecs)
        paIndex         = {}
        lastName        = ''
        firstName       = ''
        photoFirstName  = ''
        verseRef        = ''
        verseText       = ''

        # Get the page layout coordinates for this publication
        crds = self.getCoordinates(self.dimensions)

        # Make a new document to put our records on
        if scribus.newDocument(getattr(scribus, self.dimensions['page']['scribusPageCode']), 
                    (self.dimensions['margins']['left'], self.dimensions['margins']['right'], self.dimensions['margins']['top'], self.dimensions['margins']['bottom']),
                        scribus.PORTRAIT, 1, scribus.UNIT_POINTS, scribus.NOFACINGPAGES, 
                            scribus.FIRSTPAGERIGHT, 1) :

            self.setPageNumber(crds, pageSide, row, pageNumber)

            while recCount < totalRecs :

                # Output a new page on the first row after we have done the first page
                if row == 0 and recCount != 0:
                    scribus.newPage(-1)
                    if pageSide == 'Odd' :
                        pageSide = 'Even'
                    else :
                        pageSide = 'Odd'

                    self.setPageNumber(crds, pageSide, row, pageNumber)

                ########### Now set the current record in the current row ##########

                # Set the last name
                lastName = records[recCount]['NameLast']

                # Adjust the NameFirst field to include the spouse if there is one
                if records[recCount]['Spouse'] != '' :
                    firstName = records[recCount]['NameFirst'] + ' & ' + records[recCount]['Spouse']
                else :
                    firstName = records[recCount]['NameFirst']
                    
                # Make the photo file name
                photoFirstName = firstName.replace('&', '-').replace('.', '').replace(' ', '')

                # Set our record count for progress display and send a status message
                scribus.progressSet(recCount)
                scribus.statusMessage('Placing record ' + `recCount` + ' of ' + `totalRecs`)

                # Add a watermark if a string is specified
                if self.outputWatermark :
                    self.addWatermark()

                # Put the last name element in this row
                nameLastBox = scribus.createText(crds[row]['nameLastXPos'], crds[row]['nameLastYPos'], crds[row]['nameLastWidth'], crds[row]['nameLastHeight'])
                scribus.setText(lastName, nameLastBox)
                scribus.setTextAlignment(scribus.ALIGN_RIGHT, nameLastBox)
                scribus.setTextDistances(0, 0, 0, 0, nameLastBox)
                scribus.setFont(self.fonts['nameLast']['bold'], nameLastBox)
                scribus.setFontSize(self.fonts['nameLast']['size'], nameLastBox)
                scribus.setTextShade(80, nameLastBox)
                scribus.rotateObject(90, nameLastBox)

                # Place the first name element in this row
                nameFirstBox = scribus.createText(crds[row]['nameFirstXPos'], crds[row]['nameFirstYPos'], crds[row]['nameFirstWidth'], crds[row]['nameFirstHeight'])
                scribus.setText(records[recCount]['Caption'], nameFirstBox)
                scribus.setTextAlignment(scribus.ALIGN_LEFT, nameFirstBox)
                scribus.setFont(self.fonts['nameFirst']['boldItalic'], nameFirstBox)
                scribus.setFontSize(self.fonts['nameFirst']['size'], nameFirstBox)

                # Place the image element in this row
                # We will need to do some processing on the first pass
                # The default output format is JPG
                orgImgFileName = records[recCount]['Photo']
                orgImgFile = os.path.join(self.orgImgDir, orgImgFileName)
                baseImgFileName = lastName + '_' + photoFirstName
                if self.willBePngImg :
                    ext = 'png'
                else :
                    ext = 'jpg'
                if not self.rgbColor :
                    imgFile = os.path.join(getattr(self, ext + 'ImgDir'), baseImgFileName + '-gray' + '.' + ext)
                else :
                    imgFile = os.path.join(getattr(self, ext + 'ImgDir'), baseImgFileName + '.' + ext)

                # Process the image now if there is none
                if not os.path.exists(imgFile) :
                    self.img_process.sizePic(orgImgFile, imgFile, self.maxHeight)
#                    self.img_process.outlinePic(imgFile, imgFile)
                    self.img_process.scalePic(imgFile, imgFile, self.imgDensity)
                    self.img_process.addPoloroidBorder(imgFile, imgFile)
                    # Color RGB is the default
                    if not self.rgbColor :
                        self.img_process.makeGray(imgFile, imgFile)

                # Double check the output and substitute with placeholder pic
                if not os.path.exists(imgFile) :
                    imgFile = self.placeholderPic
                # Create the imageBox and load the picture
                imageBox = scribus.createImage(crds[row]['imageXPos'], crds[row]['imageYPos'], crds[row]['imageWidth'], crds[row]['imageHeight'])
                if os.path.isfile(imgFile) :
                    scribus.loadImage(imgFile, imageBox)
                scribus.setScaleImageToFrame(scaletoframe=1, proportional=1, name=imageBox)

                # Place the country element in this row (add second one if present)
                countryBox = scribus.createText(crds[row]['countryXPos'], crds[row]['countryYPos'], crds[row]['countryWidth'], crds[row]['countryHeight'])
                countryLine = records[recCount]['Country1']
                try :
                    if records[recCount]['Country2'] != '' :
                        countryLine = countryLine + ' & ' + records[recCount]['Country2']
                except :
                    pass
                scribus.setText(countryLine, countryBox)
                scribus.setTextAlignment(scribus.ALIGN_RIGHT, countryBox)
                scribus.setFont(self.fonts['text']['boldItalic'], countryBox)
                scribus.setFontSize(self.fonts['text']['size'], countryBox)

                # Place the assignment element in this row
                assignBox = scribus.createText(crds[row]['assignXPos'], crds[row]['assignYPos'], crds[row]['assignWidth'], crds[row]['assignHeight'])
                scribus.setText(self.fixText(records[recCount]['Assignment']), assignBox)
                # Assign style to box
#                scribus.createParagraphStyle(name='assignStyle', alignment=0, leftmargin=10, firstindent=-10)
#                scribus.setStyle('assignStyle', assignBox)
                # Hard formated box
                scribus.setTextAlignment(scribus.ALIGN_LEFT, assignBox)
                scribus.setFont(self.fonts['text']['italic'], assignBox)
                scribus.setFontSize(self.fonts['text']['size'], assignBox)
                scribus.setLineSpacing(self.fonts['text']['size'] + 1, assignBox)
                scribus.setTextDistances(4, 0, 0, 0, assignBox)
                # Resize the frame height and determine the difference for
                # placing the next frame below it
                assignHeightNew = self.resizeFrame(assignBox)
                assignHeightDiff = crds[row]['assignHeight'] - assignHeightNew

                # Place the verse element in this row
                verseYPosNew = crds[row]['verseYPos'] - assignHeightDiff
                verseBox = scribus.createText(crds[row]['verseXPos'], verseYPosNew, crds[row]['verseWidth'], crds[row]['verseHeight'])
                # The verse element may be either a Scripture verse or a prayer request
                # If it is Scripture, and it has a verse ref, we want to set that
                # seperatly so we need to do a little preprocess on the text to find
                # out if it has a ref. This script will only recognize references
                # at the end of the string that are enclosed in brackets. See the
                # findVerseRef() function for more details
                verseRef = self.findVerseRef(records[recCount]['Prayer'])
                if verseRef :
                    verseText = self.removeVerseRef(self.fixText(records[recCount]['Prayer']))
                    scribus.setText(verseText, verseBox)
                else :
                    scribus.setText(self.fixText(records[recCount]['Prayer']), verseBox)
                # Can't find a way to set alignment to justified using setTextAlignment()
#                scribus.setTextAlignment(scribus.ALIGN_LEFT, verseBox)
                # Because of this, we make a style which seems to work
                scribus.createParagraphStyle(name='vBoxStyle', alignment=3)
                scribus.setStyle('vBoxStyle', verseBox)
                scribus.setFont(self.fonts['verse']['regular'], verseBox)
                scribus.setFontSize(self.fonts['verse']['size'], verseBox)
                scribus.setLineSpacing(self.fonts['verse']['size'] + 1, verseBox)
                scribus.setTextDistances(4, 0, 4, 0, verseBox)
                if self.hyphenate :
                    scribus.hyphenateText(verseBox)
                # Get the height difference in case we need to set ref box
                verseHeightNew = self.resizeFrame(verseBox)
                verseHeightDiff = crds[row]['verseHeight'] - verseHeightNew
                if verseRef :
                    # Set coordinates for this box
                    vRefBoxX = crds[row]['verseXPos']
                    vRefBoxY = (verseYPosNew + verseHeightNew)
                    vRefBoxH = crds[row]['nameFirstHeight'] / 2
                    vRefBoxW = crds[row]['verseWidth']
                    verseRefBox = scribus.createText(vRefBoxX, vRefBoxY, vRefBoxW, vRefBoxH)
                    scribus.setText(verseRef, verseRefBox)
                    scribus.setTextAlignment(scribus.ALIGN_RIGHT, verseRefBox)
                    scribus.setFont(self.fonts['verse']['italic'], verseRefBox)
                    scribus.setFontSize(self.fonts['verse']['size'] - 2, verseRefBox)
                    scribus.setLineSpacing(self.fonts['verse']['size'], verseRefBox)
                    scribus.setTextDistances(2, 0, 0, 0, verseRefBox)

                # Up our counts
                if row >= self.dimensions['rows']['count'] - 1 :
                    row = 0
                    pageNumber +=1
                else :
                    row +=1
                    
                recCount +=1

            # Create the index page here
            # Output a new page for the index
            if row == 0 and recCount != 0:
                scribus.newPage(-1)
                if pageSide == 'Odd' :
                    pageSide = 'Even'
                else :
                    pageSide = 'Odd'

                self.setPageNumber(crds, pageSide, 0, pageNumber)

        # Outut the index entries at this point
#        for key in paIndex.keys() :

        # Report we are done now before we loose focus
        scribus.statusMessage('Process Complete!')

###############################################################################
############################## Output Results #################################
###############################################################################

        # Now we will output the results to PDF if that is desired
        if self.makePdf :
            pdfExport =  scribus.PDFfile()
            pdfExport.info = self.pdfFile
            pdfExport.file = self.pdfFile
            pdfExport.save()

        # View the output if set
        if self.makePdf and self.viewPdf :
            cmd = ['evince', self.pdfFile]
            try :
                subprocess.Popen(cmd)
            except Exception as e :
                result = scribus.messageBox ('View PDF command failed with: ' + str(e), scribus.BUTTON_OK)
     layercount].elements[elementcount].size.height
 x_pos = albumdata.pages[pagenum].layers[
     layercount].elements[elementcount].position.x - (
         size_x / 2)
 y_pos = albumdata.pages[pagenum].layers[
     layercount].elements[elementcount].position.y - (
         size_y / 2)
 #This is the kind of text defined within the "text" label
 #<p style=\"text-align: left;\"><span style=\"color:#000000;font-family: Calibri; font-size: 2.82mm;\">Cataratas de Iguazú (Argentina) 27/11/2016</span></p>\n
 caption_text = ""
 parser.feed(albumdata.pages[pagenum].layers[layercount].
             elements[elementcount].text)
 #print "caption_text : " + caption_text
 captionBox = scribus.createText(x_pos, y_pos, size_x,
                                 size_y)
 scribus.setText(caption_text, captionBox)
 #scribus.setFont("Copper Std", captionBox)
 scribus.setFontSize(fontsize, captionBox)
 #The following are defined within the element attributes, but they don't seem to be used. The fonts are rather taken from the html info within the "text" attribute
 #scribus.setFont(albumdata.pages[pagenum].layers[layercount].elements[elementcount].font.family, captionBox)
 #scribus.setFontSize(albumdata.pages[pagenum].layers[layercount].elements[elementcount].font.size, captionBox)
 rotation = -albumdata.pages[pagenum].layers[
     layercount].elements[elementcount].rotation % (2 *
                                                    math.pi)
 if rotation > 0.5:
     # https://stackoverflow.com/questions/34372480/rotate-point-about-another-point-in-degrees-python
     # Scribus by default rotates the text box over the upper leftmost corner, while myphotobook uses the center point.
     # Therefore, I use the function in the above site to translate the frame after rotation
     # It works for most of our rotated text (upside down, as in the album spine) but sometimes not in the straight horizontal text
     #	ox, oy = origin
     ox, oy = 0, 0
예제 #20
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  #
    #########################
    script = "Aufschlussdoku.py"
    version = "20140107"
    csvfile = scribus.fileDialog("csv2table :: open file", "*.csv")
    fname_ext = csvfile[csvfile.rfind("/") + 1:]
    fname_noext = fname_ext[:fname_ext.rfind(".")]
    reader = csv.reader(open(csvfile, "rb"), delimiter=";")
    boxes = [["strat_d", 2.25], ["strat_n", 2.25], ["strat_b", 6.5], ["strat_p", 2.3], ["strat_a", 3.9]]
    start_x = float(1.9075)
    start_y = float(10.5)
    strats = []
    strat_ct = int(0)
    strat_ok = float(0.0)
    print getpass.getuser()

    for line in reader:
        if line[0].find("Tiefe bis [m]") <> 0:
            start_x_0 = start_x
            strat_ct = strat_ct + 1
            strat_d = line[0].replace(",", ".");
            strat_uk = float(strat_d) + float(strat_ok)
            strat_draw = float(strat_d) * 2.0
            strat_uk_draw = start_y + strat_draw

            if strat_uk_draw > 26.4:
                nPage = scribus.currentPage() + 1
                pageendtext = "Fortsetzung nächste Seite"
                #print nPage
                scribus.createText(start_x_0 + 0.1, start_y + 0.1, 17, 0.5, "box_txt_pageend")
                scribus.sentToLayer("profil_txt", "box_txt_pageend")
                scribus.setText(pageendtext, "box_txt_pageend")
                scribus.setStyle("Buchner_sehrklein", "box_txt_pageend")
                scribus.newPage(-1,"Buchner_Standard")
                scribus.gotoPage(nPage)
                start_y = float(5.5)
                strat_uk_draw = start_y + strat_draw
                
            box_nr = int(0)
            #print strat_uk
            #print "aktuelle Seite:", scribus.currentPage()

            #print strat_uk
            strat_uk_txt = str(strat_uk).replace(".", ",");
            #print strat_uk_txt
            strat_h = line[0]
            strat_n = line[1]
            strat_b = line[2]
            strat_p = line[3]
            strat_a = line[4]
            strat = [strat_d, strat_uk, strat_h, strat_n, strat_b, strat_p, strat_a]
            #print strat
            strats.append(strat)

            for box in boxes:
                box_n = box[0] + str(strat_ct)
                box_txt = strat[box_nr + 2]
                box_txt_n = box_n + "txt"
                
                #print box_nr
                #print box_txt
                #print box_n, box_txt_n, dimensions[1], position
                scribus.createRect(start_x_0, start_y, float(box[1]), strat_draw, box_n)
                scribus.setLineWidth(0.567, box_n)
                scribus.sentToLayer("profil_rahmen", box_n)
                if box_nr == 0:
                    scribus.createText(start_x_0 + 0.1, start_y + (strat_draw) - 0.4, float(box[1]) - 0.2, 0.4, box_txt_n)
                    #print strat_uk_txt
                    scribus.setText(strat_uk_txt, box_txt_n)
                else:
                    scribus.createText(start_x_0 + 0.1, start_y + 0.1, float(box[1]) - 0.2, (strat_draw) - 0.1, box_txt_n)
                    scribus.setText(box_txt, box_txt_n)
                scribus.setStyle("Buchner_Standard schmal", box_txt_n)
                scribus.sentToLayer("profil_txt", box_txt_n)
                start_x_0 = start_x_0 + float(box[1])
                box_nr = box_nr + 1
            #print "end: strat count:", strat_ct
            start_y = strat_uk_draw
            start_x_0 = start_x
            strat_ok = strat_ok + float(strat_d)
    print "end: all"
    scribus.createText(start_x_0 + 0.1, start_y + 0.1, 17, 0.5, "box_txt_end")
    scribus.sentToLayer("profil_txt", "box_txt_end")
    endtext = "Erstellt von " + getpass.getuser() + " mit " + fname_ext + ", " + script + " (V" + version + ")"
    scribus.setText(endtext, "box_txt_end")
    scribus.setStyle("Buchner_sehrklein", "box_txt_end")
    scribus.saveDocAs(fname_noext + ".sla")
예제 #21
0
def funzioneprincipale(csvData):  # def funzioneprincipale(row,headerRow):
    # scribus.messageBox('Scribus - Messaggio di test', str(row), scribus.ICON_WARNING, scribus.BUTTON_OK)
    # scribus.messageBox('Scribus - Messaggio di test', str(headerRow), scribus.ICON_WARNING, scribus.BUTTON_OK)
    # scribus.messageBox('Scribus - Messaggio di test', str(csvData), scribus.ICON_WARNING, scribus.BUTTON_OK)
    if scribus.haveDoc():
        # scribus.newDoc(scribus.PAPER_LETTER,  (20,20,20,20),scribus.PORTRAIT, 1, scribus.UNIT_POINTS,  scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT)
        # Dichiaro variabili e costanti
        # le COSTANTI sono quelle in maiuscolo
        POS_X_FOOTER = 43
        WIDTH1 = 330
        WIDTH2 = 90
        HEIGHT = 26
        MAX_HEIGHT = 710
        # max_width = 520
        INTERLINEA = 12.5
        MARGIN_SX = 3.5
        MARGIN_DX = 3.5
        MARGIN_UP = 3.5
        MARGIN_DOWN = 2
        FONT_SIZE = 8
        NUM_COL = 3
        # primo numero da inserire dopo %VAR_F
        # n = 6

        # Riga di partenza del csv, da cui inizio a creare la tabella
        ROW_START = 1
        # Colonna di partenza, da cui creare la tabella
        COL_START = 3

        # variabili in minuscolo
        pos_y = 521

        # ciclo tutte le righe del csv
        for i in range(ROW_START, len(csvData)):
            # creo la variabile pos_footer, che contiene la nuova posizione della y
            # che verrà assegnata alla cornice di testo chiamata 'footer'
            pos_x = 43
            for j in range(COL_START, len(csvData[i])):
                # i è la riga attuale del csv
                # j è la colonna attuale del csv
                # cur_col è la colonna attuale nella pagina
                cur_col = j % NUM_COL
                cur_width = WIDTH1
                if cur_col == 0:  # and pos_x <= pos_x:
                    # a capo ogni num_col celle
                    # pos_y = pos_y + height
                    pos_x = 43
                    if pos_y >= MAX_HEIGHT:
                        # crea una nuova pagina se la variabile pos_y raggiunge la dimensione
                        # massima prestabilita
                        scribus.newPage(-1)
                        pos_y = HEIGHT + 20
                    else:
                        pos_y = pos_y + HEIGHT
                if cur_col == 1 or cur_col == 2:
                    cur_width = WIDTH2
                nometxtbox = "Cella: csvrow=%d, row=%d, col=%d" % (i, pos_y, pos_x)
                # cell_label = "%VAR_F" + str(n) + "%"
                cell_label = csvData[i][j]
                scribus.createText(pos_x, pos_y, cur_width, HEIGHT, nometxtbox)
                scribus.createRect(pos_x, pos_y, cur_width, HEIGHT)
                scribus.setText(cell_label, nometxtbox)
                # modifico la dimensione del testo
                scribus.setFontSize(FONT_SIZE, nometxtbox)
                # modifico i margini (sx, dx, alto, basso)
                scribus.setTextDistances(MARGIN_SX, MARGIN_DX, MARGIN_UP, MARGIN_DOWN, nometxtbox)
                # modifico l’interlinea
                scribus.setLineSpacing(INTERLINEA, nometxtbox)
                pos_x = pos_x + cur_width
                # n=n+1
                pos_footer = pos_y + HEIGHT + 5
                scribus.moveObjectAbs(POS_X_FOOTER, pos_footer, "footer")
        # Salvo il documento attivo altrimenti
        # lo script ScribusGenerator non inserisce la tabella appena creata
        # scribus.messageBox('Scribus - Messaggio di test', str(cell_label), scribus.ICON_WARNING, scribus.BUTTON_OK)
        scribus.saveDoc()
    else:
        scribus.messageBox(
            "Alert di errore", "Devi avere una pagina Scribus aperta!!!", scribus.ICON_WARNING, scribus.BUTTON_OK
        )
        scribus.newDoc(
            scribus.PAPER_LETTER,
            (20, 20, 20, 20),
            scribus.PORTRAIT,
            1,
            scribus.UNIT_POINTS,
            scribus.NOFACINGPAGES,
            scribus.FIRSTPAGERIGHT,
        )
예제 #22
0
# Database related issues
try:
    conn = MySQLdb.connect(passwd=password,
                           db=dbname,
                           host=hostname,
                           user=username)
except:
    scribus.messageBox(
        'DB connection example',
        'Connection error. You should specify your login in the script')
    sys.exit(1)

cur = conn.cursor()
# get the list of the databases
# it's like 'select * from dba_tables' in Oracle
count = cur.execute('show tables')
# formating the output
result = str(count) + ' table(s) in the ' + dbname + ' database.\n\n'
for i in cur.fetchall():
    result = result + i[0] + '\n'

# Scribus presentation part
scribus.newDoc(scribus.PAPER_A5, (10, 10, 20, 20), scribus.PORTRAIT, 1,
               scribus.UNIT_POINTS, scribus.NOFACINGPAGES,
               scribus.FIRSTPAGERIGHT)
txtName = scribus.createText(10, 10, 200, 200)
scribus.setText(result, txtName)

scribus.statusMessage('Script done.')
text_usage = "scribus -g -py " + sys.argv[0] + " -pa -o <outputfile.pdf> -pa -t <text place holder> <inputfile.sla>"
pdf_file = ''
text_placeholder = ''

try:
  opts, args = getopt.getopt(sys.argv[2:],"ho:t:",["output=", "text="])
except getopt.GetoptError:
  print(text_usage)
  sys.exit(2)

for opt, arg in opts:
  if opt == "-h":
     print(text_usage)
     sys.exit()
  elif opt in ("-o", "--output"):
     pdf_file = arg
  elif opt in ("-t", "--text"):
     text_placeholder = arg

if (pdf_file == "" or text_placeholder == "") :
     print(text_usage)
     sys.exit()

if scribus.haveDoc() :
    scribus.setText(text_placeholder, "placeholder")
    pdf = scribus.PDFfile()
    pdf.file = pdf_file
    pdf.save()
else :
    print("No file open")
    lattextshade = scribus.getTextShade(lattextstring)
    
    for row in data:
        #if i > 0 :
	  #sys.exit(1)
	#scribus.messageBox("csv2table", row)
	roseid = row[0]
	rosenameger = row[1]
	rosenamelat = row[2]
        #scribus.messageBox("csv2table", roseid+' '+rosenameger+' ('+rosenamelat+')')
        
        #Insert the Right Text into the Right Position
        
        #Write ID into ID Field
	scribus.deleteText(idtextstring)
	scribus.setText(roseid, idtextstring)
	scribus.setFont(idfont, idtextstring)
	scribus.setFontSize(idfonSize, idtextstring)
	scribus.setTextColor(idtextcolor, idtextstring)
	scribus.setTextShade(idtextshade, idtextstring)
	
	#Write German Name into german Name Field
	scribus.deleteText(gertextstring)
	scribus.setText(rosenameger, gertextstring)
	scribus.setFont(gerfont, gertextstring)
	scribus.setFontSize(gerfonSize, gertextstring)
	scribus.setTextColor(gertextcolor, gertextstring)
	scribus.setTextShade(gertextshade, gertextstring)
	
	#Write Latin Name into Latin Name field
	scribus.deleteText(lattextstring)
예제 #25
0
def createDefaultVal():
    scribus.gotoPage(1)
    if scribus.objectExists("myframe") == False:
        scribus.createText(-70, 10, 40, 10, "myframelabel")
        scribus.setText("Default Frame:", "myframelabel")
        scribus.setProperty("myframelabel", "m_PrintEnabled", False)

        scribus.createText(-30, 10, 10, 10, "myframe")
        scribus.setText("3", "myframe")
        scribus.setProperty("myframe", "m_PrintEnabled", False)

    if scribus.objectExists("myborder") == False:
        scribus.createText(-70, 30, 40, 10, "myborderlabel")
        scribus.setText("Default Border:", "myborderlabel")
        scribus.setProperty("myborderlabel", "m_PrintEnabled", False)

        scribus.createText(-30, 30, 10, 10, "myborder")
        scribus.setText("3", "myborder")
        scribus.setProperty("myborder", "m_PrintEnabled", False)

    if scribus.objectExists("mylayout") == False:
        scribus.createText(-70, 50, 40, 10, "mylayoutlabel")
        scribus.setText("Default Layout:", "mylayoutlabel")
        scribus.setProperty("mylayoutlabel", "m_PrintEnabled", False)

        scribus.createText(-30, 50, 10, 10, "mylayout")
        scribus.setText("h", "mylayout")
        scribus.setProperty("mylayout", "m_PrintEnabled", False)
예제 #26
0
    def main(self):

        # Load up all the file and record information.
        # Use CSV reader to build list of record dicts
        records = self.loadCSVData(self.dataFile)
        totalRecs = len(records)

        # Reality check first to see if we have anything to process
        if totalRecs <= 0:
            scribus.messageBox('Not Found', 'No records found to process!')
            sys.exit()

        pageNumber = 1
        recCount = 0
        row = 0
        pageSide = 'Odd'
        scribus.progressTotal(totalRecs)
        paIndex = {}
        lastName = ''
        firstName = ''
        photoFirstName = ''
        verseRef = ''
        verseText = ''

        # Get the page layout coordinates for this publication
        crds = self.getCoordinates(self.dimensions)

        # Make a new document to put our records on
        if scribus.newDocument(
                getattr(scribus, self.dimensions['page']['scribusPageCode']),
            (self.dimensions['margins']['left'],
             self.dimensions['margins']['right'],
             self.dimensions['margins']['top'],
             self.dimensions['margins']['bottom']), scribus.PORTRAIT, 1,
                scribus.UNIT_POINTS, scribus.NOFACINGPAGES,
                scribus.FIRSTPAGERIGHT, 1):

            self.setPageNumber(crds, pageSide, row, pageNumber)

            while recCount < totalRecs:

                # Output a new page on the first row after we have done the first page
                if row == 0 and recCount != 0:
                    scribus.newPage(-1)
                    if pageSide == 'Odd':
                        pageSide = 'Even'
                    else:
                        pageSide = 'Odd'

                    self.setPageNumber(crds, pageSide, row, pageNumber)

                ########### Now set the current record in the current row ##########

                # Set the last name
                lastName = records[recCount]['NameLast']

                # Adjust the NameFirst field to include the spouse if there is one
                if records[recCount]['Spouse'] != '':
                    firstName = records[recCount][
                        'NameFirst'] + ' & ' + records[recCount]['Spouse']
                else:
                    firstName = records[recCount]['NameFirst']

                # Make the photo file name
                photoFirstName = firstName.replace('&', '-').replace(
                    '.', '').replace(' ', '')

                # Set our record count for progress display and send a status message
                scribus.progressSet(recCount)
                scribus.statusMessage('Placing record ' + ` recCount ` +
                                      ' of ' + ` totalRecs `)

                # Add a watermark if a string is specified
                if self.outputWatermark:
                    self.addWatermark()

                # Put the last name element in this row
                nameLastBox = scribus.createText(crds[row]['nameLastXPos'],
                                                 crds[row]['nameLastYPos'],
                                                 crds[row]['nameLastWidth'],
                                                 crds[row]['nameLastHeight'])
                scribus.setText(lastName, nameLastBox)
                scribus.setTextAlignment(scribus.ALIGN_RIGHT, nameLastBox)
                scribus.setTextDistances(0, 0, 0, 0, nameLastBox)
                scribus.setFont(self.fonts['nameLast']['bold'], nameLastBox)
                scribus.setFontSize(self.fonts['nameLast']['size'],
                                    nameLastBox)
                scribus.setTextShade(80, nameLastBox)
                scribus.rotateObject(90, nameLastBox)

                # Place the first name element in this row
                nameFirstBox = scribus.createText(crds[row]['nameFirstXPos'],
                                                  crds[row]['nameFirstYPos'],
                                                  crds[row]['nameFirstWidth'],
                                                  crds[row]['nameFirstHeight'])
                scribus.setText(records[recCount]['Caption'], nameFirstBox)
                scribus.setTextAlignment(scribus.ALIGN_LEFT, nameFirstBox)
                scribus.setFont(self.fonts['nameFirst']['boldItalic'],
                                nameFirstBox)
                scribus.setFontSize(self.fonts['nameFirst']['size'],
                                    nameFirstBox)

                # Place the image element in this row
                # We will need to do some processing on the first pass
                # The default output format is JPG
                orgImgFileName = records[recCount]['Photo']
                orgImgFile = os.path.join(self.orgImgDir, orgImgFileName)
                baseImgFileName = lastName + '_' + photoFirstName
                if self.willBePngImg:
                    ext = 'png'
                else:
                    ext = 'jpg'
                if not self.rgbColor:
                    imgFile = os.path.join(
                        getattr(self, ext + 'ImgDir'),
                        baseImgFileName + '-gray' + '.' + ext)
                else:
                    imgFile = os.path.join(getattr(self, ext + 'ImgDir'),
                                           baseImgFileName + '.' + ext)

                # Process the image now if there is none
                if not os.path.exists(imgFile):
                    self.img_process.sizePic(orgImgFile, imgFile,
                                             self.maxHeight)
                    #                    self.img_process.outlinePic(imgFile, imgFile)
                    self.img_process.scalePic(imgFile, imgFile,
                                              self.imgDensity)
                    self.img_process.addPoloroidBorder(imgFile, imgFile)
                    # Color RGB is the default
                    if not self.rgbColor:
                        self.img_process.makeGray(imgFile, imgFile)

                # Double check the output and substitute with placeholder pic
                if not os.path.exists(imgFile):
                    imgFile = self.placeholderPic
                # Create the imageBox and load the picture
                imageBox = scribus.createImage(crds[row]['imageXPos'],
                                               crds[row]['imageYPos'],
                                               crds[row]['imageWidth'],
                                               crds[row]['imageHeight'])
                if os.path.isfile(imgFile):
                    scribus.loadImage(imgFile, imageBox)
                scribus.setScaleImageToFrame(scaletoframe=1,
                                             proportional=1,
                                             name=imageBox)

                # Place the country element in this row (add second one if present)
                countryBox = scribus.createText(crds[row]['countryXPos'],
                                                crds[row]['countryYPos'],
                                                crds[row]['countryWidth'],
                                                crds[row]['countryHeight'])
                countryLine = records[recCount]['Country1']
                try:
                    if records[recCount]['Country2'] != '':
                        countryLine = countryLine + ' & ' + records[recCount][
                            'Country2']
                except:
                    pass
                scribus.setText(countryLine, countryBox)
                scribus.setTextAlignment(scribus.ALIGN_RIGHT, countryBox)
                scribus.setFont(self.fonts['text']['boldItalic'], countryBox)
                scribus.setFontSize(self.fonts['text']['size'], countryBox)

                # Place the assignment element in this row
                assignBox = scribus.createText(crds[row]['assignXPos'],
                                               crds[row]['assignYPos'],
                                               crds[row]['assignWidth'],
                                               crds[row]['assignHeight'])
                scribus.setText(self.fixText(records[recCount]['Assignment']),
                                assignBox)
                # Assign style to box
                #                scribus.createParagraphStyle(name='assignStyle', alignment=0, leftmargin=10, firstindent=-10)
                #                scribus.setStyle('assignStyle', assignBox)
                # Hard formated box
                scribus.setTextAlignment(scribus.ALIGN_LEFT, assignBox)
                scribus.setFont(self.fonts['text']['italic'], assignBox)
                scribus.setFontSize(self.fonts['text']['size'], assignBox)
                scribus.setLineSpacing(self.fonts['text']['size'] + 1,
                                       assignBox)
                scribus.setTextDistances(4, 0, 0, 0, assignBox)
                # Resize the frame height and determine the difference for
                # placing the next frame below it
                assignHeightNew = self.resizeFrame(assignBox)
                assignHeightDiff = crds[row]['assignHeight'] - assignHeightNew

                # Place the verse element in this row
                verseYPosNew = crds[row]['verseYPos'] - assignHeightDiff
                verseBox = scribus.createText(crds[row]['verseXPos'],
                                              verseYPosNew,
                                              crds[row]['verseWidth'],
                                              crds[row]['verseHeight'])
                # The verse element may be either a Scripture verse or a prayer request
                # If it is Scripture, and it has a verse ref, we want to set that
                # seperatly so we need to do a little preprocess on the text to find
                # out if it has a ref. This script will only recognize references
                # at the end of the string that are enclosed in brackets. See the
                # findVerseRef() function for more details
                verseRef = self.findVerseRef(records[recCount]['Prayer'])
                if verseRef:
                    verseText = self.removeVerseRef(
                        self.fixText(records[recCount]['Prayer']))
                    scribus.setText(verseText, verseBox)
                else:
                    scribus.setText(self.fixText(records[recCount]['Prayer']),
                                    verseBox)
                # Can't find a way to set alignment to justified using setTextAlignment()
#                scribus.setTextAlignment(scribus.ALIGN_LEFT, verseBox)
# Because of this, we make a style which seems to work
                scribus.createParagraphStyle(name='vBoxStyle', alignment=3)
                scribus.setStyle('vBoxStyle', verseBox)
                scribus.setFont(self.fonts['verse']['regular'], verseBox)
                scribus.setFontSize(self.fonts['verse']['size'], verseBox)
                scribus.setLineSpacing(self.fonts['verse']['size'] + 1,
                                       verseBox)
                scribus.setTextDistances(4, 0, 4, 0, verseBox)
                if self.hyphenate:
                    scribus.hyphenateText(verseBox)
                # Get the height difference in case we need to set ref box
                verseHeightNew = self.resizeFrame(verseBox)
                verseHeightDiff = crds[row]['verseHeight'] - verseHeightNew
                if verseRef:
                    # Set coordinates for this box
                    vRefBoxX = crds[row]['verseXPos']
                    vRefBoxY = (verseYPosNew + verseHeightNew)
                    vRefBoxH = crds[row]['nameFirstHeight'] / 2
                    vRefBoxW = crds[row]['verseWidth']
                    verseRefBox = scribus.createText(vRefBoxX, vRefBoxY,
                                                     vRefBoxW, vRefBoxH)
                    scribus.setText(verseRef, verseRefBox)
                    scribus.setTextAlignment(scribus.ALIGN_RIGHT, verseRefBox)
                    scribus.setFont(self.fonts['verse']['italic'], verseRefBox)
                    scribus.setFontSize(self.fonts['verse']['size'] - 2,
                                        verseRefBox)
                    scribus.setLineSpacing(self.fonts['verse']['size'],
                                           verseRefBox)
                    scribus.setTextDistances(2, 0, 0, 0, verseRefBox)

                # Up our counts
                if row >= self.dimensions['rows']['count'] - 1:
                    row = 0
                    pageNumber += 1
                else:
                    row += 1

                recCount += 1

            # Create the index page here
            # Output a new page for the index
            if row == 0 and recCount != 0:
                scribus.newPage(-1)
                if pageSide == 'Odd':
                    pageSide = 'Even'
                else:
                    pageSide = 'Odd'

                self.setPageNumber(crds, pageSide, 0, pageNumber)

        # Outut the index entries at this point
#        for key in paIndex.keys() :

# Report we are done now before we loose focus
        scribus.statusMessage('Process Complete!')

        ###############################################################################
        ############################## Output Results #################################
        ###############################################################################

        # Now we will output the results to PDF if that is desired
        if self.makePdf:
            pdfExport = scribus.PDFfile()
            pdfExport.info = self.pdfFile
            pdfExport.file = self.pdfFile
            pdfExport.save()

        # View the output if set
        if self.makePdf and self.viewPdf:
            cmd = ['evince', self.pdfFile]
            try:
                subprocess.Popen(cmd)
            except Exception as e:
                result = scribus.messageBox(
                    'View PDF command failed with: ' + str(e),
                    scribus.BUTTON_OK)
예제 #27
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import scribus

scribus.openDoc('/Users/mforaste/Desktop/gabarit_test.sla')
scribus.setText('Resultat concluant : ' + sys.argv[1], 'Text4')
scribus.saveDoc()
scribus.closeDoc()
textbox = scribus.getSelectedObject()
pageitems = scribus.getPageItems()
boxcount = 1
for item in pageitems:
    if (item[0] == textbox):
        if (item[1] != 4):
            scribus.messageBox('Scribus - Usage Error',
                               "This is not a textframe. Try again.",
                               scribus.ICON_WARNING, scribus.BUTTON_OK)
            sys.exit(2)
contents = scribus.getTextLength(textbox)

probably_url = scribus.getAllText(textbox)
button = scribus.messageBox('url is', probably_url, scribus.ICON_NONE,
                            scribus.BUTTON_OK, scribus.BUTTON_CANCEL)
if button == scribus.BUTTON_CANCEL:
    sys.exit(2)

r = requests.get(probably_url)
scribus.setText(r.text, textbox)

scribus.setRedraw(1)
scribus.docChanged(1)
# TODO: save in a new doc
# TODO: Check for a valid url
# TODO: make it possible to do all text boxes in a document
# TODO: Format the text, make it possible to use basic markdown, basic wiki formatting
scribus.messageBox("Finished", "That should do it!", scribus.ICON_NONE,
                   scribus.BUTTON_OK)
#!/usr/bin/env python


import scribus
from oblique_text import make_oblique_4

scribus.setText(make_oblique_4(scribus.getAllText()))
    # scribus.openDoc(os.path.dirname(os.path.realpath(__file__)) + '/cards.sla')
    # scribus.openDoc(os.path.dirname(os.path.realpath(sys.argv[0])) + '/cards.sla')
    scribus.messageBox("Error", "You should first open the cards.sla file", ICON_WARNING, BUTTON_OK)
    sys.exit(1)

# for page in range(2, scribus.pageCount()) :
# scribus.messageBox("Error", str(scribus.pageCount()), ICON_WARNING, BUTTON_OK)
for page in range(scribus.pageCount(), 1, -1) :
    scribus.deletePage(page)

for project in projects :
    scribus.newPage(-1, project['section'])

    # title: x=10 y=10 w=85mm h=20
    # description: x=10 y=40 w=85mm h=80
    titleFrame = scribus.createText(10, 10, 85, 20)
    scribus.setText(project['title'], titleFrame)
    scribus.setStyle('title', titleFrame)
    descriptionFrame = scribus.createText(10, 40, 85, 80)
    scribus.setText(project['description'], descriptionFrame)
    scribus.setStyle('description', descriptionFrame)

    # shrink the title and text size if it does not fit in the frame
    while scribus.textOverflows(titleFrame) != 0 :
        fontSize = scribus.getFontSize(titleFrame)
        scribus.setFontSize(fontSize - 1, titleFrame)

    while scribus.textOverflows(descriptionFrame) != 0 :
        fontSize = scribus.getFontSize(descriptionFrame)
        scribus.setFontSize(fontSize - 1, descriptionFrame)
예제 #31
0
hostname = 'server.foo.org'
dbname = 'name'
username = '******'
password = '******'

# connection to the network wide server would be time consuming. So get the hint to the user.
scribus.statusMessage('Connecting to the ' + hostname + ' server. Be patient, please...')

# Database related issues
try:
    conn = MySQLdb.connect(passwd=password, db=dbname, host=hostname, user=username)
except:
	scribus.messageBox('DB connection example', 'Connection error. You should specify your login in the script')
	sys.exit(1)

cur = conn.cursor()
# get the list of the databases
# it's like 'select * from dba_tables' in Oracle
count = cur.execute('show tables')
# formating the output
result = str(count) + ' table(s) in the ' + dbname + ' database.\n\n'
for i in cur.fetchall():
    result = result + i[0] + '\n'

# Scribus presentation part
scribus.newDoc(scribus.PAPER_A5, (10, 10, 20, 20), scribus.PORTRAIT, 1, scribus.UNIT_POINTS, scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT)
txtName = scribus.createText(10, 10, 200, 200)
scribus.setText(result, txtName)

scribus.statusMessage('Script done.')
예제 #32
0
def main(argv):

    scribus.setUnit(scribus.UNIT_MILLIMETERS)

    # get page size
    pagesize = scribus.getPageSize()

    ###########################################

    # size and position of the exit buttons
    linksize = pagesize[0] / 30
    linkpos = pagesize[0] - linksize - 2

    # set up exit to page
    pagenum = scribus.pageCount()
    exittopage = scribus.valueDialog(
        "Exit to page",
        "Exit buttons should go to page (1-" + str(pagenum) + ") :", "1")

    #error
    #if exittopage > pagenum:
    #    scribus.messageBox("Error", "This page doesn't exist.")
    #    sys.exit()

    # get active layer, create new layer for exit buttons, set it as active
    activelayer = scribus.getActiveLayer()
    scribus.createLayer("Exitbuttons")
    scribus.setActiveLayer("Exitbuttons")

    #progressbar max
    scribus.progressTotal(pagenum)

    # iterate through all the pages
    page = 1
    while (page <= pagenum):

        #messagebar text
        scribus.messagebarText("Create exit buttons...")

        scribus.progressSet(page)
        scribus.gotoPage(page)

        # create rectangle
        exitrect = scribus.createRect(linkpos, 2, linksize, linksize,
                                      "exitrect" + str(page))
        scribus.setFillColor("White", exitrect)

        # create text in rectangle
        exittext = scribus.createText(linkpos, 4, linksize, linksize,
                                      "exittext" + str(page))

        scribus.setText("X", exittext)
        scribus.setFontSize(20, exittext)
        scribus.setTextAlignment(1, exittext)

        # create link annotation
        exitlink = scribus.createText(linkpos, 2, linksize, linksize,
                                      "exitlink" + str(page))
        #setLinkAnnotation(page,x,y,["name"])
        scribus.setLinkAnnotation(int(exittopage), 0, 0, exitlink)

        # add page number to iteration
        page += 1

    # go back to active layer
    scribus.setActiveLayer(activelayer)
예제 #33
0
def frontPage(LogoPath, ChurchPath, ChurchImage, Citation, CitationLocation):
    #scribus.setText('Gemeindebrief   DIGITAL Buxtehude',"Oben")

    #Line upper left corner
    l_line = scribus.createLine(10,10,10,33,"l_Line")
    scribus.setLineWidth(0.75, l_line)
    scribus.setLineColor("NAK-blau 100%", l_line)
    scribus.setLineShade("NAK-blau 100%", l_line)

    #Headline
    t_headline = scribus.createText(10,22,128,20,"t_Headline")
    scribus.setText("Gemeindebrief", t_headline)
    scribus.selectText(1, 100, t_headline)
    scribus.setCharacterStyle(
        "Erste Seite - Gemeindebrief - gross", t_headline)
    scribus.deselectAll()
    # Digital - Text
    t_digitalText = scribus.createText(107,27,30,7, "t_Digital")
    scribus.selectText(1, 100, t_digitalText)
    scribus.setCharacterStyle(
        "Erste Seite - Gemeindebrief - gross", t_digitalText)
    scribus.deselectAll()
    # Congregation - Text
    t_congregationText = scribus.createText(10,35.250, 70, 6, "t_Congregation")
    scribus.selectText(1, 100, t_congregationText)
    scribus.setCharacterStyle(
        "Erste Seite - Gemeindebrief - klein", t_congregationText)
    scribus.deselectAll()

    # Month Year
    t_monthYear = scribus.createText(56, 46.500, 82, 10, "t_MonthYear")
    scribus.selectText(1, 100, t_monthYear)
    scribus.setCharacterStyle(
        "Erste Seite - Gemeindebrief - Monat", t_monthYear)
    scribus.deselectAll()

    # Logo charitable
    i_charitable = scribus.createImage(10, 46, 35.5, 9, "i_NAC_charitable")
    scribus.loadImage(LogoPath + "Logo_NAK_karitativ_HQ.tiff", i_charitable)
    scribus.setImageScale(0.0613, 0.0613, i_charitable)
    
    # Church image
    i_churchImage = scribus.createImage(10,57,128,100,"i_Church")
    scribus.loadImage(ChurchPath + ChurchImage, i_churchImage)
    scribus.setImageScale(1, 1, i_churchImage)
    scribus.setImageOffset(-18.244, -0.342, i_churchImage)
    
    # Citation
    t_citation = scribus.createText(42.500, 162.500,95.500,4.500, "t_Citation")
    # OverflowCheck
    scribus.setText(Citation, t_citation)
    scribus.selectText(1, 100, t_citation)
    scribus.setCharacterStyle("Erste Seite - Bibelzitat - Text", t_citation)
    scribus.deselectAll()
    # Citation Location
    t_citationLocation = scribus.createText(42.500, 170, 95.500, 3, "t_CitationLocation")
    scribus.setText(CitationLocation, t_citationLocation)
    scribus.selectText(1, 100, t_citationLocation)
    scribus.setCharacterStyle(
        "Erste Seite - Bibelzitat - Ort", t_citationLocation)
    scribus.deselectAll()

    # NAC
    t_nac = scribus.createText(52.500,195,66,5,"t_NAC")
    scribus.setText("Neuapostolische Kirche", t_nac)
    scribus.selectText(1, 100, t_nac)
    scribus.setCharacterStyle("Erste Seite - NAK", t_nac)
    scribus.deselectAll()
    # North and east germany
    t_northEastGermany = scribus.createText(52.500, 195, 66, 5, "t_NorthEastGermany")
    scribus.setText("Nord- und Ostdeutschland", t_northEastGermany)
    scribus.selectText(1, 100, t_northEastGermany)
    scribus.setCharacterStyle(
        "Erste Seite - Nord- und Ostdeutschland", t_northEastGermany)
    scribus.deselectAll()

    # NAC Logo
    i_nacLogo = scribus.createImage(122, 184, 16, 16,"i_Logo")
    scribus.loadImage("L:\\GB\\Bilder\\Logos\\Logo_NAK_HQ.tif", i_nacLogo)
    scribus.setImageScale(0.0384, 0.0384, i_nacLogo)

    scribus.saveDocAs()
예제 #34
0

import scribus

if scribus.haveDoc():
	scribus.setText("bblablabla","Texte1");
def main(argv):

    ###########################################

    scribus.newDocDialog()

    if scribus.haveDoc:
        scribus.setUnit(scribus.UNIT_MILLIMETERS)
        (w, h) = scribus.getPageSize()

        ###################

        # ask for workdir
        workdir = scribus.fileDialog("Open directory with images",
                                     "",
                                     haspreview=False,
                                     issave=False,
                                     isdir=True)
        #workdir = "/media/sda7/StudioSession3/PDFTools/pics"
        #workdir = "/media/sda7/ISG/Itex/PhotoVisit/Boilerroom"

        # 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)))
        #scribus.messageBox("Help", str(filelist))

        # count files
        filesinworkdir = len(filelist)
        #scribus.messageBox("Help", str(filesinworkdir))

        #messagebar text
        scribus.messagebarText("Importing images...")

        #error
        if filesinworkdir == 0:
            scribus.messageBox("Error", "This directory is empty.")
            sys.exit()

        # add filename text?
        addfilenames = scribus.messageBox("Import images",
                                          "Files found in workdir : " +
                                          str(filesinworkdir) +
                                          "\n\nAdd file names to images?",
                                          button1=scribus.BUTTON_YES,
                                          button2=scribus.BUTTON_NO)

        #create text layer
        if addfilenames == 16384:
            activelayer = scribus.getActiveLayer()
            scribus.createLayer("Filenames")
            scribus.setActiveLayer(activelayer)

        #progressbar max
        scribus.progressTotal(filesinworkdir)

        page = 1

        #create page, add and load image
        for i in filelist:
            scribus.progressSet(page)

            scribus.gotoPage(page)
            scribus.createImage(0, 0, w, h, "imagename" + str(page))
            scribus.loadImage(filelist[page - 1], "imagename" + str(page))
            scribus.setScaleImageToFrame(True,
                                         proportional=True,
                                         name="imagename" + str(page))
            #scribus.setImageOffset(0, 0, "imagename"+str(page))
            #scribus.setScaleFrameToImage(name="imagename"+str(page))

            # add filename on page?
            if addfilenames == 16384:
                scribus.setActiveLayer("Filenames")
                filename = scribus.createText(2, 2, 50, 10, filelist[page - 1])
                scribus.setText(os.path.basename(filelist[page - 1]), filename)
                scribus.setTextColor("White", filename)
                scribus.setActiveLayer(activelayer)

            scribus.newPage(-1)
            page += 1

        #delete last blank page
        scribus.deletePage(filesinworkdir + 1)
예제 #36
0
    def pageFn(left, right):
        page = scribus.newPage(-1, 'planner')
        i = 0
        sizeDate = (20, 15)
        sizeMonth = (20, 7)
        sizeName = (290, 7)
        for xend, y in iterDayLines():
            try:
                tLeftDate = left[i]
                posLeftDate = (xstart, y - sizeDate[1])
                posLeftMonth = (xstart + sizeDate[0], y - sizeDate[1])
                posLeftName = (xstart + sizeDate[0], y - sizeName[1])
                tLeftName = ', '.join(d[tLeftDate.month][tLeftDate.day])
                objLeftDate = scribus.createText(*posLeftDate + sizeDate)
                objLeftMonth = scribus.createText(*posLeftMonth + sizeMonth)
                objLeftName = scribus.createText(*posLeftName + sizeName)
                scribus.setText(tLeftDate.strftime('%d'), objLeftDate)
                scribus.setText(mm(tLeftDate), objLeftMonth)
                scribus.setText(tLeftName, objLeftName)
                scribus.setStyle('dateL', objLeftDate)
                scribus.setStyle('monthL', objLeftMonth)
                scribus.setStyle('nameL', objLeftName)
            except IndexError:
                pass

            try:
                posRightDate = (xend - sizeDate[0], y - sizeDate[1])
                posRightMonth = (xend - sizeDate[0] - sizeMonth[0],
                                 y - sizeDate[1])
                posRightName = (xend - sizeDate[0] - sizeName[0],
                                y - sizeName[1])
                tRightDate = right[i]
                tRightName = ', '.join(d[tRightDate.month][tRightDate.day])
                objRightDate = scribus.createText(*posRightDate + sizeDate)
                objRightMonth = scribus.createText(*posRightMonth + sizeMonth)
                objRightName = scribus.createText(*posRightName + sizeName)
                scribus.setText(tRightDate.strftime('%d'), objRightDate)
                scribus.setText(mm(tRightDate), objRightMonth)
                scribus.setText(tRightName, objRightName)
                scribus.setStyle('dateR', objRightDate)
                scribus.setStyle('monthR', objRightMonth)
                scribus.setStyle('nameR', objRightName)
            except IndexError:
                pass
            i += 1
예제 #37
0
def funzioneprincipale(csvData):

    for line in csvData:
        i = 0
        listacompleta=[]
        while i < len(line):
            listacompleta.append(line[i])
            #scribus.messageBox('Scribus - Messaggio di test', str(line[i]), scribus.ICON_WARNING, scribus.BUTTON_OK)
            i = i + 1

    if scribus.haveDoc():
        #scribus.messageBox('Scribus - Messaggio di test', str(listacompleta), scribus.ICON_WARNING, scribus.BUTTON_OK)
        #scribus.newDoc(scribus.PAPER_LETTER,  (20,20,20,20),scribus.PORTRAIT, 1, scribus.UNIT_POINTS,  scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT)
        #variabili
        pos_footer_x = 43
        pos_y = 521
        width1 = 330
        width2 = 90
        height = 26
        max_height = 710
        max_width = 520
        interlinea = 12.5
        margin_sx = 3.5
        margin_dx = 3.5
        margin_up = 3.5
        margin_down = 2
        font_size = 8
        # primo numero da inserire dopo %VAR_F
        n = 6
        num_col = 3
        width3 = width1 + width2
        #ciclo tutte le righe del csv
        for i in range(1, len(csvData)):
            #scribus.messageBox('Scribus - Messaggio di test', str(len(csvData[i])), scribus.ICON_WARNING, scribus.BUTTON_OK)
            pos_x = 43
            #colonne
            for j in range(3, len(csvData[i])):
            #creo la variabile pos_footer, che contiene la nuova posizione della y
            #che verrà assegnata alla cornice di testo chiamata 'footer'
             while (pos_x <= max_width):
                #creazione di 3 colonne con dimensioni diverse
                # la prima ha larghezza pari a variabile width1
                # la seconda e la terza hanno la larghezza pari a width2
                if (pos_x <= width1):
                    nometxtbox = "Cella: I=%d, Pos_x=%d, Pos_y=%d" % (i, pos_x, pos_y)
                    cell_label = csvData[i][j]
                    scribus.createText(pos_x, pos_y, width1, height, nometxtbox)
                    scribus.createRect(pos_x, pos_y, width1, height)
                    scribus.setText(cell_label, nometxtbox)
                    #scribus.setText("Testo di pcsvDataa","Testo1")
                    #comando per creare una cornice di testo
                    #modifico la dimensione del testo
                    scribus.setFontSize(font_size, nometxtbox)
                    #modifico i margini (sx, dx, alto, basso)
                    scribus.setTextDistances(margin_sx, margin_dx, margin_up, margin_down, nometxtbox)
                    #modifico l’interlinea
                    scribus.setLineSpacing(interlinea,nometxtbox)
                    j = j + 1
                    pos_x = pos_x + width1
                    #n = n + 1
                elif (pos_x <= width3):
                    nometxtbox = "Cella: I=%d, Pos_x=%d, Pos_y=%d" % (i, pos_x, pos_y)
                    cell_label = csvData[i][j]
                    scribus.createText(pos_x, pos_y, width2, height, nometxtbox)
                    scribus.createRect(pos_x, pos_y, width2, height)
                    scribus.setText(cell_label, nometxtbox)
                    #Allineo il testo al centro
                    scribus.setTextAlignment(scribus.ALIGN_CENTERED, nometxtbox)
                    scribus.setFontSize(font_size, nometxtbox)
                    scribus.setTextDistances(margin_sx, margin_dx, margin_up, margin_down, nometxtbox)
                    scribus.setLineSpacing(interlinea,nometxtbox)
                    j = j + 1
                    pos_x = pos_x + width2
                    #n = n + 1
                else:
                    nometxtbox = "Cella: I=%d, Pos_x=%d, Pos_y=%d" % (i, pos_x, pos_y)
                    cell_label = csvData[i][j]
                    scribus.createText(pos_x, pos_y, width2, height, nometxtbox)
                    scribus.createRect(pos_x, pos_y, width2, height)
                    scribus.setText(cell_label, nometxtbox)
                    #Allineo il testo al centro
                    scribus.setTextAlignment(scribus.ALIGN_CENTERED, nometxtbox)
                    scribus.setFontSize(font_size, nometxtbox)
                    scribus.setTextDistances(margin_sx, margin_dx, margin_up, margin_down, nometxtbox)
                    scribus.setLineSpacing(interlinea,nometxtbox)
                    j = j + 1
                    pos_x = pos_x + width2
                    #n = n + 1

            if pos_y >= max_height:
            #crea una nuova pagina se la variabile pos_y raggiunge la dimensione
            #massima prestabilita
                scribus.newPage(-1)
                pos_y = height + 20
            else:
                pos_y = pos_y + height
        #Salvo il documento attivo altrimenti
        #lo script ScribusGenerator non inserisce la tabella appena creata
        pos_footer_y = pos_y + height + 5
        scribus.moveObjectAbs(pos_footer_x, pos_footer_y,"footer")
        scribus.saveDoc()

    else:
        scribus.messageBox('Alert di errore',  "Devi avere una pagina Scribus aperta!!!", scribus.ICON_WARNING,  scribus.BUTTON_OK)
        scribus.newDoc(scribus.PAPER_LETTER,  (20,20,20,20),scribus.PORTRAIT, 1, scribus.UNIT_POINTS,  scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT)

#per importare uno script copiarlo nella cartella: C:\Python27\Lib\site-packages
#Ottenere testo da textbox
#a=scribus.getText(nometextbox)
#mostrare msgbox
#scribus.messageBox('Scribus - Messaggio di test', a, scribus.ICON_WARNING, scribus.BUTTON_OK)