Beispiel #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()
Beispiel #2
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])
Beispiel #3
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])
Beispiel #4
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)
Beispiel #5
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()
Beispiel #6
0
   def newFrame(self, height=MINFRAMESIZE, columns=2):
      """Start a new text frame.
         If we are working with 2 columns, we build each column as a seperate frame.
         Scribus does support multi column text frames, but with no keep-with-next
         functionality its of no use."""

      self.flushImages()
      if columns == 2 and self.frame != None and self.currentcolumn == 1:
         # Start the second column.
         (x,y) = scribus.getPosition(self.frame)
         (w,h) = scribus.getSize(self.frame)
         width = w
         xpos = x + w + COLUMNGAP
         ypos = y
         self.currentcolumn = 2
      else:
         # First column or full width frame
         while True:
            ypos = self.topmargin
            for obj in scribus.getAllObjects():
               if obj in self.textframes:
                  (x,y) = scribus.getPosition(obj)
                  (w,h) = scribus.getSize(obj)
                  if y + h > ypos: 
                     ypos = y + h + FRAMEGAP
            if ypos + height > self.pageheight - self.bottommargin:
               self.newPage()
               self.flushImages()
            else:
               break
         xpos = self.leftmargin
         if columns == 1: 
            width = self.pagewidth - self.leftmargin - self.rightmargin
            self.currentcolumn = 0
         else:            
            width = self.columnwidth
            self.currentcolumn = 1
                                
      self.frame = scribus.createText(xpos, ypos, width, height)
      self.contents = []
      self.buffer = []
      self.columns = columns
      self.framelinked = False
      self.textframes.append(self.frame)
Beispiel #7
0
    def newFrame(self, height=MINFRAMESIZE, columns=2):
        """Start a new text frame.
         If we are working with 2 columns, we build each column as a seperate frame.
         Scribus does support multi column text frames, but with no keep-with-next
         functionality its of no use."""

        self.flushImages()
        if columns == 2 and self.frame != None and self.currentcolumn == 1:
            # Start the second column.
            (x, y) = scribus.getPosition(self.frame)
            (w, h) = scribus.getSize(self.frame)
            width = w
            xpos = x + w + COLUMNGAP
            ypos = y
            self.currentcolumn = 2
        else:
            # First column or full width frame
            while True:
                ypos = self.topmargin
                for obj in scribus.getAllObjects():
                    if obj in self.textframes:
                        (x, y) = scribus.getPosition(obj)
                        (w, h) = scribus.getSize(obj)
                        if y + h > ypos:
                            ypos = y + h + FRAMEGAP
                if ypos + height > self.pageheight - self.bottommargin:
                    self.newPage()
                    self.flushImages()
                else:
                    break
            xpos = self.leftmargin
            if columns == 1:
                width = self.pagewidth - self.leftmargin - self.rightmargin
                self.currentcolumn = 0
            else:
                width = self.columnwidth
                self.currentcolumn = 1

        self.frame = scribus.createText(xpos, ypos, width, height)
        self.contents = []
        self.buffer = []
        self.columns = columns
        self.framelinked = False
        self.textframes.append(self.frame)
def getPosition():
    if scribus.selectionCount() == 1:
        areaname = scribus.getSelectedObject()
        position= scribus.getPosition(areaname)
        vpos = position[1]
        hpos = position[0]
        scribus.deleteObject(areaname)
        return vpos, hpos
        
    else: 
        scribus.messageBox("csv2table", "please select ONE Object to mark the drawing area for the table")
        sys.exit()
Beispiel #9
0
 def freeSpace(self, width, height):
    ypos = self.topmargin
    for obj in scribus.getAllObjects():
       if not obj in self.sidebar.frames:
          (x,y) = scribus.getPosition(obj)
          (w,h) = scribus.getSize(obj)
          if y + h > ypos:
             ypos = y + h + COLUMNGAP + 1
    if ypos + height <= self.pageheight - self.bottommargin and self.gotSpace(self.leftmargin, ypos, width, height):
       return ypos
    else:
       return -1
