Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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)
#!/usr/bin/env python

import scribus
import sys
import os
from random import randint
magtxt = 'Enter a magnetude number between 1 and 10'
pagetxt = 'What page to shake?'
magnetude = int(scribus.valueDialog("Magnetude",magtxt,"1"))
page = int(scribus.valueDialog("Enter page number, '0' for all",pagetxt,"1"))
pagenum = scribus.pageCount()
content = []
if page == 0:
	page = 1
else:
	pagenum = page
	pass
while (page <= pagenum):
	scribus.gotoPage(page)
	d = scribus.getPageItems()
	for item in d:
		rand = randint(- magnetude * 10 , magnetude * 10)
		itemname = item[0]
		print itemname
		scribus.rotateObjectAbs(rand,itemname)
		scribus.moveObject(rand,rand,itemname)
	page += 1
                        layercount].elements[elementcount].rotation % (2 *
                                                                       math.pi)
                    if rotation > 0.5:
                        # https://stackoverflow.com/questions/34372480/rotate-point-about-another-point-in-degrees-python
                        # Scribus by default rotates the text box over the upper leftmost corner, while myphotobook uses the center point.
                        # Therefore, I use the function in the above site to translate the frame after rotation
                        # It works for most of our rotated text (upside down, as in the album spine) but sometimes not in the straight horizontal text
                        #	ox, oy = origin
                        ox, oy = 0, 0
                        #	px, py = point
                        px, py = size_x / 2, size_y / 2
                        qx = ox + math.cos(rotation) * (
                            px - ox) - math.sin(rotation) * (py - oy)
                        qy = oy + math.sin(rotation) * (
                            px - ox) + math.cos(rotation) * (py - oy)
                        scribus.rotateObjectAbs(math.degrees(rotation),
                                                captionBox)
                        scribus.moveObject(size_x / 2, size_y / 2, captionBox)
                        scribus.moveObject(qx, qy, captionBox)
                        #print ("texto: " + str(caption_text))
                        #print ("rotation: " + str(rotation))
                        #print ("rotation degrees: " + str(math.degrees(rotation) % 360))
                        #print ("----------------------------------------"+"\n")
                #else:
                #print ("no Elements within LAYER containing PICTURE or TEXT")
        #else:
        #print ("No elements within the LAYER")

scribus.setRedraw(1)
scribus.redrawAll()
Esempio n. 7
0
vGuides = [(PageX/2), (PageX/2 + newWidth/2), (PageX/2 - newWidth/2)]
hGuides = []

for item in pageItems:
	if item[0].startswith('spine_background'):
		X,Y = scribus.getPosition(item[0])
		hasSpineBackground = True
		Xsize,Ysize = scribus.getSize(item[0])
		scribus.sizeObject(newWidth, Ysize, item[0])
		scribus.moveObjectAbs(PageX/2 - newWidth/2, Y ,item[0])
	
for item in pageItems:
	X,Y = scribus.getPosition(item[0])
	if item[0].startswith('background'):
		scribus.moveObject(-halfWidthDiff, 0 , item[0])
		Xsize,Ysize = scribus.getSize(item[0])
		backgroundSize = Xsize + spineWidthDiff 
		scribus.sizeObject(backgroundSize, Ysize, item[0])
	if item[0].startswith('left_'):
		scribus.moveObject(-halfWidthDiff, 0 , item[0])
		if item[0].startswith('left_background'):
			Xsize,Ysize = scribus.getSize(item[0])
			leftBackgroundSize = PageX/2 - X + halfWidthDiff + 0.05 
			if hasSpineBackground:
				leftBackgroundSize -=  newWidth/2
			scribus.sizeObject(leftBackgroundSize, Ysize, item[0])
		if item[0].startswith('left_top_crop'):
			newX,newY = scribus.getPosition(item[0])
			Xsize,Ysize = scribus.getSize(item[0])
			vGuides.append(newX+Xsize)
Esempio n. 8
0
#!/usr/bin/env python

import scribus
import sys
import os
from random import randint
magtxt = 'Enter a magnetude number between 1 and 10'
pagetxt = 'What page to shake?'
magnetude = int(scribus.valueDialog("Magnetude", magtxt, "1"))
page = int(scribus.valueDialog("Enter page number, '0' for all", pagetxt, "1"))
pagenum = scribus.pageCount()
content = []
if page == 0:
    page = 1
else:
    pagenum = page
    pass
while (page <= pagenum):
    scribus.gotoPage(page)
    d = scribus.getPageItems()
    for item in d:
        rand = randint(-magnetude * 10, magnetude * 10)
        itemname = item[0]
        print itemname
        scribus.rotateObjectAbs(rand, itemname)
        scribus.moveObject(rand, rand, itemname)
    page += 1