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 createCell(text, roffset, coffset, w, h, marginl, margint, isBlack):
    #Create textbox
    box=scribus.createRect(marginl+(roffset-1)*w,margint+(coffset-1)*h, w, h)
    textBox=scribus.createText(marginl+(roffset-1)*w,margint+(coffset-1)*h, w, h)
    #insert the text into textbox
    scribus.setFont("Arial Bold", textBox)
    
    
    
    #Default  font size
    fontSize=12
    if len(text) < 50: fontSize=14
    if len(text) < 20: fontSize=16
    scribus.setFontSize(fontSize, textBox)
    scribus.setTextDistances(3, 3, 3, 3, textBox)
    scribus.insertText(text, 0, textBox)

    #black card
    if isBlack==True:
        scribus.setFillColor("Black", box)
        scribus.setTextColor("White", textBox)
        scribus.setLineColor("White", box)


    #add Logo
    hOffset=37
    wOffset=5
    addLogo(marginl+(roffset-1)*w+wOffset,margint+(coffset-1)*h+hOffset, isBlack)
    return
Esempio n. 4
0
def createCell(text, roffset, coffset, w, h, marginl, margint, isBlack):
    #Create textbox
    box=scribus.createRect(marginl+(roffset-1)*w,margint+(coffset-1)*h, w, h)
    textBox=scribus.createText(marginl+(roffset-1)*w,margint+(coffset-1)*h, w, h)
    #insert the text into textbox
    scribus.setFont("Arial Bold", textBox)
    
    
    
    #Default  font size
    fontSize=12
    if len(text) < 50: fontSize=14
    if len(text) < 20: fontSize=16
    scribus.setFontSize(fontSize, textBox)
    scribus.setTextDistances(3, 3, 3, 3, textBox)
    scribus.insertText(text, 0, textBox)

    #black card
    if isBlack==True:
        scribus.setFillColor("Black", box)
        scribus.setTextColor("White", textBox)
        scribus.setLineColor("White", box)


    #add Logo
    hOffset=37
    wOffset=5
    addLogo(marginl+(roffset-1)*w+wOffset,margint+(coffset-1)*h+hOffset, isBlack)
    return
Esempio n. 5
0
 def pasteImage(self, src, xpos, ypos, width, height, rotate=False):
     img = scribus.createImage(xpos, ypos, width, height)
     scribus.loadImage(src, img)
     scribus.setScaleImageToFrame(True, True, img)
     scribus.textFlowMode(img, 1)
     if src[-3:] == "jpg":
         scribus.setLineColor("Black", img)
         scribus.setLineWidth(0.2, img)
     #scribus.setLineShade(50,img)
     if rotate:
         scribus.rotateObject(90, img)
     #scribus.setCornerRadius(ROUNDS,img)
     self.imageframes.append(img)
Esempio n. 6
0
 def pasteImage(self, src, xpos, ypos, width, height, rotate=False):
    img = scribus.createImage(xpos, ypos, width, height)
    scribus.loadImage(src, img)
    scribus.setScaleImageToFrame(True,True,img)    
    scribus.textFlowMode(img, 1)
    if src[-3:] == "jpg":
       scribus.setLineColor("Black",img)
       scribus.setLineWidth(0.2,img)
    #scribus.setLineShade(50,img)
    if rotate:
       scribus.rotateObject(90,img)
    #scribus.setCornerRadius(ROUNDS,img)
    self.imageframes.append(img)
