示例#1
0
 def expandFrame(self):
    """Text is inserted into a frame without regard to frame size.
       Later we expand the frame to fit the text, carrying text to
       a new frame if necessary."""
    numcarries = 0
    self.raiseImages()
    if self.frame != None:
       while scribus.textOverflows(self.frame,) > 0:
          (x,y) = scribus.getPosition(self.frame)
          (width,height) = scribus.getSize(self.frame)
          if y + height < self.pageheight - self.bottommargin:
             scribus.sizeObject(width, height + 1, self.frame)
          else:
             fullpage = (y <= self.topmargin and self.columns == 1)
             if self.buffer != [] and not self.framelinked and numcarries < 4 and not fullpage:
                numcarries = numcarries + 1
                scribus.deselectAll()
                scribus.deleteText(self.frame)
                for (content,style) in self.contents:
                   self.styleText(content,style,self.frame)
                newcontents = self.buffer[:]
                self.newFrame(columns=self.columns)
                for (content,style) in newcontents:
                   self.styleText(content,style,self.frame)
                self.buffer = newcontents[:]
             else:
                lastframe = self.frame
                self.newFrame(columns=self.columns)
                scribus.linkTextFrames(lastframe,self.frame)
                self.framelinked = True
          self.raiseImages()
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
示例#3
0
 def expandFrame(self):
     """Text is inserted into a frame without regard to frame size.
      Later we expand the frame to fit the text, carrying text to
      a new frame if necessary."""
     numcarries = 0
     self.raiseImages()
     if self.frame != None:
         while scribus.textOverflows(self.frame, ) > 0:
             (x, y) = scribus.getPosition(self.frame)
             (width, height) = scribus.getSize(self.frame)
             if y + height < self.pageheight - self.bottommargin:
                 scribus.sizeObject(width, height + 1, self.frame)
             else:
                 fullpage = (y <= self.topmargin and self.columns == 1)
                 if self.buffer != [] and not self.framelinked and numcarries < 4 and not fullpage:
                     numcarries = numcarries + 1
                     scribus.deselectAll()
                     scribus.deleteText(self.frame)
                     for (content, style) in self.contents:
                         self.styleText(content, style, self.frame)
                     newcontents = self.buffer[:]
                     self.newFrame(columns=self.columns)
                     for (content, style) in newcontents:
                         self.styleText(content, style, self.frame)
                     self.buffer = newcontents[:]
                 else:
                     lastframe = self.frame
                     self.newFrame(columns=self.columns)
                     scribus.linkTextFrames(lastframe, self.frame)
                     self.framelinked = True
             self.raiseImages()
示例#4
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
示例#5
0
 def pasteCaption(self, xpos, ypos, text, width, imgheight=0, footer=False):
     height = 5
     rect = scribus.createRect(xpos, ypos, width, height)
     scribus.setFillColor("Black", rect)
     scribus.setFillTransparency(0.60, rect)
     scribus.setCornerRadius(ROUNDS, rect)
     scribus.setLineColor("White", rect)
     scribus.setLineWidth(0.4, rect)
     frame = scribus.createText(xpos + 2, ypos + 1, width, height)
     self.styleText(text, "imageCaption", frame)
     scribus.setTextColor("White", frame)
     scribus.setFillColor("None", frame)
     # there are probably some performance issues in the following section of code
     if scribus.textOverflows(frame) == 0:
         # its a one liner, so shrink width
         while scribus.textOverflows(frame) == 0 and width > 5:
             width = width - 1
             scribus.sizeObject(width, height, frame)
         scribus.sizeObject(width + 2, height, frame)
         scribus.sizeObject(width + 4, height, rect)
     else:
         # its a multi liner, expand vertically
         while scribus.textOverflows(frame) > 0:
             height = height + 1
             scribus.sizeObject(width, height, frame)
         scribus.sizeObject(width, height + 1, rect)
     if footer:
         scribus.moveObject(0, imgheight - height - 1, rect)
         scribus.moveObject(0, imgheight - height - 1, frame)
     self.imageframes.append(rect)
     self.imageframes.append(frame)