Beispiel #10
0
def main():
    pass

    n = scribus.selectionCount()
    if n == 0:
        scribus.messageBox('Error', 'No item selected')
        return

    items = []
    for i in range(n):
        items.append(scribus.getSelectedObject(i))

    for item in items:
        pos = scribus.getPosition(item)
        dx, dy = pos
        scribus.pasteObject()
        new_item = scribus.getSelectedObject()
        pos = scribus.getPosition(new_item)
        dx, dy = dx - pos[0], dy - pos[1]
        scribus.moveObject(dx, dy, new_item)
        scribus.deleteObject(item)
Beispiel #11
0
def getPosition():
    if scribus.selectionCount() == 1:
        areaname = scribus.getSelectedObject()
        position = scribus.getPosition(areaname)
        vpos = position[1]
        hpos = position[0]
        scribus.deleteObject(areaname)
        return vpos, hpos

    else:
        scribus.messageBox("csv2table", "please select ONE Object to mark the drawing area for the table")
        sys.exit()
Beispiel #12
0
 def freeSpace(self, width, height):
     ypos = self.topmargin
     for obj in scribus.getAllObjects():
         if not obj in self.sidebar.frames:
             (x, y) = scribus.getPosition(obj)
             (w, h) = scribus.getSize(obj)
             if y + h > ypos:
                 ypos = y + h + COLUMNGAP + 1
     if ypos + height <= self.pageheight - self.bottommargin and self.gotSpace(
             self.leftmargin, ypos, width, height):
         return ypos
     else:
         return -1
def get_all_empty_images_frames():
    image_frames = []
    for page in range(1, scribus.pageCount() + 1):
        page_image_frames = []
        scribus.gotoPage(page)
        # get all empty image frames on the page
        for item in scribus.getPageItems():
            if item[1] == 2:
                if scribus.getImageFile(item[0]) == "":
                    x, y = scribus.getPosition(item[0])
                    page_image_frames.append((item[0], x, y))
        # sort the frames by position
        page_image_frames.sort(key=lambda k: [k[2], k[1]])
        image_frames += [i[0] for i in page_image_frames]
    return image_frames
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)
Beispiel #15
0
def drawPlaceholders():
    page = scribus.getPageSize()
    margin = scribus.getPageMargins()

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

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

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

    # add a "crossed frame" for missing images
    for item in scribus.getAllObjects():
        if scribus.getObjectType(item) == 'ImageFrame':
            image = scribus.getImageFile(item)
            if image == '':
                pos = scribus.getPosition(item)
                size = scribus.getSize(item)
                rectangle = scribus.createRect(pos[0], pos[1], size[0],
                                               size[1])
                scribus.setFillColor('none', rectangle)
                scribus.setLineColor('Black', rectangle)
                scribus.setLineWidth(0.4, rectangle)
                line = scribus.createLine(pos[0], pos[1], pos[0] + size[0],
                                          pos[1] + size[1])
                scribus.setLineColor('Black', line)
                scribus.setLineWidth(0.4, line)
                line = scribus.createLine(pos[0], pos[1] + size[1],
                                          pos[0] + size[0], pos[1])
                scribus.setLineColor('Black', line)
                scribus.setLineWidth(0.4, line)
def 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)
Beispiel #17
0
 def createNewPage(self, tbox):
     curPage = scribus.currentPage()
     if curPage < scribus.pageCount() - 1:
         where = curPage + 1
     else:
         where = -1
     logger.debug("cur=%d name=%s pc=%d wh=%d", curPage, tbox,
                  scribus.pageCount(), where)
     cols = scribus.getColumns(tbox)
     colgap = scribus.getColumnGap(tbox)
     x, y = scribus.getPosition(tbox)
     w, h = scribus.getSize(tbox)
     mp = scribus.getMasterPage(curPage)
     scribus.newPage(where, mp)  # return val?
     scribus.gotoPage(curPage + 1)
     newBox = scribus.createText(x, y, w, h)
     scribus.setColumns(cols, newBox)
     scribus.setColumnGap(colgap, newBox)
     scribus.linkTextFrames(tbox, newBox)
     logger.debug("link from %s to %s", tbox, newBox)
     return newBox