Esempio n. 7
0
def main(argv):

	rectColor = "Black"
	topMargin, leftMargin, rightMargin, bottomMargin = scribus.getPageMargins()
	pageWidth, pageHeight = scribus.getPageSize()
	printAreaWidth  = pageWidth  - leftMargin - rightMargin
	printAreaHeight = pageHeight - topMargin  - bottomMargin

	vertRectW = random.randrange(2,4)
	vertRectH = random.randrange(48,50)
	horRectW = random.randrange(47,49)
	horRectH = random.randrange(2,5)

	startx = leftMargin
	endx = pageWidth - leftMargin - horRectW
	starty = topMargin
	endy = pageHeight - topMargin - vertRectH

	numberRectVert = random.randrange(400,600)
	numberRectHor = random.randrange(400,600)
	opacity = 0

	scribus.progressTotal(numberRectVert+numberRectHor)
	scribus.setRedraw(False)

	for i in range(1, numberRectVert):
		opacity = opacity + 0.002
		xpos = random.randrange(int(startx),int(endx))
		ypos = random.randrange(int(starty),int(endy))
		rect = scribus.createRect(xpos, ypos, vertRectW, vertRectH)
		scribus.setFillColor(rectColor, rect)
		scribus.setLineColor("None", rect) 
		if opacity < 1:
			scribus.setFillTransparency(opacity, rect) 
		scribus.progressSet(i*2)


	for i in range(1, numberRectVert):
		opacity = opacity + 0.002
		xpos = random.randrange(int(startx),int(endx))
		ypos = random.randrange(int(starty),int(endy))
		recthor = scribus.createRect(xpos, ypos, horRectW, horRectH)
		scribus.setFillColor(rectColor, recthor)
		scribus.setLineColor("None", recthor) 
		if opacity < 1:
			scribus.setFillTransparency(opacity, recthor)

	scribus.progressReset()
	scribus.docChanged(True)
	scribus.statusMessage("Done")
	scribus.setRedraw(True)
Esempio n. 8
0
def drawColor(colorname, h, v, width, height):  # h horizontal position, v vertical position
    """draws a color chart field with its caption for the given colorname at the h and v position
    """
    # get cmyk values and convert them to 0 - 255 values
    color = scribus.getColor(colorname)
    c = int(round(color[0] / 2.55))
    m = int(round(color[1] / 2.55))
    y = int(round(color[2] / 2.55))
    k = int(round(color[3] / 2.55))
    # get rgb color
    rgbcolor = scribus.getColorAsRGB(colorname)
    r = rgbcolor[0]
    g = rgbcolor[1]
    b = rgbcolor[2]
    # get webcolor
    webcolor = rgbhex(r, g, b)
    # but String for Textbox together
    colorDisplay = colorname
    if scribus.isSpotColor(colorname):
        colorDisplay += " (Spot Color)"
    colorstring = "%s\nC %i, M %i, Y %i, K %i, \nR %i, G %i, B %i \nRGB: %s" % (
        colorDisplay,
        c,
        m,
        y,
        k,
        r,
        g,
        b,
        webcolor,
    )

    # draw rectangle and set colors
    rect = scribus.createRect(h, v, width, height)
    scribus.setFillColor(colorname, rect)
    # if total amount of color is < 20 draw outline in Black for rectangle, else in same color
    if c + m + y + k < 20:
        scribus.setLineColor("Black", rect)
    else:
        scribus.setLineColor(colorname, rect)
    # create textbox and insert text
    textbox = scribus.createText(h + width + 5, v, 50, height)
    # set proper font size
    scribus.setFontSize(11, textbox)
    scribus.setTextAlignment(scribus.ALIGN_LEFT, textbox)
    # load the string into the textbox
    scribus.insertText(colorstring, 0, textbox)
Esempio n. 9
0
 def draw(self):
    if self.txt != "":
       if scribus.currentPage() % 2 == 0:   
          r = scribus.createRect(-1,self.y,8,self.height)
          t = scribus.createText(2,self.y + self.height,self.height,6)
       else:   
          (pagewidth, pageheight) = scribus.getPageSize()
          r = scribus.createRect(pagewidth-7,self.y,8,self.height)
          t = scribus.createText(pagewidth-5,self.y + self.height,self.height,6)
       scribus.setFillColor("Black",r)
       scribus.setFillShade(20,r)
       scribus.setLineColor("None",r)
       scribus.setCornerRadius(ROUNDS,r)
       scribus.insertText(self.txt, -1, t)
       scribus.deselectAll()
       scribus.selectObject(t)
       scribus.selectText(0, len(self.txt), t)
       scribus.setStyle("Sidebar", t)
       scribus.rotateObject(90,t)
       self.frames.append(r)
       self.frames.append(t)