示例#6
0
 def pasteCaption(self, xpos, ypos, text, width, imgheight=0, footer=False):
    height = 5 
    rect = scribus.createRect(xpos, ypos, width, height)
    scribus.setFillColor("Black",rect)
    scribus.setFillTransparency(0.60,rect)
    scribus.setCornerRadius(ROUNDS,rect)
    scribus.setLineColor("White",rect)
    scribus.setLineWidth(0.4,rect)
    frame = scribus.createText(xpos+2, ypos+1, width, height)
    self.styleText(text, "imageCaption", frame)
    scribus.setTextColor("White",frame)
    scribus.setFillColor("None",frame)
    # there are probably some performance issues in the following section of code
    if scribus.textOverflows(frame) == 0:
       # its a one liner, so shrink width
       while scribus.textOverflows(frame) == 0 and width > 5:
          width = width - 1
          scribus.sizeObject(width, height, frame)
       scribus.sizeObject(width+2, height, frame)
       scribus.sizeObject(width+4, height, rect)
    else:
       # its a multi liner, expand vertically
       while scribus.textOverflows(frame) > 0:
          height = height + 1
          scribus.sizeObject(width, height, frame)
       scribus.sizeObject(width, height+1, rect)
    if footer:
       scribus.moveObject(0,imgheight - height - 1,rect)
       scribus.moveObject(0,imgheight - height - 1,frame)
    self.imageframes.append(rect)
    self.imageframes.append(frame)
示例#7
0
    def placeGuide(self, rock, sun, walk, graph, iconpath):
        """Build the header section of a guide"""
        if self.frame != None:
            (w, h) = scribus.getSize(self.frame)
            scribus.sizeObject(w, h + HEADERSIZE, self.frame)

            if os.path.exists(graph):
                img = scribus.createImage(self.leftmargin + 5,
                                          self.topmargin + 10, GRAPHSIZE,
                                          GRAPHSIZE)
                scribus.loadImage(graph, img)
                scribus.setScaleImageToFrame(True, True, img)

            offset = 13
            iconleft = self.leftmargin + 10 + GRAPHSIZE + 3
            txtleft = iconleft + ICONSIZE + 3
            framewidth = self.pagewidth - self.leftmargin - self.rightmargin
            if sun != "":
                img = scribus.createImage(iconleft, self.topmargin + offset,
                                          ICONSIZE, ICONSIZE)
                scribus.loadImage(iconpath + os.sep + "sun1.png", img)
                scribus.setScaleImageToFrame(True, True, img)
                #scribus.setCornerRadius(ROUNDS,img)
                icontxtframe = scribus.createText(txtleft,
                                                  self.topmargin + offset + 2,
                                                  framewidth - txtleft,
                                                  ICONSIZE)
                self.styleText(sun, "IconText", icontxtframe)
                offset = offset + ICONSIZE + 3

            if walk != "":
                img = scribus.createImage(iconleft, self.topmargin + offset,
                                          ICONSIZE, ICONSIZE)
                scribus.loadImage(iconpath + os.sep + "walk1.png", img)
                scribus.setScaleImageToFrame(True, True, img)
                #scribus.setCornerRadius(ROUNDS,img)
                icontxtframe = scribus.createText(txtleft,
                                                  self.topmargin + offset + 2,
                                                  framewidth - txtleft,
                                                  ICONSIZE)
                self.styleText(walk, "IconText", icontxtframe)
                offset = offset + ICONSIZE + 3

            if rock != "":
                img = scribus.createImage(iconleft, self.topmargin + offset,
                                          ICONSIZE, ICONSIZE)
                scribus.loadImage(iconpath + os.sep + "rock1.png", img)
                scribus.setScaleImageToFrame(True, True, img)
                #scribus.setCornerRadius(ROUNDS,img)
                icontxtframe = scribus.createText(txtleft,
                                                  self.topmargin + offset + 2,
                                                  framewidth - txtleft,
                                                  ICONSIZE)
                self.styleText(rock, "IconText", icontxtframe)
                offset = offset + ICONSIZE + 3
        self.endFrame()
示例#8
0
    def resizeFrame(self, frame):
        '''Resize a frame in place so that it fits the text inside it.
		Code for this was take from:
		http://wiki.scribus.net/canvas/Adjust_a_text_frame_to_fit_its_content'''

        # Now adjust the frame to fit the text
        # get some page and frame measure
        (x, ph) = scribus.getPageSize()
        (x, x, x, pm) = scribus.getPageMargins()
        # warning: gets the margins from document setup not for the current page
        (x, y) = scribus.getPosition(frame)
        bottom = (ph - pm) - y
        (w, h) = scribus.getSize(frame)
        # if the frame doesn't overflow, shorten it to make it overflow
        while (((scribus.textOverflows(frame) == 0) or (h > bottom))
               and (h > 0)):
            h -= 10
            scribus.sizeObject(w, h, frame)
        # resize the frame in 10pt steps
        while ((scribus.textOverflows(frame) > 0) and (h < bottom)):
            h += 10
            scribus.sizeObject(w, h, frame)
        # undo the latest 10pt step and fine adjust in 1pt steps
        h -= 10
        scribus.sizeObject(w, h, frame)
        while ((scribus.textOverflows(frame) > 0) and (h < bottom)):
            h += 1
            scribus.sizeObject(w, h, frame)

        # For vertical sizing operations return the frame height
        return int(scribus.getSize(frame)[1])
