Esempio n. 1
0
def copyPlayer(sourceName, destinationName):
    if scribus.objectExists(sourceName):
        doc = scribus.getDocName()
        unit = scribus.getUnit()
        (PageWidth, PageHeight) = scribus.getPageSize()
        (iT, iI, iO, iB) = scribus.getPageMargins()
        NewPagepoint = PageHeight - iT - iB
        player = scribus.selectObject(sourceName)
        #Duplicate the object...
        scribus.duplicateObject(sourceName)
        x = scribus.getSelectedObject()
        newObjectName = str(x)
        size = scribus.getSize(newObjectName)
        scribus.moveObject(0, size[1], newObjectName)
        (x, y) = scribus.getPosition(newObjectName)
        scribus.setRedraw(1)
        scribus.docChanged(1)
        if (y + size[1] > NewPagepoint):
            currentPage = scribus.currentPage()
            scribus.newPage(-1)
            newPage = currentPage + 1
            scribus.copyObject(newObjectName)
            scribus.deleteObject(newObjectName)
            scribus.gotoPage(newPage)
            scribus.pasteObject(newObjectName)
            scribus.moveObjectAbs(iO, iT, newObjectName)
        scribus.setNewName(destinationName, sourceName)
        scribus.setNewName(sourceName, newObjectName)
def fileMatchingTextFrame(sampleFrameName, pattern):
    pagenum = scribus.pageCount()
    for page in range(1, pagenum + 1):
        scribus.gotoPage(page)
        d = scribus.getPageItems()
        for item in d:
            # print(item)
            frameName = item[0]
            if (item[1] == 4):
                if frameName != sampleFrameName and remove_copy_prefix(frameName).startswith(pattern):
                    print(frameName + " found")
                    position = scribus.getPosition(frameName)
                    scribus.selectObject(sampleFrameName)
                    scribus.duplicateObject()
                    #duplicateFrameName = scribus.getSelectedObject()
                    scribus.moveObjectAbs(position[0], position[1])
                    scribus.deleteObject(frameName)
def fileMatchingTextFrame(sampleFrameName, pattern):
    pagenum = scribus.pageCount()
    for page in range(1, pagenum + 1):
        scribus.gotoPage(page)
        d = scribus.getPageItems()
        for item in d:
            # print(item)
            frameName = item[0]
            if (item[1] == 4):
                if frameName != sampleFrameName and remove_copy_prefix(
                        frameName).startswith(pattern):
                    print(frameName + " found")
                    position = scribus.getPosition(frameName)
                    scribus.selectObject(sampleFrameName)
                    scribus.duplicateObject()
                    #duplicateFrameName = scribus.getSelectedObject()
                    scribus.moveObjectAbs(position[0], position[1])
                    scribus.deleteObject(frameName)