Esempio n. 10
0
def drawColor(colorname, h, v, width,
              height):  #h horizontal position, v vertical position
    """draws a color chart field with its caption for the given colorname at the h and v position
    """
    #get cmyk values and convert them to 0 - 255 values
    color = scribus.getColor(colorname)
    c = int(round(color[0] / 2.55))
    m = int(round(color[1] / 2.55))
    y = int(round(color[2] / 2.55))
    k = int(round(color[3] / 2.55))
    #get rgb color
    rgbcolor = scribus.getColorAsRGB(colorname)
    r = rgbcolor[0]
    g = rgbcolor[1]
    b = rgbcolor[2]
    #get webcolor
    webcolor = rgbhex(r, g, b)
    #but String for Textbox together
    colorDisplay = colorname
    if scribus.isSpotColor(colorname):
        colorDisplay += " (Spot Color)"
    colorstring = "%s\nC %i, M %i, Y %i, K %i, \nR %i, G %i, B %i \nRGB: %s" % (
        colorDisplay, c, m, y, k, r, g, b, webcolor)

    #draw rectangle and set colors
    rect = scribus.createRect(h, v, width, height)
    scribus.setFillColor(colorname, rect)
    #if total amount of color is < 20 draw outline in Black for rectangle, else in same color
    if c + m + y + k < 20:
        scribus.setLineColor("Black", rect)
    else:
        scribus.setLineColor(colorname, rect)
    #create textbox and insert text
    textbox = scribus.createText(h + width + 5, v, 50, height)
    #set proper font size
    scribus.setFontSize(11, textbox)
    scribus.setTextAlignment(scribus.ALIGN_LEFT, textbox)
    #load the string into the textbox
    scribus.insertText(colorstring, 0, textbox)
    scribus.setTextColor("Black", textbox)
Esempio n. 11
0
 def draw(self):
     if self.txt != "":
         if scribus.currentPage() % 2 == 0:
             r = scribus.createRect(-1, self.y, 8, self.height)
             t = scribus.createText(2, self.y + self.height, self.height, 6)
         else:
             (pagewidth, pageheight) = scribus.getPageSize()
             r = scribus.createRect(pagewidth - 7, self.y, 8, self.height)
             t = scribus.createText(pagewidth - 5, self.y + self.height,
                                    self.height, 6)
         scribus.setFillColor("Black", r)
         scribus.setFillShade(20, r)
         scribus.setLineColor("None", r)
         scribus.setCornerRadius(ROUNDS, r)
         scribus.insertText(self.txt, -1, t)
         scribus.deselectAll()
         scribus.selectObject(t)
         scribus.selectText(0, len(self.txt), t)
         scribus.setStyle("Sidebar", t)
         scribus.rotateObject(90, t)
         self.frames.append(r)
         self.frames.append(t)
Esempio n. 12
0
def addLogo(x, y, isBlack):
    #square side
    a=5
    #line
    line=0.01
    #angle
    angle=15
    #LightGrey
    scribus.defineColor("LightGrey",0,0,0,128)
    #DarkGrey
    scribus.defineColor("DarkGrey",0,0,0,192)
    
    # White cards colors
    squareColor1="Black"
    lineColor1="White"
    squareColor2="DarkGrey"
    lineColor2="White"
    squareColor3="LightGrey"
    lineColor3="White"
    titleColor="Black"
    
    # Black cards colors
    if isBlack==True:
        squareColor1="DarkGrey"
        lineColor1="DarkGrey"
        squareColor2="LightGrey"
        lineColor2="LightGrey"
        squareColor3="White"
        lineColor3="White"
        titleColor="White"
    
    square1=scribus.createRect(x, y+a/10, a, a)
    scribus.setLineWidth(1, square1)
    scribus.setFillColor(squareColor1, square1)
    scribus.setLineColor(lineColor1, square1)
    scribus.rotateObject(angle, square1)
    
    square2=scribus.createRect(x+a/2, y, a, a)
    scribus.setLineWidth(1, square2)
    scribus.setFillColor(squareColor2, square2)
    scribus.setLineColor(lineColor2, square2)
    
    square3=scribus.createRect(x+a, y, a, a)
    scribus.setLineWidth(1, square3)
    scribus.setFillColor(squareColor3, square3)
    scribus.setLineColor(lineColor3, square3)
    scribus.rotateObject(-angle, square3)
    
    title=scribus.createText(x+10,y+2, 50, 5)
    scribus.setFont("Arial Bold", title)
    scribus.setFontSize(8, title)
    scribus.insertText("Game of Filth", 0, title)
    scribus.setTextColor(titleColor, title)
    return