示例#9
0
    def resizeFrame (self, frame) :
        '''Resize a frame in place so that it fits the text inside it.
        Code for this was take from: 
        http://wiki.scribus.net/canvas/Adjust_a_text_frame_to_fit_its_content'''

        # Now adjust the frame to fit the text
        # get some page and frame measure
        (x, ph) = scribus.getPageSize();
        (x, x, x, pm) = scribus.getPageMargins(); # warning: gets the margins from document setup not for the current page
        (x, y) = scribus.getPosition(frame)
        bottom = (ph - pm) - y
        (w, h) = scribus.getSize(frame)
        # if the frame doesn't overflow, shorten it to make it overflow
        while (((scribus.textOverflows(frame) == 0) or (h > bottom)) and (h > 0)) :
            h -= 10
            scribus.sizeObject(w, h, frame)
        # resize the frame in 10pt steps
        while ((scribus.textOverflows(frame) > 0) and (h < bottom)) :
            h += 10
            scribus.sizeObject(w, h, frame)
        # undo the latest 10pt step and fine adjust in 1pt steps
        h -= 10
        scribus.sizeObject(w, h, frame)
        while ((scribus.textOverflows(frame) > 0) and (h < bottom)) :
            h += 1
            scribus.sizeObject(w, h, frame)

        # For vertical sizing operations return the frame height
        return int(scribus.getSize(frame)[1])
示例#10
0
 def placeGuide(self, rock, sun, walk, graph, iconpath):
    """Build the header section of a guide"""
    if self.frame != None:
       (w,h) = scribus.getSize(self.frame)
       scribus.sizeObject(w, h + HEADERSIZE, self.frame)
          
       if os.path.exists(graph):
          img = scribus.createImage(self.leftmargin + 5, self.topmargin + 10, GRAPHSIZE, GRAPHSIZE)
          scribus.loadImage(graph, img)
          scribus.setScaleImageToFrame(True,True,img)    
                   
       offset = 13
       iconleft = self.leftmargin + 10 + GRAPHSIZE + 3
       txtleft = iconleft + ICONSIZE + 3
       framewidth = self.pagewidth - self.leftmargin - self.rightmargin
       if sun != "":
          img = scribus.createImage(iconleft, self.topmargin + offset, ICONSIZE, ICONSIZE)
          scribus.loadImage(iconpath + os.sep + "sun1.png", img)
          scribus.setScaleImageToFrame(True,True,img)
          #scribus.setCornerRadius(ROUNDS,img)
          icontxtframe = scribus.createText(txtleft, self.topmargin + offset + 2, framewidth - txtleft, ICONSIZE)
          self.styleText(sun, "IconText", icontxtframe)
          offset = offset + ICONSIZE + 3
             
       if walk != "":
          img = scribus.createImage(iconleft, self.topmargin + offset, ICONSIZE, ICONSIZE)
          scribus.loadImage(iconpath + os.sep + "walk1.png", img)
          scribus.setScaleImageToFrame(True,True,img)    
          #scribus.setCornerRadius(ROUNDS,img)
          icontxtframe = scribus.createText(txtleft, self.topmargin + offset + 2, framewidth - txtleft, ICONSIZE)
          self.styleText(walk, "IconText", icontxtframe)
          offset = offset + ICONSIZE + 3
                
       if rock != "":
          img = scribus.createImage(iconleft, self.topmargin + offset, ICONSIZE, ICONSIZE)
          scribus.loadImage(iconpath + os.sep + "rock1.png", img)
          scribus.setScaleImageToFrame(True,True,img)    
          #scribus.setCornerRadius(ROUNDS,img)
          icontxtframe = scribus.createText(txtleft, self.topmargin + offset + 2, framewidth - txtleft, ICONSIZE)
          self.styleText(rock, "IconText", icontxtframe)
          offset = offset + ICONSIZE + 3
    self.endFrame()
示例#11
0
    def slotOkClicked(self):
        global CWD

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

        DPI = 600.0
        os.chdir(CWD)

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

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

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

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

        scribus.setUnit(scribus.UNIT_MILLIMETERS)
        scribus.loadImage(img_file, img)
        scribus.setScaleImageToFrame(True, True, img)
        x, y = scribus.getPosition(img)
        scribus.sizeObject(x + w*25.4/DPI, y + h*25.4/DPI, img)
        
        self.accept()