def load_song(data, offset, settings):
    page_num = scribus.pageCount()
    page_width, page_height, margin_top, margin_left, margin_right, margin_bottom = page_size_margin(
        page_num)
    start_point = margin_top + offset

    new_width = page_width - margin_left - margin_right
    if not FAST:
        scribus.placeEPS(os.path.join(FILES, data["filename"]), 0, 0)
        eps = scribus.getSelectedObject()
        eps_width, eps_height = scribus.getSize(eps)
        #scribus.scaleGroup(new_width/eps_width) # slow on scribus 1.4; does something else on scribus 1.5
        scribus.sizeObject(eps_width * 0.86, eps_height * 0.86, eps)
        scribus.moveObjectAbs(margin_left, start_point + SPACING_HEADLINE_SONG,
                              eps)
        eps_width, eps_height = scribus.getSize(eps)
    else:
        eps_height = 0

    scribus.deselectAll()
    textbox = scribus.createText(margin_left, start_point, new_width, 20)

    style_suffix = get_style_suffix()

    if data["composer"]:
        scribus.deselectAll()
        scribus.insertText(u"{}\n".format(data["composer"]), 0, textbox)
        scribus.selectText(0, 1, textbox)
        scribus.setStyle("subline_{}".format(style_suffix), textbox)

    if data["poet"]:
        scribus.deselectAll()
        scribus.insertText(u"{}\n".format(data["poet"]), 0, textbox)
        scribus.selectText(0, 1, textbox)
        scribus.setStyle("subline_{}".format(style_suffix), textbox)

    scribus.deselectAll()
    scribus.insertText(u"{}\n".format(data["name"]), 0, textbox)
    scribus.selectText(0, 1, textbox)
    scribus.setStyle("headline_{}".format(style_suffix), textbox)

    text = data["text"]
    text = [t.strip() for t in text if t.strip() != ""]

    # TODO: exit if text == []

    textbox = scribus.createText(
        margin_left,
        start_point + eps_height + SPACING_HEADLINE_SONG + SPACING_SONG_TEXT,
        new_width, 50)
    scribus.setStyle("text", textbox)
    # let's see how many digits are in there:
    num_verses = len([l for l in text if l.isdigit()])
    num_chars = 0
    num_line_total = len(text)
    num_line_actually = 0
    no_new_line = False
    verse_counter = 0
    text_columns_height = 0  # TODO: should be None
    for num_line, line in enumerate(text):
        if line.strip == "":
            continue
        num_line_actually += 1
        if line.isdigit():

            print "#", verse_counter, math.ceil(
                num_verses * 0.5), num_verses, data["filename"]
            if verse_counter == math.ceil(
                    num_verses * 0.5
            ):  # this is the first verse that should be in the new column, so let's see what's the height
                print text_columns_height, num_line_actually
                text_columns_height = BASELINE_GRID * (num_line_actually - 1)

            first_char = "\n"
            if num_line == 0:
                first_char = ""
            no_new_line = True
            line = u"{}{}.\t".format(first_char, line)
            scribus.insertText(line, -1, textbox)
            scribus.deselectAll()
            scribus.selectText(num_chars, len(line), textbox)
            #scribus.setStyle("num", textbox) # no character styles available
            #scribus.setFontSize(5, textbox)  # TODO: testing only # BUG?
            scribus.setFont("Linux Libertine O Bold", textbox)
            num_chars += len(line)
            verse_counter += 1
        else:
            if no_new_line:
                first_char = ""
            else:
                first_char = chr(28)
            no_new_line = False
            line = u"{}{}".format(first_char, line)
            scribus.insertText(line, -1, textbox)
            #scribus.deselectAll()
            #scribus.selectText(num_chars, len(line), textbox)
            #scribus.setStyle("text", textbox)
            num_chars += len(line)

    scribus.setColumnGap(5, textbox)
    columns = settings.get("columns", 2)
    scribus.setColumns(columns, textbox)
    if columns != 2:
        fit_height(textbox)
    else:
        scribus.sizeObject(new_width, text_columns_height, textbox)
        l, t = scribus.getPosition(textbox)
        scribus.moveObjectAbs(l,
                              round(t / BASELINE_GRID) * BASELINE_GRID,
                              textbox)
        if scribus.textOverflows(textbox):
            fit_height(textbox)  # there are some cases,..
    text_width, text_height = scribus.getSize(textbox)
    text_left, text_top = scribus.getPosition(textbox)
    return text_top + text_height - start_point + SPACING_SONGS, page_num
Esempio n. 5
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,
        )