Esempio n. 13
0
def addLogo(x, y, isBlack):
    #square side
    a=5
    #line
    line=0.01
    #angle
    angle=15
    #LightGrey
    scribus.defineColor("LightGrey",0,0,0,128)
    #DarkGrey
    scribus.defineColor("DarkGrey",0,0,0,192)
    
    # White cards colors
    squareColor1="Black"
    lineColor1="White"
    squareColor2="DarkGrey"
    lineColor2="White"
    squareColor3="LightGrey"
    lineColor3="White"
    titleColor="Black"
    
    # Black cards colors
    if isBlack==True:
        squareColor1="DarkGrey"
        lineColor1="DarkGrey"
        squareColor2="LightGrey"
        lineColor2="LightGrey"
        squareColor3="White"
        lineColor3="White"
        titleColor="White"
    
    square1=scribus.createRect(x, y+a/10, a, a)
    scribus.setLineWidth(1, square1)
    scribus.setFillColor(squareColor1, square1)
    scribus.setLineColor(lineColor1, square1)
    scribus.rotateObject(angle, square1)
    
    square2=scribus.createRect(x+a/2, y, a, a)
    scribus.setLineWidth(1, square2)
    scribus.setFillColor(squareColor2, square2)
    scribus.setLineColor(lineColor2, square2)
    
    square3=scribus.createRect(x+a, y, a, a)
    scribus.setLineWidth(1, square3)
    scribus.setFillColor(squareColor3, square3)
    scribus.setLineColor(lineColor3, square3)
    scribus.rotateObject(-angle, square3)
    
    title=scribus.createText(x+10,y+2, 50, 5)
    scribus.setFont("Arial Bold", title)
    scribus.setFontSize(8, title)
    scribus.insertText("Cards Against Humanity", 0, title)
    scribus.setTextColor(titleColor, title)
    return
Esempio n. 14
0
def frontPage(LogoPath, ChurchPath, ChurchImage, Citation, CitationLocation):
    #scribus.setText('Gemeindebrief   DIGITAL Buxtehude',"Oben")

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

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

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

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

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

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

    scribus.saveDocAs()