def fit_height(textbox):
    # come to a state that the text box does not overflow:
    width, height = scribus.getSize(textbox)
    to_add = height + 1
    while scribus.textOverflows(textbox):
        scribus.sizeObject(width, height + to_add, textbox)
        to_add = to_add * 2

    # reduce height
    step = height / 2
    overflows = False
    counter = 0
    while step > 0.05 or overflows:
        counter += 1
        width, old_height = scribus.getSize(textbox)
        if scribus.textOverflows(textbox):
            scribus.sizeObject(width, old_height + step, textbox)
        else:
            scribus.sizeObject(width, old_height - step, textbox)
            step = step * 0.5
        overflows = scribus.textOverflows(textbox)
def fit_height(textbox):
    # come to a state that the text box does not overflow:
    width, height = scribus.getSize(textbox)
    to_add = height + 1
    while scribus.textOverflows(textbox):
        scribus.sizeObject(width, height + to_add, textbox)
        to_add = to_add * 2

    # reduce height
    step = height/2
    overflows = False
    counter = 0
    while step > 0.05 or overflows:
        counter += 1
        width, old_height = scribus.getSize(textbox)
        if scribus.textOverflows(textbox):
            scribus.sizeObject(width, old_height + step, textbox)
        else:
            scribus.sizeObject(width, old_height - step, textbox)
            step = step * 0.5
        overflows = scribus.textOverflows(textbox)
# get some page and frame measure

(x, y) = scribus.getPosition(frame)

(w, h) = scribus.getSize(frame)

original_height = h

(dl, dr, dt, db) = scribus.getTextDistances();

scribus.setTextDistances(dl, dr, 0, 0);

# if the frame doesn't overflow, shorten it to make it overflow
while ((scribus.textOverflows(frame) == 0) and (h > 0)) :
    h -= 10
    scribus.sizeObject(w, h, frame)

# resize the frame in 10pt steps
while (scribus.textOverflows(frame) > 0) :
    h += 10
    scribus.sizeObject(w, h, frame)

# undo the latest 10pt step and fine adjust in 1pt steps
h -= 10
scribus.sizeObject(w, h, frame)

while (scribus.textOverflows(frame) > 0) :
    h += 1
    scribus.sizeObject(w, h, frame)

示例#15
0
leftX, leftY = scribus.getPosition(leftSpineMarker)
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:
def main(argv):
    userdim = scribus.getUnit()  # get unit and change it to mm
    scribus.setUnit(scribus.UNIT_MILLIMETERS)
    cellwidthleft = 0
    cellwidthright = 0
    # Set starting position
    hposition = 28
    vposition = 20
    data = getCSVdata()
    di = getDataInformation(data)
    ncol = len(data[0])
    nrow = len(data)
    scribus.messageBox("Table", "   " + str(ncol) + " columns,    " +
                       str(nrow) + " rows   ")  #jpg
    ColWidthList = []
    TableWidth = 0
    RowHeightList = []
    TableHeight = 0
    i = 0
    for row in data:
        if i == 0:
            c = 0
            for cell in row:
                ColWidth = 40
                ColWidthList.append(ColWidth)
        TableWidth = TableWidth + ColWidth
        c = c + 1
        RowHeight = 15
        RowHeightList.append(RowHeight)
        TableHeight = TableHeight + RowHeight
        i = i + 1
    objectlist = [
    ]  # here we keep a record of all the created textboxes so we can group them later
    i = 0
    scribus.progressTotal(len(data))
    scribus.setRedraw(False)
    rowindex = 0
    new_row_indication = 1
    new_page_indication = 1
    firstorigin_indicator = 1
    while rowindex < len(data):
        c = 0
        origin_cd = data[rowindex][0].strip()
        origin = data[rowindex][1].strip()
        origin_complete = origin + ' (' + origin_cd + ")"
        headerorigin = origin_complete
        origin_added = 0
        destination_cd = data[rowindex][2].strip()
        destination = data[rowindex][3].strip()
        destination_complete = destination + ' (' + destination_cd + ")"
        fareplan = data[rowindex][4].strip()
        fareplan_type = data[rowindex][5].strip()
        fareplan_complete = fareplan + ' ' + fareplan_type[:1]
        fare = data[rowindex][6].strip()
        fare = float(fare)
        fare = "{0:.2f}".format(fare)
        fare_onboard = data[rowindex][7].strip()
        fare_onboard = float(fare_onboard)
        fare_onboard = "{0:.2f}".format(fare_onboard)
        cellheight_market = 5
        cellheight_market_dos = 5

        try:
            last_origin = data[rowindex - 1][1].strip()
        except:
            last_origin = origin

        try:
            last_destination = data[rowindex - 1][3].strip()
        except:
            last_destination = destination

        cellsize = ColWidthList[c]
        cellHeight = RowHeightList[i]

        # Check to see if near bottom of the page, if so wrap it over
        if (vposition > 227):
            hposition = hposition + cellsize
            vposition = 20
            new_row_indication = 1
        # If at end, reset and create new page
        if (hposition > 174):
            scribus.newPage(-1)
            hposition = 28
            vposition = 20
            new_page_indication = 1
            firstorigin_indicator = 0

        if new_row_indication == 1:
            textbox = scribus.createText(hposition, 16, cellsize / 2,
                                         4)  # create a textbox.
            objectlist.append(textbox)
            scribus.setStyle('FareplanHeader', textbox)
            scribus.insertText('Fareplan', 0, textbox)
            c = c + 1

            textbox = scribus.createText(hposition + (cellsize / 2), 16,
                                         cellsize / 2, 4)  # create a textbox.
            objectlist.append(textbox)
            scribus.setStyle('FareplanHeader', textbox)
            scribus.insertText('Amount', 0, textbox)
            c = c + 1