Esempio n. 6
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)
def load_song(data, offset, settings):
    page_num = scribus.pageCount()
    page_width, page_height, margin_top, margin_left, margin_right, margin_bottom = page_size_margin(page_num)
    start_point = margin_top + offset

    new_width = page_width - margin_left - margin_right
    if not FAST:
        scribus.placeEPS(os.path.join(FILES, data["filename"]), 0, 0)
        eps = scribus.getSelectedObject()
        eps_width, eps_height = scribus.getSize(eps)
        #scribus.scaleGroup(new_width/eps_width) # slow on scribus 1.4; does something else on scribus 1.5
        scribus.sizeObject(eps_width*0.86, eps_height*0.86, eps)
        scribus.moveObjectAbs(margin_left, start_point+SPACING_HEADLINE_SONG, eps)
        eps_width, eps_height = scribus.getSize(eps)
    else:
        eps_height = 0

    scribus.deselectAll()
    textbox = scribus.createText(margin_left, start_point, new_width, 20)

    style_suffix = get_style_suffix()

    if data["composer"]:
        scribus.deselectAll()
        scribus.insertText(u"{}\n".format(data["composer"]), 0, textbox)
        scribus.selectText(0, 1, textbox)
        scribus.setStyle("subline_{}".format(style_suffix), textbox)

    if data["poet"]:
        scribus.deselectAll()
        scribus.insertText(u"{}\n".format(data["poet"]), 0, textbox)
        scribus.selectText(0, 1, textbox)
        scribus.setStyle("subline_{}".format(style_suffix), textbox)

    scribus.deselectAll()
    scribus.insertText(u"{}\n".format(data["name"]), 0, textbox)
    scribus.selectText(0, 1, textbox)
    scribus.setStyle("headline_{}".format(style_suffix), textbox)

    text = data["text"]
    text = [t.strip() for t in text if t.strip() != ""]

    # TODO: exit if text == []

    textbox = scribus.createText(margin_left, start_point + eps_height + SPACING_HEADLINE_SONG + SPACING_SONG_TEXT, new_width, 50)
    scribus.setStyle("text", textbox)
    # let's see how many digits are in there:
    num_verses = len([l for l in text if l.isdigit()])
    num_chars = 0
    num_line_total = len(text)
    num_line_actually = 0
    no_new_line = False
    verse_counter = 0
    text_columns_height = 0 # TODO: should be None
    for num_line, line in enumerate(text):
        if line.strip == "":
            continue
        num_line_actually += 1
        if line.isdigit():

            print "#", verse_counter, math.ceil(num_verses * 0.5), num_verses, data["filename"]
            if verse_counter == math.ceil(num_verses*0.5): # this is the first verse that should be in the new column, so let's see what's the height
                print text_columns_height, num_line_actually
                text_columns_height = BASELINE_GRID * (num_line_actually -1)

            first_char = "\n"
            if num_line == 0:
                first_char = ""
            no_new_line = True
            line = u"{}{}.\t".format(first_char, line)
            scribus.insertText(line, -1, textbox)
            scribus.deselectAll()
            scribus.selectText(num_chars, len(line), textbox)
            #scribus.setStyle("num", textbox) # no character styles available
            #scribus.setFontSize(5, textbox)  # TODO: testing only # BUG?
            scribus.setFont("Linux Libertine O Bold", textbox)
            num_chars += len(line)
            verse_counter += 1
        else:
            if no_new_line:
                first_char = ""
            else:
                first_char = chr(28)
            no_new_line = False
            line = u"{}{}".format(first_char, line)
            scribus.insertText(line, -1, textbox)
            #scribus.deselectAll()
            #scribus.selectText(num_chars, len(line), textbox)
            #scribus.setStyle("text", textbox)
            num_chars += len(line)

    scribus.setColumnGap(5, textbox)
    columns = settings.get("columns", 2)
    scribus.setColumns(columns, textbox)
    if columns != 2:
        fit_height(textbox)
    else:
        scribus.sizeObject(new_width, text_columns_height, textbox)
        l, t = scribus.getPosition(textbox)
        scribus.moveObjectAbs(l, round(t/BASELINE_GRID)*BASELINE_GRID, textbox)
        if scribus.textOverflows(textbox):
            fit_height(textbox) # there are some cases,.. 
    text_width, text_height = scribus.getSize(textbox)
    text_left, text_top = scribus.getPosition(textbox)
    return text_top + text_height - start_point + SPACING_SONGS, page_num
Esempio n. 8
0
rightX, rightY = scribus.getPosition(rightSpineMarker)
curSpineWidth = rightX - leftX - leftOffset - rightOffset

spineWidthDiff = newWidth - curSpineWidth
halfWidthDiff = spineWidthDiff / 2 

vGuides = [(PageX/2), (PageX/2 + newWidth/2), (PageX/2 - newWidth/2)]
hGuides = []

for item in pageItems:
	if item[0].startswith('spine_background'):
		X,Y = scribus.getPosition(item[0])
		hasSpineBackground = True
		Xsize,Ysize = scribus.getSize(item[0])
		scribus.sizeObject(newWidth, Ysize, item[0])
		scribus.moveObjectAbs(PageX/2 - newWidth/2, Y ,item[0])
	
for item in pageItems:
	X,Y = scribus.getPosition(item[0])
	if item[0].startswith('background'):
		scribus.moveObject(-halfWidthDiff, 0 , item[0])
		Xsize,Ysize = scribus.getSize(item[0])
		backgroundSize = Xsize + spineWidthDiff 
		scribus.sizeObject(backgroundSize, Ysize, item[0])
	if item[0].startswith('left_'):
		scribus.moveObject(-halfWidthDiff, 0 , item[0])
		if item[0].startswith('left_background'):
			Xsize,Ysize = scribus.getSize(item[0])
			leftBackgroundSize = PageX/2 - X + halfWidthDiff + 0.05 
			if hasSpineBackground:
				leftBackgroundSize -=  newWidth/2