Esempio n. 15
0
def generateContent(string, window):

    #generates all the elements/only one element
    start = 0
    end = 0
    if string == "all":
        #dont include the first line to make the data sort work [1:]
        #sort the the elements by date
        data = sorted(getCSVdata()[1:],
                      key=lambda row: dateFun(str.strip(row[5])),
                      reverse=True)
        end = len(data)
        print(str(end) + "  " + str(start))
        print("generating elements from all lines")
        window.destroy()
    elif RepresentsInt(string):
        start = int(string) - 1  #index shifting
        end = int(string)
        print("only generating line " + string)
        data = getCSVdata()
        window.destroy()
    else:
        print(string + " is not a valid value")
        print("exiting")
        window.destroy()
        sys.exit()

    if not scribus.haveDoc() > 0:  #do we have a doc?
        scribus.messageBox("importcvs2table",
                           "No opened document.\nPlease open one first.")
        sys.exit()
    userdim = scribus.getUnit()  #get unit and change it to mm
    scribus.setUnit(scribus.UNIT_MILLIMETERS)

    lineWidth = 3.92  #aka 1.383mm, kp warum

    rowDate = ""
    for i in range(start, end):

        rowName = str.strip(data[i][0])
        rowCategory = str.strip(data[i][1])
        rowDescription = str.strip(data[i][2])
        rowPrice = str.strip(data[i][3])
        rowPlace = str.strip(data[i][4])
        rowDate = str.strip(data[i][5])
        rowTime = str.strip(data[i][6])

        if rowName == "":  #skip empty csv lines
            continue

        print("add element: " + rowName)

        #random values
        hpos = 120.0
        vpos = 200.0
        hposition = 120.0
        vposition = 200.0

        objectlist = []  #list for all boxes

        x = 0  #sets the progress
        #create the blue box
        print("create the blue line")
        blueBox = scribus.createLine(hposition + 1, vposition, hposition + 1,
                                     vposition + 5.863)
        scribus.setLineColor("Cyan", blueBox)
        scribus.setLineWidth(lineWidth, blueBox)
        objectlist.append(blueBox)
        scribus.progressSet(x)

        x = 1
        #create the data character box
        #these are the width values for the numbers
        zero = 4.608
        one = 2.839
        two = 4.724
        three = 4.393
        four = 4.625
        five = 4.261
        six = 4.278
        seven = 4.261
        eight = 4.625
        nine = 4.708

        lenArray = [zero, one, two, three, four, five, six, seven, eight, nine]

        marginleft = 1.3
        margintop = 0.519  #substract, cause the box is heigher that the blue line
        cellwidthright = 10.951
        cellHeight = 8.282
        hposition = hposition + marginleft + 1
        textbox = scribus.createText(hposition, vposition - margintop,
                                     cellwidthright, cellHeight)
        scribus.setFont("Quicksand Regular", textbox)
        scribus.setFontSize(20.0, textbox)
        finalDate = ""
        rowDateLength = 0
        #checks if the rowDate is from 01-09, in that case remove the zero
        if rowDate[0] == '0':
            finalDate = rowDate[1]
            rowDateLength = lenArray[int(rowDate[1])]

        else:
            finalDate = rowDate[:2]
            rowDateLength = lenArray[int(rowDate[0])] + lenArray[int(
                rowDate[1])]

        scribus.insertText(finalDate, 0, textbox)
        print("day: " + finalDate)
        objectlist.append(textbox)
        scribus.progressSet(x)

        x = 2
        #create the month/day box
        print("create the box with the day and month")
        width = 19.447
        height = 8.025
        marginleft = rowDateLength  #gain that from the calculations above, depends on the width of the rowDate characters

        monthBox = scribus.createText(hposition + marginleft + 0.7, vposition,
                                      width, height)
        scribus.setFont("Quicksand Regular", monthBox)
        scribus.setFontSize(8.5, monthBox)

        month = ""
        m = rowDate[3:5]
        if m == '01':
            month = "Januar"
        elif m == '02':
            month = "Februar"
        elif m == '03':
            month = "März"
        elif m == '04':
            month = "April"
        elif m == '05':
            month = "Mai"
        elif m == '06':
            month = "Juni"
        elif m == '07':
            month = "Juli"
        elif m == '08':
            month = "August"
        elif m == '09':
            month = "September"
        elif m == '10':
            month = "Oktober"
        elif m == '11':
            month = "November"
        elif m == '12':
            month = "Dezember"
        else:
            print("cant determine month!")

        day = datetime.date(int(rowDate[6:]), int(m),
                            int(rowDate[:2])).weekday()
        dayName = ""

        if day == 0:
            dayName = "Montag"
        elif day == 1:
            dayName = "Dienstag"
        elif day == 2:
            dayName = "Mittwoch"
        elif day == 3:
            dayName = "Donnerstag"
        elif day == 4:
            dayName = "Freitag"
        elif day == 5:
            dayName = "Samstag"
        elif day == 6:
            dayName = "Sonntag"
        else:
            print("cant determine day!")

        text = month + "\n" + dayName
        scribus.setStyle("Kalender_neu_Monat und Tag", monthBox)
        scribus.insertText(text, 0, monthBox)
        print("month: " + month + " day: " + dayName)
        objectlist.append(monthBox)
        scribus.progressSet(x)

        x = 3
        #create the main text box
        print("create the main text box")
        margintop = 5.5
        hpos = hpos - 0.383  #i dont know why but scribus always places the element 0.383 right than it should be :/
        mainTextBox = scribus.createText(
            hpos, vposition + margintop, 43.0,
            45.0)  #minus eins weil der blaue balken seinen kasten overflowed

        #insert category
        print("insert the category: " + rowCategory)
        scribus.insertText(rowCategory, 0, mainTextBox)
        endCategory = scribus.getTextLength(mainTextBox)
        scribus.selectText(0, endCategory, mainTextBox)
        scribus.setFontSize(10.5, mainTextBox)
        scribus.selectText(0, endCategory, mainTextBox)
        scribus.setStyle("Kalender_Eventname", mainTextBox)

        #insert main text
        print("insert the main text")
        scribus.insertText("\n" + rowDescription, endCategory, mainTextBox)
        endMainText = scribus.getTextLength(mainTextBox) - endCategory
        scribus.selectText(endCategory, endMainText, mainTextBox)
        scribus.setStyle("Kalender_Eventbeschreibung", mainTextBox)

        #get start length to color everything black and set font size
        startAll = scribus.getTextLength(mainTextBox)
        createPlaceTimePrice(mainTextBox, "\n| Ort: ", "",
                             "Kalender_Eventname")

        #insert value for place
        createPlaceTimePrice(mainTextBox, rowPlace, "Heuristica Regular", "")

        #insert time letters
        createPlaceTimePrice(mainTextBox, " | Zeit: ", "Quicksand Regular", "")

        #insert time value
        createPlaceTimePrice(mainTextBox, rowTime, "Heuristica Regular", "")

        #insert price letters
        createPlaceTimePrice(mainTextBox, " | Eintritt: ", "Quicksand Regular",
                             "")

        #insert price value
        createPlaceTimePrice(mainTextBox, rowPrice, "Heuristica Regular", "")

        #setFontSize and black color for the whole detail box
        endAll = scribus.getTextLength(mainTextBox) - startAll
        scribus.selectText(startAll, endAll, mainTextBox)
        scribus.setFontSize(8.5, mainTextBox)
        scribus.selectText(startAll, endAll, mainTextBox)
        scribus.setTextColor("Black", mainTextBox)

        objectlist.append(mainTextBox)
        scribus.progressSet(x)

        #do some generell stuff
        scribus.groupObjects(objectlist)
        scribus.progressReset()
        scribus.setUnit(userdim)  # reset unit to previous value
        scribus.docChanged(True)
        scribus.statusMessage("Done")
        scribus.setRedraw(True)

    print("done")
    return 0