def drawPlaceholders():
    page = scribus.getPageSize()
    margin = scribus.getPageMargins()

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

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

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

    # add a "crossed frame" for missing images
    for item in scribus.getAllObjects():
        if scribus.getObjectType(item) == 'ImageFrame':
            image = scribus.getImageFile(item)
            if image == '':
                pos = scribus.getPosition(item)
                size = scribus.getSize(item)
                rectangle = scribus.createRect(pos[0], pos[1], size[0], size[1])
                scribus.setFillColor('none', rectangle)
                scribus.setLineColor('Black', rectangle)
                scribus.setLineWidth(0.4, rectangle)
                line = scribus.createLine(pos[0], pos[1] , pos[0] + size[0], pos[1] + size[1])
                scribus.setLineColor('Black', line)
                scribus.setLineWidth(0.4, line)
                line = scribus.createLine(pos[0], pos[1] + size[1], pos[0] + size[0], pos[1])
                scribus.setLineColor('Black', line)
                scribus.setLineWidth(0.4, line)
Beispiel #19
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()
Beispiel #20
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
Beispiel #22
0
    scribus.messageBox('Selection Count', "You must have at least one object selected",
                       scribus.ICON_WARNING, scribus.BUTTON_OK)
    sys.exit(2)

captionloc = scribus.valueDialog("Caption Location","Where to put the caption(s) -\n B/T/R/L?", "b")
captionloc = captionloc[0]
location = captionloc.upper()

pageunits = scribus.getUnit()
scribus.setUnit(scribus.UNIT_POINTS)

while count < numselect:
    frames.append(scribus.getSelectedObject(count))
    count += 1
    
for frame in frames:
    fwidth, fheight = scribus.getSize(frame)
    fx, fy = scribus.getPosition(frame)
    if location == "B":
        textf = scribus.createText(fx, fy+fheight, fwidth, 24)
    elif location == "T":
        textf = scribus.createText(fx, fy-24, fwidth, 24)
    elif location == "R":
        textf = scribus.createText(fx + fwidth, fy, 150, 40)
    elif location == "L":
        textf = scribus.createText(fx-150, fy + fheight - 40, 150, 40)
scribus.setUnit(pageunits)

scribus.setRedraw(True)

Beispiel #23
0
 def clashes(self, xpos, ypos, width, height, obj):
    (x,y) = scribus.getPosition(obj)
    (w,h) = scribus.getSize(obj)
    return not ((x+w < xpos or x > xpos+width) or (y+h < ypos or y > ypos+height))
Beispiel #24
0
import scribus
n = scribus.selectionCount()
list = []
for i in range(0, n):
    list.append(scribus.getSelectedObject(i))

margin = 2
fillColor = "White"
lineStyle = "noLine"
lineWidth = 0

#deselectAll()
for selected in list:
    x, y = scribus.getPosition(selected)
    width, height = scribus.getSize(selected)
    scribus.setFillColor(fillColor, selected)
    scribus.setLineShade(lineWidth, selected)
    scribus.setLineWidth(lineWidth, selected)
    scribus.setLineTransparency(lineWidth, selected)
    #scribus.setLineStyle(lineStyle, rectangle)
    #scribus.setStrokeColor(strokeColor, rectangle)
Beispiel #25
0
    sys.exit(1)

print(filename_png)

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

print(filename_svg)

scratchblocks_svg = os.path.join(download_path, 'scratchblocks.svg')
print(scratchblocks_svg + ' >> ' + filename_svg)
if os.path.isfile(scratchblocks_svg):
    os.rename(scratchblocks_svg, filename_svg)
else:
    scribus.messageBox('Error:', 'Cannot find ' + filename_svg)

# https://gitlab.com/inkscape/inbox/issues/405
# FitCanvasToDrawing cannot be run without a GUI
call([
    'inkscape', '--verb=FitCanvasToDrawing', '--verb=FileSave',
    '--verb=FileQuit', filename_svg
])
call(['inkscape', '-z', '--export-dpi=300', filename_svg, '-e', filename_png])