#			if (firstorigin_indicator == 1):
#				headerorigin = origin_complete
#				textbox = scribus.createText(20, 10, cellsize*4, 4) # create a textbox.
#				objectlist.append(textbox)
#				scribus.setStyle('HeaderOrigin', textbox)
#				scribus.insertText(headerorigin, 0, textbox)
#				c = c + 1

# Origin textbox
        if (rowindex < len(data)):
            if ((origin != last_origin) or (rowindex == 0)):
                # Add 'btwn' text
                textbox = scribus.createText(hposition, vposition, cellsize,
                                             4)  # create a textbox.
                objectlist.append(textbox)
                scribus.setStyle(
                    'Headings', textbox
                )  # set it in the style 'Headings' as defined in Scribus.
                scribus.insertText(
                    'btwn', 0, textbox)  # insert the origin into the textbox.
                # scribus.setDistances(1,1,1,1) # set the distances.
                vposition = vposition + 4  # Shift position of cell down.
                c = c + 1

                textbox = scribus.createText(
                    hposition, vposition, cellsize,
                    cellheight_market_dos)  # create a textbox.
                objectlist.append(textbox)
                scribus.setStyle(
                    'Headings', textbox
                )  # set it in the style 'Headings' as defined in Scribus.
                scribus.insertText(
                    origin_complete, 0,
                    textbox)  # insert the origin into the textbox.
                while (scribus.textOverflows(textbox) > 0):
                    cellheight_market_dos += 1
                    scribus.sizeObject(cellsize, cellheight_market_dos,
                                       textbox)
                vposition = vposition + cellheight_market_dos  # Shift position of cell down.
                c = c + 1

                # Add 'and' text
                textbox = scribus.createText(hposition, vposition, cellsize,
                                             4)  # create a textbox.
                objectlist.append(textbox)
                scribus.setStyle(
                    'andStyle', textbox
                )  # set it in the style 'andStyle' as defined in Scribus.
                scribus.insertText(
                    'and', 0, textbox)  # insert the origin into the textbox.
                vposition = vposition + 4  # Shift position of cell down.
                c = c + 1

                origin_added = 1
                firstorigin_indicator = firstorigin_indicator + 1

                # Insert the origin at the top margin
                if (firstorigin_indicator == 1 or rowindex == 0):
                    headerorigin = origin_complete
                    textbox = scribus.createText(28, 10, cellsize * 4,
                                                 4)  # create a textbox.
                    objectlist.append(textbox)
                    scribus.setStyle('HeaderOrigin', textbox)
                    scribus.insertText(headerorigin, 0, textbox)
                    c = c + 1

        # Destination textbox
        if ((destination != last_destination) or (rowindex == 0)
                or (origin_added == 1)):
            textbox = scribus.createText(
                hposition, vposition, cellsize,
                cellheight_market)  # create a textbox.
            objectlist.append(textbox)
            scribus.setStyle(
                'Headings', textbox
            )  # set it in the style 'Headings' as defined in Scribus.
            scribus.insertText(
                destination_complete, 0,
                textbox)  # insert the destination into the textbox.
            while (scribus.textOverflows(textbox) > 0):
                cellheight_market += 1
                scribus.sizeObject(cellsize, cellheight_market, textbox)

            vposition = vposition + cellheight_market  # Shift position of cell down.
            c = c + 1
        rowindex = rowindex + 1

        # Fareplan textbox
        fareplan_box_height = 5
        if fare_onboard != '0.00':
            fareplan_box_height = 10
        textbox = scribus.createText(hposition, vposition, cellsize / 2,
                                     fareplan_box_height)  # create a textbox.
        objectlist.append(textbox)
        scribus.insertText(fareplan_complete, 0,
                           textbox)  # insert the fareplan into the textbox.
        hposition = hposition + (cellsize / 2)  # Shift position of cell right.
        c = c + 1

        # Fare textbox
        textbox = scribus.createText(hposition, vposition, cellsize / 2,
                                     5)  # create a textbox.
        objectlist.append(textbox)
        scribus.insertText(fare, 0,
                           textbox)  # insert the fare into the textbox.
        c = c + 1

        if fare_onboard != '0.00':
            vposition = vposition + 5  # Shift position of cell down.
            textbox = scribus.createText(hposition, vposition, cellsize / 2,
                                         5)  # create a textbox.
            objectlist.append(textbox)
            scribus.setStyle('OnBoard', textbox)
            scribus.insertText(fare_onboard, 0,
                               textbox)  # insert the fare into the textbox.
            hposition = hposition - (cellsize / 2
                                     )  # Shift position of cell back.
            vposition = vposition + 5  # Shift position of cell down.
            c = c + 1
        else:
            hposition = hposition - (cellsize / 2
                                     )  # Shift position of cell back.
            vposition = vposition + 5  # Shift position of cell down.
        i = i + 1
        new_row_indication = 0
        new_page_indication = 0

    scribus.deselectAll()
    scribus.groupObjects(objectlist)
    scribus.progressReset()
    scribus.setUnit(userdim)  # reset unit to previous value
    scribus.docChanged(True)
    scribus.statusMessage("Done")
    scribus.setRedraw(True)