Esempio n. 16
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)
Esempio n. 17
0
 def pasteSpacer(self, xpos, ypos, width, height):
     img = scribus.createRect(xpos, ypos, width, height)
     scribus.textFlowMode(img, 1)
     scribus.setLineColor("None", img)
     scribus.setFillColor("None", img)
     self.imageframes.append(img)
Esempio n. 18
0
 def pasteSpacer(self, xpos, ypos, width, height):
    img = scribus.createRect(xpos, ypos, width, height)
    scribus.textFlowMode(img,1)
    scribus.setLineColor("None",img)
    scribus.setFillColor("None",img)
    self.imageframes.append(img)
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)
import random
import scribus

# page size in inch (letter)
pageX = 8.5
pageY = 11.0
lineY = 0.4125
spaceY = 0.1875

scribus.newDocument((pageX, pageY), (0.0, 0.0, 0.0, 0.0), scribus.PORTRAIT, 1, scribus.UNIT_INCHES, scribus.PAGE_1, 0, 1)
scribus.defineColor("lightgray",21,21,21,21)
scribus.defineColor("gray",51,51,51,51)
scribus.defineColor("darkgray",91,91,91,91)

l = scribus.createLine(1.0,0.0,1.0,11)
scribus.setLineColor("gray", l)
l = scribus.createLine(1.05,0.0,1.05,11)
scribus.setLineColor("gray", l)  

for x in range(0,19):
	l = scribus.createLine(0.0,lineY-spaceY,8.5,lineY-spaceY)
	scribus.setLineColor("gray", l) 

	l = scribus.createLine(0.0,lineY,8.5,lineY)
	scribus.setLineColor("lightgray", l)
	scribus.setLineStyle(scribus.LINE_DOT,l) 

	l = scribus.createLine(0.0,lineY+spaceY,8.5,lineY+spaceY)
	scribus.setLineColor("darkgray", l)
	lineY = lineY + 0.5625