if (scribus.getObjectType(item) == 'TextFrame'):
    (x, y) = scribus.getPosition()
    (w, h) = scribus.getSize()
    scribus.deleteObject()
    name = scribus.createImage(x, y, w, h)
    scribus.selectObject(name)
    scribus.loadImage(filename_png)
if not scribus.haveDoc():
    scribus.messagebarText("No .") 
    sys.exit()

if scribus.selectionCount() == 0:
    scribus.messagebarText("No frame selected.") 
    sys.exit()

if scribus.selectionCount() > 1:
    scribus.messagebarText("Please select one single frame.") 
    sys.exit()

master_frame = scribus.getSelectedObject()

x,y = scribus.getPosition()
width, height = scribus.getSize()


path = scribus.fileDialog("Pick a directory", scribus.getDocName(), isdir = True)
if path == '':
    scribus.messagebarText("No directory selected.") 
    

extensions = ['jpg', 'png', 'tif']
filenames = [f for f in os.listdir(path)
              if any(f.endswith(ext) for ext in extensions)]

if not filenames:
    scribus.messagebarText("No image found.") 
    sys.exit()
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 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
Beispiel #29
0
 def clashes(self, xpos, ypos, width, height, obj):
     (x, y) = scribus.getPosition(obj)
     (w, h) = scribus.getSize(obj)
     return not ((x + w < xpos or x > xpos + width) or
                 (y + h < ypos or y > ypos + height))
    char_n = scribus.getTextLength(frame)
except scribus.WrongFrameTypeError:
    scribus.messageBox('Error:', 'You may only adjust text frames');
    sys.exit(1)

if char_n == 0 :
    scribus.messageBox('Error:', 'You can\'t adjust an empty frame');
    sys.exit(1)

if (scribus.textOverflows(frame) == 1) :
    scribus.messageBox('Error:', 'You can\' center a text which is overflowing');
    sys.exit(1)

# 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
Beispiel #31
0
def main(argv):
    unit = scribus.getUnit()
    units = ['pts', 'mm', 'inches', 'picas', 'cm', 'ciceros']
    unitlabel = units[unit]

    # get page size
    xysize = scribus.getPageSize()

    # ask for layout style
    layout_style = scribus.valueDialog("Guides Layout", layout_text, "1")
    if layout_style == "":
        sys.exit()

# 0 = erase all guides
    if layout_style == "0":
        #guides
        scribus.setVGuides([])
        scribus.setHGuides([])
        sys.exit()

# 1 = guides around page
    if layout_style == "1":
        # set guides distance
        pageguides_str = scribus.valueDialog(
            "Create Guides around Page",
            "Set distance to page borders (" + unitlabel +
            ") :\n\n- positive (e.g. 3) for page margin\n\n- negative (e.g. -3) for page bleed\n",
            "3")
        if pageguides_str != "":
            pageguides = float(pageguides_str)
        else:
            sys.exit()

        #set guides
        scribus.setVGuides(scribus.getVGuides() +
                           [pageguides, xysize[0] - pageguides])
        scribus.setHGuides(scribus.getHGuides() +
                           [pageguides, xysize[1] - pageguides])

# 2 = guides around selected object
    if layout_style == "2":
        # set guides distance
        objectguides_str = scribus.valueDialog(
            "Create Guides around selected Objects",
            "Set distance to object borders (" + unitlabel +
            ") :\n\n- 0 for around the object borders\n\n- positive (e.g. 3) towards inside the object\n\n- negative (e.g. -3) towards outside the object\n",
            "0")
        if objectguides_str != "":
            objectguides = float(objectguides_str)
        else:
            sys.exit()

        if scribus.selectionCount() == 0:
            scribus.messageBox("Error",
                               "Select an object first !",
                               icon=scribus.ICON_WARNING)
            sys.exit()

        #get selected object
        selection_name = scribus.getSelectedObject(0)
        objectpos = scribus.getPosition(selection_name)
        objectsize = scribus.getSize(selection_name)

        #set guides
        scribus.setVGuides(scribus.getVGuides() + [
            objectpos[0] + objectguides, objectpos[0] + objectsize[0] -
            objectguides
        ])
        scribus.setHGuides(scribus.getHGuides() + [
            objectpos[1] + objectguides, objectpos[1] + objectsize[1] -
            objectguides
        ])