def main(argv):
    unit = scribus.getUnit()
    units = ['pts','mm','inches','picas','cm','ciceros']
    unitlabel = units[unit]
    
# get page size
    pagesize = scribus.getPageSize()

    
# ask for layout style
    layout_style = scribus.valueDialog("Select Mirror", layout_text, "v")
    if layout_style == "":
        sys.exit()

        

# v = vertical mirror
    if layout_style == "v":            
        # warn and exit if no selection
        if scribus.selectionCount() == 0:
            scribus.messageBox("Error", "Select an object first!", icon=scribus.ICON_WARNING)
            sys.exit()
        
        #create mirror guides
        scribus.setVGuides(scribus.getHGuides() + [pagesize[0]/2])
        
        #get selected object
        selection_name = scribus.getSelectedObject(0)
        objectpos = scribus.getPosition(selection_name)
        objectsize = scribus.getSize(selection_name)
        
        #duplicate object
        scribus.duplicateObject(selection_name)
        
        #move object
        newobjectpos = (pagesize[0] - (objectpos[0] + objectsize[0]) , objectpos[1])
        scribus.moveObjectAbs(newobjectpos[0], objectpos[1], selection_name)
        
        #flip object
        scribus.flipObject(1,0,selection_name)

        

# h = horizontal mirror
    if layout_style == "h":            
        # warn and exit if no selection
        if scribus.selectionCount() == 0:
            scribus.messageBox("Error", "Select an object first!", icon=scribus.ICON_WARNING)
            sys.exit()
        
        #create mirror guides
        scribus.setHGuides(scribus.getHGuides() + [pagesize[1]/2])
        
        #get selected object
        selection_name = scribus.getSelectedObject(0)
        objectpos = scribus.getPosition(selection_name)
        objectsize = scribus.getSize(selection_name)
        
        #duplicate object
        scribus.duplicateObject(selection_name)
        
        #move object
        newobjectpos = (objectpos[0] , pagesize[1] - (objectpos[1] + objectsize[1]))
        scribus.moveObjectAbs(objectpos[0], newobjectpos[1], selection_name)
        
        #flip object
        scribus.flipObject(0,1,selection_name)
def main(argv):

    scribus.setUnit(scribus.UNIT_MILLIMETERS)

    # get page size and page count
    pagesize = scribus.getPageSize()
    pagenum = scribus.pageCount()

    #create on page
    selectedpage = scribus.valueDialog(
        "Select page", "Create arrows and annotation links on page (1-" +
        str(pagenum) + ") :", "1")

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

    #progressbar max
    scribus.progressTotal(pagenum)

    arrowinitxpos = 10
    arrowinitypos = 30

    scribus.gotoPage(int(selectedpage))

    page = 1
    ###########################################

    for i in range(pagenum):
        # create rectangle
        #exitrect = scribus.createRect(arrowinitxpos, 50, 30, 30, "exitrect")

        #messagebar text
        scribus.messagebarText(
            "Creating arrows and annotation links on page " + selectedpage +
            "...")

        #progress bar
        scribus.progressSet(page)

        #create and distribute arrow
        arrowpoly = [
            10, 30, 30, 10, 50, 30, 40, 30, 40, 50, 20, 50, 20, 30, 10, 30
        ]
        arrowup = scribus.createPolygon(arrowpoly)
        scribus.sizeObject(10, 10, arrowup)
        scribus.moveObjectAbs(arrowinitxpos, arrowinitypos, arrowup)
        scribus.setFillColor("White", arrowup)

        #create and distribute links
        arrowlink = scribus.createText(arrowinitxpos, arrowinitypos + 11, 10,
                                       10, "link_to_page_" + str(page))
        #setLinkAnnotation(page,x,y,["name"])
        scribus.setLinkAnnotation(int(page), 0, 0, arrowlink)

        arrowinitxpos += 11

        if arrowinitxpos > 250:
            arrowinitypos += 24
            arrowinitxpos = 10

        # add page number to iteration
        page += 1