示例#17
0
def main(argv):
    unit = scribus.getUnit()
    units = [' pts', 'mm', ' inches', ' picas', 'cm', ' ciceros']
    unitlabel = units[unit]
    if scribus.selectionCount() == 0:
        scribus.messageBox(
            'Scribus - Script Error',
            "There is no object selected.\nPlease select a text frame and try again.",
            scribus.ICON_WARNING, scribus.BUTTON_OK)
        sys.exit(2)
    if scribus.selectionCount() > 1:
        scribus.messageBox(
            'Scribus - Script Error',
            "You have more than one object selected.\nPlease select one text frame and try again.",
            scribus.ICON_WARNING, scribus.BUTTON_OK)
        sys.exit(2)
    textbox = scribus.getSelectedObject()
    pageitems = scribus.getPageItems()
    boxcount = 1
    for item in pageitems:
        if (item[0] == textbox):
            if (item[1] != 4):
                scribus.messageBox('Scribus - Script Error',
                                   "This is not a textframe. Try again.",
                                   scribus.ICON_WARNING, scribus.BUTTON_OK)
                sys.exit(2)


# While we're finding out what kind of frame is selected, we'll also make sure we
# will come up with a unique name for our infobox frame - it's possible we may want
# more than one for a multicolumn frame.
        if (item[0] == ("infobox" + str(boxcount) + textbox)):
            boxcount += 1
    left, top = scribus.getPosition(textbox)
    o_width, o_height = scribus.getSize(textbox)
    o_cols = int(scribus.getColumns(textbox))
    o_gap = scribus.getColumnGap(textbox)

    columns_width = 0
    column_pos = 0
    o_colwidth = (o_width - ((o_cols - 1) * o_gap)) / o_cols
    if (o_cols > 1):
        while (columns_width > o_cols or columns_width < 1):
            columns_width = scribus.valueDialog(
                'Width', 'How many columns width shall the ' + 'box be (max ' +
                str(o_cols) + ')?', '1')
            columns_width = int(columns_width)
        if (columns_width < o_cols):
            max = o_cols - columns_width
            while (column_pos <= max and column_pos <= 1):
                column_pos = scribus.valueDialog(
                    'Placement', 'In which column do you want '
                    'to place the box (1 to ' + str(o_cols) + ')?', '1')
            column_pos = int(column_pos) - 1
    if (o_cols == 1):
        columns_width = 1
    new_height = 0
    while (new_height <= 0):
        new_height = scribus.valueDialog(
            'Height', 'Your frame height is ' + str(o_height) + unitlabel +
            '. How tall\n do you want your ' + 'infobox to be in ' +
            unitlabel +
            '?\n If you load an image with the script, height will be\n calculated, so the value here will not\n matter in that case.',
            str(o_height))
        if (not new_height):
            sys.exit(0)
        new_height = float(new_height)
    new_top = -1
    while (new_top < 0):
        new_top = scribus.valueDialog(
            'Y-Pos',
            'The top of your infobox is currently\n' + str(top) + unitlabel +
            '. Where do you want \n' + 'the top to be in ' + unitlabel + '?',
            str(top))
        if (not new_top):
            sys.exit(0)
        new_top = float(new_top)
    framename = scribus.valueDialog(
        'Name of Frame', 'Name your frame or use this default name',
        "infobox" + str(boxcount) + textbox)
    if (not framename):
        sys.exit(0)
    frametype = 'text'
    frametype = scribus.valueDialog(
        'Frame Type',
        'Change to anything other\n than "text" for image frame.\nEnter "imageL" to also load an image',
        frametype)
    if (not frametype):
        sys.exit(0)
    new_width = columns_width * o_colwidth + (columns_width - 1) * o_gap
    new_left = left + ((column_pos) * o_colwidth) + ((column_pos) * o_gap)
    if (frametype == 'text'):
        new_textbox = scribus.createText(new_left, float(new_top), new_width,
                                         float(new_height), framename)
        scribus.setColumnGap(0, new_textbox)
        scribus.setColumns(1, new_textbox)
        scribus.textFlowMode(new_textbox, 1)
    else:
        if (frametype == 'imageL'):
            imageload = scribus.fileDialog(
                'Load image',
                'Images(*.jpg *.png *.tif *.JPG *.PNG *.jpeg *.JPEG *.TIF)',
                haspreview=1)
            new_image = scribus.createImage(new_left,
                                            float(new_top), new_width,
                                            float(new_height), framename)
            scribus.textFlowMode(new_image, 1)
            scribus.loadImage(imageload, new_image)
            scribus.setScaleImageToFrame(1, 0, new_image)
            currwidth, currheight = scribus.getSize(new_image)
            Xscale, Yscale = scribus.getImageScale(new_image)
            if (Xscale != Yscale):
                scribus.sizeObject(currwidth, currheight * Xscale / Yscale,
                                   new_image)
            scribus.setScaleImageToFrame(1, 1, new_image)
        else:
            new_image = scribus.createImage(new_left,
                                            float(new_top), new_width,
                                            float(new_height), framename)
            scribus.textFlowMode(new_image, 1)
            scribus.setScaleImageToFrame(1, 1, new_image)
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
filecontent = filecontent.replace('PTYPE="16"', 'PTYPE="4"')
# quick and dirty workaround for setting PRINTABLE attribute to 1 if not already set:
filecontent = filecontent.replace('CLIPEDIT="1" PWIDTH=',
                                  'CLIPEDIT="1" PRINTABLE="1" PWIDTH=')