Beispiel #32
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, height will be\n calculated, so the value here does not\n matter.', str(o_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))
    framename = scribus.valueDialog('Name of Frame','Name your frame or use this default name',"infobox" + str(boxcount) + textbox)
    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)
    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.loadImage(imageload, new_image)
            scribus.messageBox('Please Note',"Your frame will be created once you click OK.\n\nUse the Context Menu to Adjust Frame to Image.\n\nIf your image does not fill the width completely,\nstretch the frame vertically first.",scribus.BUTTON_OK)
        else:
	    new_image = scribus.createImage(new_left, float(new_top), new_width, float(new_height),framename)
        scribus.textFlowMode(new_image, 1)
        scribus.setScaleImageToFrame(scaletoframe=1, proportional=1, name=new_image)
    scribus.setLineColor('Black', line)
    scribus.setLineWidth(0.6, line)
    scribus.setLineStyle(scribus.LINE_DASHDOT, line)

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

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

scribus.setActiveLayer(layer)

scribus.setUnit(unit_current)
Beispiel #34
0
	scribus.messageBox('Error', "Document should have left_top_mark and right_top_mark or starts with left_top_mark_offset_ and right_top_mark_offset_ with suffix in mm to measure current spine width. Read more at https://litvinovg.pro/scribus-spine-width.html",  scribus.ICON_WARNING, scribus.BUTTON_OK)
	sys.exit(1)

newSpineWidth = scribus.valueDialog('Spine width','Set spine width in mm.')
if newSpineWidth == "0":
	scribus.messageBox('Error', "Spine width could not be zero.",  scribus.ICON_WARNING, scribus.BUTTON_OK)
	sys.exit(1)
newWidth = float(newSpineWidth.replace(',','.'))
if newWidth < 0:
	scribus.messageBox('Error', "Spine width could not be negative",  scribus.ICON_WARNING, scribus.BUTTON_OK)
	sys.exit(1)

#set units to mm
scribus.setUnit(1)
PageX,PageY = scribus.getPageSize()
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])
Beispiel #35
0
# Import wikipedia article to scribus page
# Bachir Soussi Chiadmi - 2015 - outilslibresalternatifs.org - ola#0

import sys
sys.path.append('/usr/lib/python3.4/site-packages')

import random
import string
import wikipedia
import scribus

# help(string)

# CONSTANTS
# nbr_pages = 4
bpX, bpY = scribus.getPosition('wiki')
bW, bH = scribus.getSize('wiki')

# block_txt_w = (bW)/2
block_txt_w = 50
nbr_col = bW / block_txt_w


# INIT
def init():
    # k = 0
    c = 0
    y = bpY
    x = bpX
    h = 0
Beispiel #36
0
if not scribus.haveDoc():
    scribus.messagebarText("No .")
    sys.exit()

if scribus.selectionCount() == 0:
    scribus.messagebarText("No frame selected.")
    sys.exit()

if scribus.selectionCount() > 1:
    scribus.messagebarText("Please select one single frame.")
    sys.exit()

master_frame = scribus.getSelectedObject()

x, y = scribus.getPosition()
width, height = scribus.getSize()

path = scribus.fileDialog("Pick a directory", scribus.getDocName(), isdir=True)
if path == '':
    scribus.messagebarText("No directory selected.")

extensions = ['jpg', 'png', 'tif']
filenames = [
    f for f in os.listdir(path) if any(f.endswith(ext) for ext in extensions)
]

if not filenames:
    scribus.messagebarText("No image found.")
    sys.exit()

import sys
sys.path.append('/usr/lib/python3.4/site-packages')

import random
import string
import wikipedia
import scribus

# help(string)


# CONSTANTS
# nbr_pages = 4
bpX, bpY = scribus.getPosition('wiki')
bW, bH = scribus.getSize('wiki')

# block_txt_w = (bW)/2
block_txt_w = 50
nbr_col = bW / block_txt_w


# INIT
def init():
  # k = 0
  c = 0
  y = bpY
  x = bpX
  h = 0