def addWatermark(self): '''Create a Draft watermark layer. This was taken from: http://wiki.scribus.net/canvas/Adding_%27DRAFT%27_to_a_document''' L = len(self.watermark) # The length of the word # will determine the font size scribus.defineColor("gray", 11, 11, 11, 11) # Set your own color here u = scribus.getUnit() # Get the units of the document al = scribus.getActiveLayer() # Identify the working layer scribus.setUnit( scribus.UNIT_MILLIMETERS) # Set the document units to mm, (w, h) = scribus.getPageSize() # needed to set the text box size scribus.createLayer("c") scribus.setActiveLayer("c") T = scribus.createText(w / 6, 6 * h / 10, h, w / 2) # Create the text box scribus.setText(self.watermark, T) # Insert the text scribus.setTextColor("gray", T) # Set the color of the text scribus.setFontSize( (w / 210) * (180 - 10 * L), T) # Set the font size according to length and width scribus.rotateObject(45, T) # Turn it round antclockwise 45 degrees scribus.setUnit(u) # return to original document units # FIXME: It would be nice if we could move the watermark box down to the lowest layer so # that it is under all the page text. Have not found a method to do this. For now we just # plop the watermark on top of everything else. scribus.setActiveLayer(al) # return to the original active layer
def addWatermark (self) : '''Create a Draft watermark layer. This was taken from: http://wiki.scribus.net/canvas/Adding_%27DRAFT%27_to_a_document''' L = len(self.watermark) # The length of the word # will determine the font size scribus.defineColor("gray", 11, 11, 11, 11) # Set your own color here u = scribus.getUnit() # Get the units of the document al = scribus.getActiveLayer() # Identify the working layer scribus.setUnit(scribus.UNIT_MILLIMETERS) # Set the document units to mm, (w,h) = scribus.getPageSize() # needed to set the text box size scribus.createLayer("c") scribus.setActiveLayer("c") T = scribus.createText(w/6, 6*h/10 , h, w/2) # Create the text box scribus.setText(self.watermark, T) # Insert the text scribus.setTextColor("gray", T) # Set the color of the text scribus.setFontSize((w/210)*(180 - 10*L), T) # Set the font size according to length and width scribus.rotateObject(45, T) # Turn it round antclockwise 45 degrees scribus.setUnit(u) # return to original document units # FIXME: It would be nice if we could move the watermark box down to the lowest layer so # that it is under all the page text. Have not found a method to do this. For now we just # plop the watermark on top of everything else. scribus.setActiveLayer(al) # return to the original active layer
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
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)
def drawHeaderFooter(pagetitle): """draw some info on the pages""" # get page size pageSize=scribus.getPageSize() pageWidth=pageSize[0] pageHeight=pageSize[1] #pageMargins pageMargins=scribus.getPageMargins() topMargin=pageMargins[0] leftMargin=pageMargins[1] rightMargin=pageMargins[2] bottomMargin=pageMargins[3] #create textbox and insert text for header textbox=scribus.createText(leftMargin, topMargin, pageWidth-leftMargin-rightMargin, HEADERSIZE) #set proper font size and alignment scribus.setFontSize(18, textbox) scribus.setTextAlignment(scribus.ALIGN_CENTERED, textbox) #load the string into the textbox headerstring=pagetitle scribus.insertText(headerstring, 0, textbox) scribus.setTextColor("Black", textbox) #create textbox and insert text for footer textbox=scribus.createText(leftMargin, pageHeight-bottomMargin-FOOTERSIZE, pageWidth-leftMargin-rightMargin, FOOTERSIZE) #set proper font size and alignment scribus.setFontSize(9, textbox) scribus.setTextAlignment(scribus.ALIGN_LEFT, textbox) #load the string into the textbox footerstring="Created using ColorChart.py V %s script for Scribus by Sebastian Stetter - http://www.sebastianstetter.de" % str(__version__) scribus.insertText(footerstring, 0, textbox) scribus.setTextColor("Black", textbox)
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)
def textframes(text_id, x, y, width, height, bg_colour, text_colour, fontsize, font, spacing, parsedtext, layer, linespacing=0, resize=0): scribus.createText(x, y, width, height, text_id) #scribus.text_id = scribus.createText(120, 10, 200, 20) scribus.setText(parsedtext, text_id) scribus.setFont(font, text_id) scribus.setTextColor(text_colour, text_id) scribus.setTextDistances(3*spacing, spacing, 0, spacing, text_id) scribus.sentToLayer(layer, text_id) scribus.setFontSize(fontsize, text_id)
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
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
def simpleGradient(my_parameters): '''Applies a simple (character by character) gradient to a TextFrame object''' try: TextFrame_object = my_parameters[0] CMYKstart = my_parameters[1] CMYKend = my_parameters[2] object_length = scribus.getTextLength(TextFrame_object) for i in range(0, object_length): scribus.selectText(i, 1, TextFrame_object) color = CMYKgradientPoint(CMYKstart, CMYKend, object_length, i) try: getColor(str(color)) except: scribus.defineColor(str(color), color[0], color[1], color[2], color[3]) scribus.setTextColor(str(color), TextFrame_object) except: print error_message_gradient_simple scribus.messageBox(TITLE, error_message_gradient_simple, scribus.ICON_WARNING)
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)
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)
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
def main(argv): ########################################### scribus.newDocDialog() if scribus.haveDoc: scribus.setUnit(scribus.UNIT_MILLIMETERS) (w, h) = scribus.getPageSize() ################### # ask for workdir workdir = scribus.fileDialog("Open directory with images", "", haspreview=False, issave=False, isdir=True) #workdir = "/media/sda7/StudioSession3/PDFTools/pics" #workdir = "/media/sda7/ISG/Itex/PhotoVisit/Boilerroom" # file filter filefilter = scribus.valueDialog( "File filter", "File filter examples: \n\n* or *.* = add all files\n*.jpg = add .jpg files only\nIMG_*.* = add all files starting with IMG_\n\nThis filter is case sensitive!", "*.*") # get image paths filelist = sorted(glob.glob(os.path.join(workdir, filefilter))) #scribus.messageBox("Help", str(filelist)) # count files filesinworkdir = len(filelist) #scribus.messageBox("Help", str(filesinworkdir)) #messagebar text scribus.messagebarText("Importing images...") #error if filesinworkdir == 0: scribus.messageBox("Error", "This directory is empty.") sys.exit() # add filename text? addfilenames = scribus.messageBox("Import images", "Files found in workdir : " + str(filesinworkdir) + "\n\nAdd file names to images?", button1=scribus.BUTTON_YES, button2=scribus.BUTTON_NO) #create text layer if addfilenames == 16384: activelayer = scribus.getActiveLayer() scribus.createLayer("Filenames") scribus.setActiveLayer(activelayer) #progressbar max scribus.progressTotal(filesinworkdir) page = 1 #create page, add and load image for i in filelist: scribus.progressSet(page) scribus.gotoPage(page) scribus.createImage(0, 0, w, h, "imagename" + str(page)) scribus.loadImage(filelist[page - 1], "imagename" + str(page)) scribus.setScaleImageToFrame(True, proportional=True, name="imagename" + str(page)) #scribus.setImageOffset(0, 0, "imagename"+str(page)) #scribus.setScaleFrameToImage(name="imagename"+str(page)) # add filename on page? if addfilenames == 16384: scribus.setActiveLayer("Filenames") filename = scribus.createText(2, 2, 50, 10, filelist[page - 1]) scribus.setText(os.path.basename(filelist[page - 1]), filename) scribus.setTextColor("White", filename) scribus.setActiveLayer(activelayer) scribus.newPage(-1) page += 1 #delete last blank page scribus.deletePage(filesinworkdir + 1)
#if i > 0 : #sys.exit(1) #scribus.messageBox("csv2table", row) roseid = row[0] rosenameger = row[1] rosenamelat = row[2] #scribus.messageBox("csv2table", roseid+' '+rosenameger+' ('+rosenamelat+')') #Insert the Right Text into the Right Position #Write ID into ID Field scribus.deleteText(idtextstring) scribus.setText(roseid, idtextstring) scribus.setFont(idfont, idtextstring) scribus.setFontSize(idfonSize, idtextstring) scribus.setTextColor(idtextcolor, idtextstring) scribus.setTextShade(idtextshade, idtextstring) #Write German Name into german Name Field scribus.deleteText(gertextstring) scribus.setText(rosenameger, gertextstring) scribus.setFont(gerfont, gertextstring) scribus.setFontSize(gerfonSize, gertextstring) scribus.setTextColor(gertextcolor, gertextstring) scribus.setTextShade(gertextshade, gertextstring) #Write Latin Name into Latin Name field scribus.deleteText(lattextstring) scribus.setText(rosenamelat, lattextstring) scribus.setFont(latfont, lattextstring) scribus.setFontSize(latfonSize, lattextstring)
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("gray",21,21,21,21) for x in range(0,maxX): for y in range(0,maxY): q = scribus.createText((x*((pageX*0.9)/maxX))+offsetX, (y*(pageY/maxY))+offsetY, (pageX*0.9)/maxX, pageY/maxY) scribus.setFont('Arial Regular',q) scribus.setFontSize(48, q) if random.randint(0, 1) == 0: rx[x][y] = random.randint(minResultB, maxResultB) ry[x][y] = random.randint(minResultA, maxResultA) else: rx[x][y] = random.randint(minResultA, maxResultA) ry[x][y] = random.randint(minResultB, maxResultB) rxx = rx[x][y] ryy = ry[x][y] scribus.insertText('%(rxx)d + %(ryy)d =__' % locals(), 0, q) scribus.newPage(-1) xx = 0 for x in range(maxX-1,-1,-1): for y in range(0,maxY): q = scribus.createText((xx*((pageX/6)/maxX))+offsetXX, (y*(pageY/maxY))+offsetY, (pageX/6)/maxX, pageY/maxY) scribus.setFont('Arial Regular',q) scribus.setFontSize(20, q) scribus.setTextColor("gray", q) rr = rx[x][y] + ry[x][y] # scribus.setTextAlignment(scribus.ALIGN_CENTERED, q) scribus.insertText('%(rr)d' % locals(), 0, q) xx+=1