filecontent = filecontent.replace('CLIPEDIT="0" PWIDTH=',
                                  'CLIPEDIT="0" PRINTABLE="1" PWIDTH=')
filecontent = re.sub(r"(<DefaultStyle[^>].*?>)", "", filecontent)
filecontent = re.sub(r"(<TableData[^>].*?>)", "", filecontent)
filecontent = re.sub(r"(<Cell [^>].*?>)", "", filecontent)

newfile = slafile.replace(".sla", "_1-4.sla")
if os.path.isfile(newfile):
    scribus.messageBox(
        "Error: The file already exists", "The file '" + newfile +
        "' already exists.\The script has stopped; Please rename the existing file."
    )
else:
    ofile = open(newfile, "w").write(filecontent)
    scribus.openDoc(newfile)

    anzahl = scribus.pageCount()

    for seite in range(1, anzahl + 1):
        scribus.gotoPage(seite)
        objects = scribus.getAllObjects()
        for x in objects:
            width, height = scribus.getSize(x)
            scribus.sizeObject(100, 100, x)
            scribus.sizeObject(width, height, x)
            scribus.setLineShade(100, x)
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
示例#21
0
文件: InfoBox.py 项目: luzpaz/scribus
def main(argv):
    unit = scribus.getUnit()
    units = [' pts','mm',' inches',' picas','cm',' ciceros']
    unitlabel = units[unit]
    if scribus.selectionCount() == 0:
        scribus.messageBox('Scribus - Script Error',
            "There is no object selected.\nPlease select a text frame and try again.",
            scribus.ICON_WARNING, scribus.BUTTON_OK)
        sys.exit(2)
    if scribus.selectionCount() > 1:
        scribus.messageBox('Scribus - Script Error',
            "You have more than one object selected.\nPlease select one text frame and try again.",
            scribus.ICON_WARNING, scribus.BUTTON_OK)
        sys.exit(2)
    textbox = scribus.getSelectedObject()
    pageitems = scribus.getPageItems()
    boxcount = 1
    for item in pageitems:
        if (item[0] == textbox):
            if (item[1] != 4):
                scribus.messageBox('Scribus - Script Error', 
                          "This is not a textframe. Try again.", scribus.ICON_WARNING, scribus.BUTTON_OK)
                sys.exit(2)