Esempio n. 21
0
horRectH = random.randrange(2,5)

startx = leftMargin
endx = pageWidth - leftMargin - horRectW
starty = topMargin
endy = pageHeight - topMargin - vertRectH

numberRectVert = random.randrange(400,600)
numberRectHor = random.randrange(400,600)
opacity = 0

for i in range(1, numberRectVert):
	opacity = opacity + 0.002
	xpos = random.randrange(int(startx),int(endx))
	ypos = random.randrange(int(starty),int(endy))
	rect = scribus.createRect(xpos, ypos, vertRectW, vertRectH)
	scribus.setFillColor(rectColor, rect)
	scribus.setLineColor("None", rect) 
	if opacity < 1:
		scribus.setFillTransparency(opacity, rect) 


for i in range(1, numberRectVert):
	opacity = opacity + 0.002
	xpos = random.randrange(int(startx),int(endx))
	ypos = random.randrange(int(starty),int(endy))
	recthor = scribus.createRect(xpos, ypos, horRectW, horRectH)
	scribus.setFillColor(rectColor, recthor)
	scribus.setLineColor("None", recthor) 
	if opacity < 1:
		scribus.setFillTransparency(opacity, recthor) 
				scribus.setFontSize(12, a)
				scribus.setTextColor("gray", a)
				scribus.setTextAlignment(scribus.ALIGN_CENTERED, a)
				scribus.rotateObject(180, a);
				
				rxy = rx-ry
				scribus.insertText('%(rx)d - %(ry)d = %(rxy)d' % locals(), 0, a)		
				
				q = scribus.createText(1.0+((zx+0)*(pageX/1.55)), 1.125+(zy*(pageY/3.84)), 4, 1)
				scribus.setFont('Arial Regular',q)		
				scribus.setFontSize(55, q)
				scribus.setTextAlignment(scribus.ALIGN_CENTERED, q)
				scribus.insertText('%(rx)d + %(ry)d =' % locals(), 0, q)
				ry = ry + 1
		l = scribus.createLine(0.0,2.833333,11,2.833333)
		scribus.setLineColor("gray", l)
		l = scribus.createLine(0.0,5.666666,11,5.666666)
		scribus.setLineColor("gray", l)
		l = scribus.createLine(5.5,0.0,5.5,8.5)
		scribus.setLineColor("gray", l)
		scribus.newPage(-1)
		rx = x
		ry = y
		for zx in range(1,-1,-1):
			for zy in range(0,3):						
				a = scribus.createText(2.25+((zx+0)*(pageX/1.55)), 0.75+(zy*(pageY/3.84)), 1.25, 0.25)
				scribus.setFont('Arial Regular',a)		
				scribus.setFontSize(12, a)
				scribus.setTextColor("gray", a)
				scribus.setTextAlignment(scribus.ALIGN_CENTERED, a)
				scribus.rotateObject(180, a);
if baseline > 0 :
  guide_i = 0
  guide_list = scribus.getHGuides()
  guide_list.append(page[1])
  guide = guide_list[guide_i]
  guide_n = len(guide_list)
  if not 'Gray' in scribus.getColorNames() :
      scribus.defineColor('Gray', 10, 10, 10, 10)
  for item in range(baseline + baseline_start*multiplicator, int(page[1] * multiplicator + baseline_start*multiplicator), baseline) :
    # print item/multiplicator
    while guide_i < guide_n - 1 and item/multiplicator > guide + 0.15 :
        guide_i = guide_i + 1
        guide = guide_list[guide_i]
    if item/multiplicator < guide - 0.15 :
        line = scribus.createLine(0, item/multiplicator , page[0], item/multiplicator)
        scribus.setLineColor('Gray', line)
        scribus.setLineWidth(0.6, line)
        # scribus.setLineStyle(scribus.LINE_DASHDOT, line)


# 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)