# While we're finding out what kind of frame is selected, we'll also make sure we
# will come up with a unique name for our infobox frame - it's possible we may want
# more than one for a multicolumn frame.
        if (item[0] == ("infobox" + str(boxcount) + textbox)):
                boxcount += 1
    left, top = scribus.getPosition(textbox)
    o_width, o_height = scribus.getSize(textbox)
    o_cols = int(scribus.getColumns(textbox))
    o_gap = scribus.getColumnGap(textbox)
            
    columns_width = 0
    column_pos = 0
    o_colwidth = (o_width - ((o_cols - 1) * o_gap)) / o_cols
    if (o_cols > 1):
        while (columns_width > o_cols or columns_width < 1):
            columns_width = scribus.valueDialog('Width',
                                            'How many columns width shall the '+
                                            'box be (max ' + str(o_cols) + ')?','1')
            columns_width = int(columns_width)
        if (columns_width < o_cols):
            max = o_cols - columns_width
            while (column_pos <= max and column_pos <= 1):
                column_pos = scribus.valueDialog('Placement',
                                         'In which column do you want '
                                         'to place the box (1 to ' +
                                         str(o_cols) + ')?','1')
            column_pos = int(column_pos) - 1 
    if (o_cols == 1):
	columns_width = 1
    new_height = 0
    while (new_height <= 0):
        new_height = scribus.valueDialog('Height','Your frame height is '+ str(o_height) +
                                                 unitlabel +'. How tall\n do you want your ' +
                                                 'infobox to be in '+ unitlabel +'?\n If you load an image with the script, height will be\n calculated, so the value here will not\n matter in that case.', str(o_height))
        if (not new_height) :
            sys.exit(0)
        new_height = float(new_height)
    new_top = -1
    while (new_top < 0):
        new_top = scribus.valueDialog('Y-Pos','The top of your infobox is currently\n'+ str(top) +
                                                 unitlabel +'. Where do you want \n' +
                                                 'the top to be in '+ unitlabel +'?', str(top))
        if (not new_top) :
            sys.exit(0)
        new_top = float(new_top)
    framename = scribus.valueDialog('Name of Frame','Name your frame or use this default name',"infobox" + str(boxcount) + textbox)
    if (not framename) :
        sys.exit(0)
    frametype = 'text'
    frametype = scribus.valueDialog('Frame Type','Change to anything other\n than "text" for image frame.\nEnter "imageL" to also load an image',frametype)
    if (not frametype) :
        sys.exit(0)
    new_width = columns_width * o_colwidth + (columns_width-1) * o_gap
    new_left = left + ((column_pos) * o_colwidth) + ((column_pos) * o_gap)
    if (frametype == 'text'):
        new_textbox = scribus.createText(new_left, float(new_top), new_width, float(new_height),framename)
        scribus.setColumnGap(0, new_textbox)
        scribus.setColumns(1, new_textbox)
        scribus.textFlowMode(new_textbox, 1)
    else:
        if (frametype == 'imageL'):
            imageload = scribus.fileDialog('Load image','Images(*.jpg *.png *.tif *.JPG *.PNG *.jpeg *.JPEG *.TIF)',haspreview=1)
            new_image = scribus.createImage(new_left, float(new_top), new_width, float(new_height),framename)
            scribus.textFlowMode(new_image, 1)
            scribus.loadImage(imageload, new_image)
            scribus.setScaleImageToFrame(1,0,new_image)
            currwidth, currheight = scribus.getSize(new_image)
            Xscale, Yscale = scribus.getImageScale(new_image)
            if (Xscale != Yscale):
                scribus.sizeObject(currwidth, currheight*Xscale/Yscale, new_image)
            scribus.setScaleImageToFrame(1,1,new_image)
        else:
            new_image = scribus.createImage(new_left, float(new_top), new_width, float(new_height),framename)
            scribus.textFlowMode(new_image, 1)
            scribus.setScaleImageToFrame(1,1,new_image)
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