def getColorsFromCsv(filename, idxPro): csvreader=csv.reader(file(filename)) csvcolors=[] for row in csvreader: if len(row)>1 and idxPro==1: name=row[0].strip() if len(row)>4 and name[0:7]=='couleur': c=int(row[1] )* 2.55 c=int(c) m=int(row[2] )* 2.55 m=int(m) y=int(row[3] )* 2.55 y=int(y) k=int(row[4] )* 2.55 k=int(k) if checkValue(c, m, y, k) ==False: scribus.messageBox("importerPros", "At least one CMYK value in your csv file is not correct \n(must be between 0 and 100)\nAborting script - nothing imported.", icon=scribus.ICON_WARNING) sys.exit() color=(name, c, m, y, k) csvcolors.append(color) elif name[0:3]=='txt': if scribus.objectExists(name): scribus.setText(row[1].replace("\\n","\n"), name) nbContent=scribus.getTextLength(name) scribus.selectText(0, nbContent, name) scribus.setStyle("style"+name[3:], name) else: scribus.messageBox("Objet non trouvé","Aucun objet correspondant au paramètre %s n'a été trouvé dans le document vierge"%name) readGlobalParameter(row) return csvcolors
def evalTemplate(self): pos2 = 0 while True: textlen = scribus.getTextLength(self.textbox) if textlen == 0: return scribus.selectText(0, textlen, self.textbox) alltext = scribus.getAllText(self.textbox) # logger.debug("alltext: %s %s", type(alltext), alltext) pos1 = alltext.find("/template", pos2) logger.debug("pos /template=%d", pos1) if pos1 < 0: return pos2 = alltext.find("/endtemplate", pos1) if pos2 < 0: raise Exception("kein /endtemplate nach /template") pos2 += 12 # len("/endtemplate") lines = alltext[pos1:pos2].split('\r') logger.debug("lines:%s %s", type(lines), str(lines)) line0 = lines[0] lineN = lines[-1] # logger.debug("lineN: %s %s", type(lineN), lineN) if lineN != "/endtemplate": raise ValueError( "Die letzte Zeile des templates darf nur /endtemplate enthalten" ) words = line0.split() typ = words[1] if typ != "/tour" and typ != "/termin" and typ != "/toc": raise ValueError( "Zweites Wort nach /template muß /tour, /termin oder /toc sein" ) typ = typ[1:] if typ == "toc": continue sel = words[2] if not sel.startswith("/selektion="): raise ValueError( "Drittes Wort nach /template muß mit /selektion= beginnen") sel = sel[11:].lower() sels = self.tourselections if typ == "tour" else self.terminselections if not sel in sels: raise ValueError("Selektion " + sel + " nicht in " + typ + "selektion") sel = sels[sel] events = self.touren if typ == "tour" else self.termine self.insertPos = pos1 runs = self.makeRuns(pos1, pos2) logger.debug("runs:%s", str(runs)) # can now remove template scribus.selectText(pos1, pos2 - pos1, self.textbox) scribus.deleteText(self.textbox) pos2 = pos1 self.insertPos = pos1 self.evalEvents(sel, events, runs)
def insertTextWithStyle(txt, style, frame): start = scribus.getTextLength(frame) scribus.insertText(txt, -1, frame) scribus.selectText(start, len(txt), frame) try: scribus.setStyle(style, frame) except scribus.NotFoundError: scribus.createParagraphStyle(style) scribus.setStyle(style, frame) scribus.insertText("\n", -1, frame)
def insertTextWithStyle(txt,style,frame): start = scribus.getTextLength(frame) scribus.insertText(txt, -1, frame) scribus.selectText(start, len(txt), frame) try: scribus.setStyle(style, frame) except scribus.NotFoundError: scribus.createParagraphStyle(style) scribus.setStyle(style, frame) scribus.insertText("\n", -1, frame)
def fill_text_placeholders(frame, fields, row): for field in fields: # TODO: currently, if the fields is not found it's left as is, with no warning if field['key'] in row: scribus.insertText(row[field['key']], field['start'] + 1, frame) # delete "key}" scribus.selectText(field['start'] + len(row[field['key']]) + 1, field['end'] - field['start'], frame) scribus.deleteText(frame) # delete "{" scribus.selectText(field['start'], 1, frame) scribus.deleteText(frame)
def evalTocEvents(self, runs, firstPageNr): toc = [] pagenum = scribus.pageCount() foundEvents = 0 for page in range(1, pagenum + 1): scribus.gotoPage(page) self.pageNr = firstPageNr + page - 1 pageitems = scribus.getPageItems() for item in pageitems: if item[1] != 4: continue tbox = item[0] tlen = scribus.getTextLength(tbox) logger.debug("tbox %s length %d", tbox, tlen) if tlen == 0: continue scribus.selectText(0, tlen, tbox) allText = scribus.getText( tbox) # getAllText returns text of complete link chain! z = 0 while True: x = allText.find("_evtid_:", z) if x < 0: break y = allText.find(STX, x) evtId = allText[x + 8:y] z = allText.find(ETX, y) titel = allText[y + 1:z] logger.debug("eventid %s, titel %s on page %d", evtId, titel, self.pageNr) event = self.gui.eventServer.getEventById(evtId, titel) toc.append((self.pageNr, event)) foundEvents += 1 logger.debug("sorting") toc.sort(key=lambda t: t[1].getDatumRaw()) # sortieren nach Datum for (pageNr, event) in toc: self.eventMsg = event.getTitel() + " vom " + event.getDatum()[0] logger.debug("event %s on page %d", self.eventMsg, self.pageNr) self.pageNr = pageNr for run in runs: self.run = run self.evalRun(event) self.insertText("\n", self.run) self.pageNr = None if foundEvents == 0: print("Noch keine Events gefunden") else: # remove template pos1, pos2, tbox = self.toBeDelPosToc scribus.selectText(pos1, pos2 - pos1, tbox) scribus.deleteText(tbox) scribus.redrawAll()
def replaceText(text, code): if text is None or text is u'': logger.warn(".. empty content for elem [%s]", code) text = ' ' l = scribus.getTextLength(code) scribus.selectText(0, l - 1, code) scribus.deleteText(code) scribus.insertText(text, 0, code) l = scribus.getTextLength(code) scribus.selectText(l - 1, 1, code) scribus.deleteText(code)
def createPlaceTimePrice(box, string, font, style): startLength = scribus.getTextLength(box) scribus.insertText(string, startLength, box) endLength = scribus.getTextLength(box) - startLength if style != "": scribus.selectText(startLength, endLength, box) scribus.setStyle(style, box) if font != "": scribus.selectText(startLength, endLength, box) scribus.setFont(font, box) return endLength
def insertText(self, text, pStyle): if text is None or text == "": return pos = self.insertPos scribus.insertText(text, pos, self.textbox) tlen = len(text) if pStyle is None: pStyle = self.lastPStyle # if cStyle is None: # cStyle = self.lastCStyle scribus.selectText(pos, tlen, self.textbox) scribus.setParagraphStyle(pStyle, self.textbox) self.lastPStyle = pStyle # scribus.setCharacterStyle(cStyle, self.textbox) # self.lastCStyle = cStyle self.insertPos += tlen
def characters(self, content): """place text, apply style""" start = scribus.getTextLength(self.name) go_ahead = self.shouldSetStyle() scribus.insertText (content, -1, self.name) scribus.selectText(start, len(content), self.name) if self.styles[-1] != None and go_ahead: try: scribus.setStyle(self.styles[-1], self.name) except scribus.NotFoundError: scribus.createParagraphStyle(self.styles[-1]) scribus.setStyle(self.styles[-1], self.name) if self.overrides[-1] != None: try: scribus.setFont(self.overrides[-1], self.name) except ValueError: pass self.first = False
def evalTocTemplate(self, firstPageNr): textlen = scribus.getTextLength(self.textbox) if textlen == 0: return scribus.selectText(0, textlen, self.textbox) alltext = scribus.getAllText(self.textbox) # logger.debug("alltext: %s %s", type(alltext), alltext) pos2 = 0 while True: pos1 = alltext.find("/template", pos2) logger.debug("pos /template=%d", pos1) if pos1 < 0: return pos2 = alltext.find("/endtemplate", pos1) if pos2 < 0: raise Exception("kein /endtemplate nach /template") pos2 += 12 # len("/endtemplate") lines = alltext[pos1:pos2].split('\r') logger.debug("lines:%s %s", type(lines), str(lines)) line0 = lines[0] lineN = lines[-1] # logger.debug("lineN: %s %s", type(lineN), lineN) if lineN != "/endtemplate": raise ValueError( "Die letzte Zeile des templates darf nur /endtemplate enthalten" ) words = line0.split() typ = words[1] if typ != "/tour" and typ != "/termin" and typ != "/toc": raise ValueError( "Zweites Wort nach /template muß /tour, /termin oder /toc sein" ) typ = typ[1:] if typ != "toc": continue self.insertPos = pos1 runs = self.makeRuns(pos1, pos2) logger.debug("runs:%s", str(runs)) # remember template self.toBeDelPosToc = (pos1, pos2, self.textbox) self.insertPos = pos2 self.evalTocEvents(runs, firstPageNr)
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 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)
def insertText(self, text, run): if text is None or text == "": return pos = self.insertPos scribus.insertText(text, pos, self.textbox) tlen = len(text) logger.debug( "insert pos=%d len=%d npos=%d text='%s' style=%s cstyle=%s", pos, tlen, pos + tlen, text, run.pstyle, run.cstyle) global lastPStyle, lastCStyle if run.pstyle != lastPStyle: scribus.selectText(pos, tlen, self.textbox) scribus.setParagraphStyle( noPStyle if run.pstyle is None else run.pstyle, self.textbox) lastPStyle = run.pstyle if run.cstyle != lastCStyle: scribus.selectText(pos, tlen, self.textbox) scribus.setCharacterStyle( noCStyle if run.cstyle is None else run.cstyle, self.textbox) lastCStyle = run.cstyle if False and self.url is not None: # TODO logger.debug("URL: %s", self.url) scribus.selectText(pos, tlen, self.textbox) frame = None # see http://forums.scribus.net/index.php/topic,3487.0.html scribus.setURIAnnotation(self.url, frame) self.url = None self.insertPos += tlen
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)
def slotDoIt(self): nfs = self.val.value() obj = scribus.getSelectedObject(0) t = scribus.getText(obj) scribus.deselectAll() t0 = scribus.getText(obj) fs = scribus.getFontSize(obj) tl = scribus.getTextLength(obj) idx = t0.find(t) + (len(t) / 2) base = fs #print t0 #print t #print "FS %i NFS %i IDX %i START %i" % (fs,nfs,idx,idx - int((nfs - fs) / 0.1)) for i in xrange(max(idx - int((nfs - fs) * 10), 0), idx): scribus.selectText(i, 1, obj) base += 0.1 scribus.setFontSize(base,obj) for i in xrange(idx, min(idx + int((nfs - fs) * 10), tl - 1)): scribus.selectText(i, 1, obj) base -= 0.1 scribus.setFontSize(base,obj) scribus.setRedraw(True) scribus.selectObject(obj)
def format(self, tokensource, outfile): current_frame = scribus.getSelectedObject() # TODO: also support formatting a selection as soon as the API has getTextSelection -> (start, length) # resete the character styles scribus.setCharacterStyle(self.base_char_style) pos = 0 last_val = '' last_type = None for token_type, token_value in tokensource: print(token_type) print(token_value) token_length = len(token_value) # scribus does not have a \n after the last character, # the code has it if pos + token_length > self.code_length: token_length -= 1 # print(pos) # print(token_length) scribus.selectText(pos, token_length, current_frame) pos += token_length style_name = self.get_char_style(token_type) scribus.setCharacterStyle(style_name, current_frame)
def rmEventIdMarkers(self): pagenum = scribus.pageCount() for page in range(1, pagenum + 1): scribus.gotoPage(page) pageitems = scribus.getPageItems() for item in pageitems: if item[1] != 4: continue tbox = item[0] # frameLinks nonempty only if starten called from same gui if self.frameLinks.get( tbox ) is not None: # i.e. if tbox is not the root of a link chain continue # TODO find out if tbox is a linked frame tlen = scribus.getTextLength(tbox) if tlen == 0: continue scribus.selectText(0, tlen, tbox) allText = scribus.getAllText( tbox) # getAllText returns text of complete link chain! z = 0 xl = [] while True: x = allText.find("_evtid_:", z) if x < 0: break y = allText.find(STX, x) evtId = allText[x + 8:y] z = allText.find(ETX, y) titel = allText[y + 1:z] xl.append((x, z + 1 - x)) for (x, l) in reversed(xl): # the reversed is important! scribus.selectText(x, l, tbox) scribus.deleteText(tbox) scribus.redrawAll()
def change_text(text, item): l = scribus.getTextLength(item) scribus.selectText(0, l, item) fs = scribus.getFontSize(item) f = scribus.getFont(item) scribus.insertText(text, 0, item) l2 = scribus.getTextLength(item) scribus.selectText(0, l2, item) scribus.setFontSize(fs, item) scribus.setFont(f, item) scribus.selectText(l2-l, l, item) scribus.deleteText(item) scribus.deselectAll()
def makeRuns(self, pos1, pos2): runs = [] scribus.selectText(pos1, pos2 - pos1, self.textbox) txtAll = scribus.getAllText(self.textbox) scribus.selectText(pos1, 1, self.textbox) last_pstyle = scribus.getStyle(self.textbox) last_cstyle = scribus.getCharacterStyle(self.textbox) text = "" changed = False for c in range(pos1, pos2): scribus.selectText(c, 1, self.textbox) # does not work for text in overflown area, see https://bugs.scribus.net/view.php?id=15911 # char = scribus.getText(self.textbox) char = txtAll[c - pos1] pstyle = scribus.getStyle(self.textbox) if pstyle != last_pstyle: changed = True cstyle = scribus.getCharacterStyle(self.textbox) if cstyle != last_cstyle: changed = True # ff = scribus.getFontFeatures(self.textbox) # if ff != last_ff: # # ff mostly "", for Wingdins chars ="-clig,-liga" !?!? # logger.debug("fontfeature %s", ff) # last_ff = ff if changed: runs.append(ScrbRun(text, last_pstyle, last_cstyle)) last_pstyle = pstyle last_cstyle = cstyle text = "" changed = False text = text + char if text != "": runs.append(ScrbRun(text, last_pstyle, last_cstyle)) return runs
scribus.messageBox('Scribus - Usage Error', "This is not a textframe. Try again.", scribus.ICON_WARNING, scribus.BUTTON_OK) sys.exit(2) contents = scribus.getTextLength(textbox) ndash = u"\u2013" mdash = u"\u2014" prevchar = '' while 1: if ((c == contents) or (c > contents)): break if ((c + 1) > contents - 1): nextchar = ' ' else: scribus.selectText(c + 1, 1, textbox) nextchar = scribus.getText(textbox) scribus.selectText(c, 1, textbox) char = scribus.getText(textbox) if (len(char) != 1): c += 1 if (char == '-'): if (prevchar == '-'): if (nextchar == '-'): scribus.selectText(c - 1, 3, textbox) scribus.deleteText(textbox) scribus.insertText(mdash, c - 1, textbox) char = mdash else:
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
if scribus.getObjectType(item) == "TextFrame" : textFrame.append(item) if scribus.getObjectType(item) == "ImageFrame" : imageFrame.append(item[0]) # print textFrame # print imageFrame scribus.deselectAll() chars = [] for item in textFrame : scribus.deselectAll() scribus.selectObject(item) n = scribus.getTextLength() for i in range(n) : scribus.selectText(i, 1) char = scribus.getText() if (char not in charsIgnore and len(char) > 0) : chars.append(char.lower()) random.shuffle(chars) for item in textFrame : scribus.messagebarText("Processing text frame "+item) scribus.redrawAll() print item scribus.deselectAll() scribus.selectObject(item) n = scribus.getTextLength() print n for i in range(n) :
def get_text_placeholders(frame): scribus.selectText(0, 0, frame) text = scribus.getText(frame) return get_placeholders_from_string(text)
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
pageitems = scribus.getPageItems() for item in pageitems: if (item[1] == 4): c = 0 textbox = item[0] scribus.selectObject(textbox) contents = scribus.getTextLength(textbox) while 1: if ((c == contents) or (c > contents)): break if ((c + 1) > contents - 1): nextchar = ' ' else: scribus.selectText(c + 1, 1, textbox) nextchar = scribus.getText(textbox) scribus.selectText(c, 1, textbox) char = scribus.getText(textbox) if (len(char) != 1): c += 1 continue alpha = random.randint(1, 26) letter = chr(alpha + 96) LETTER = chr(alpha + 64) if ((ord(char) > 96) and (ord(char) < 123)): scribus.deleteText(textbox) scribus.insertText(letter, c, textbox) if ((ord(char) > 64) and (ord(char) < 91)): scribus.deleteText(textbox) scribus.insertText(LETTER, c, textbox)
"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 - Usage Error', "This is not a textframe. Try again.", scribus.ICON_WARNING, scribus.BUTTON_OK) sys.exit(2) contents = scribus.getTextLength(textbox) while c <= (contents -1): if ((c + 1) > contents - 1): nextchar = ' ' else: scribus.selectText(c+1, 1, textbox) nextchar = scribus.getText(textbox) scribus.selectText(c, 1, textbox) char = scribus.getText(textbox) if (len(char) != 1): c += 1 continue if ((ord(char) == 34) and (c == 0)): scribus.deleteText(textbox) scribus.insertText(lead_double, c, textbox) elif (ord(char) == 34): if ((prevchar == '.') or (prevchar == ',') or (prevchar == '?') or (prevchar == '!')): scribus.deleteText(textbox) scribus.insertText(follow_double, c, textbox) elif ((ord(prevchar) == 39) and ((nextchar != ' ') and (nextchar != ',') and (nextchar != '.'))): scribus.deleteText(textbox)
if (item[0] == textbox): if (item[1] != 4): scribus.messageBox('Scribus - Usage Error', "This is not a textframe. Try again.", scribus.ICON_WARNING, scribus.BUTTON_OK) sys.exit(2) contents = scribus.getTextLength(textbox) ndash = u"\u2013" mdash = u"\u2014" prevchar = '' while 1: if ((c == contents) or (c > contents)): break if ((c + 1) > contents - 1): nextchar = ' ' else: scribus.selectText(c+1, 1, textbox) nextchar = scribus.getText(textbox) scribus.selectText(c, 1, textbox) char = scribus.getText(textbox) if (len(char) != 1): c += 1 if (char == '-'): if (prevchar == '-'): if (nextchar == '-'): scribus.selectText(c-1, 3, textbox) scribus.deleteText(textbox) scribus.insertText(mdash, c-1, textbox) char = mdash else:
import scribus n = scribus.selectionCount() list = [] for i in range(0,n): list.append(scribus.getSelectedObject(i)) print(list) #deselectAll() for selected in list: size = len(scribus.getAllText(selected)) scribus.selectText(0, size , selected) scribus.setStyle("WASTE dialog", selected)
if scribus.getObjectType(item) == "TextFrame": textFrame.append(item) if scribus.getObjectType(item) == "ImageFrame": imageFrame.append(item[0]) # print textFrame # print imageFrame scribus.deselectAll() chars = [] for item in textFrame: scribus.deselectAll() scribus.selectObject(item) n = scribus.getTextLength() for i in range(n): scribus.selectText(i, 1) char = scribus.getText() if (char not in charsIgnore and len(char) > 0): chars.append(char.lower()) random.shuffle(chars) for item in textFrame: scribus.messagebarText("Processing text frame " + item) scribus.redrawAll() print item scribus.deselectAll() scribus.selectObject(item) n = scribus.getTextLength() print n for i in range(n):
if os.path.isfile(file_path): os.unlink(file_path) except Exception, e: print e #Make Document Temporary scribus.saveDoc() scribus.saveDocAs(tmpFileName) scribus.messagebarText("Dokument in Bearbeitung, bitte warten") scribus.closeDoc() scribus.messagebarText("Dokument in Bearbeitung, bitte warten") scribus.openDoc(tmpFileName) scribus.selectText(0, 1, idtextstring) idfont = scribus.getFont(idtextstring) idfonSize = scribus.getFontSize(idtextstring) idtextcolor = scribus.getTextColor(idtextstring) idtextshade = scribus.getTextShade(idtextstring) scribus.selectText(0, 1, gertextstring) gerfont = scribus.getFont(gertextstring) gerfonSize = scribus.getFontSize(gertextstring) gertextcolor = scribus.getTextColor(gertextstring) gertextshade = scribus.getTextShade(gertextstring) scribus.selectText(0, 1, lattextstring) latfont = scribus.getFont(lattextstring) latfonSize = scribus.getFontSize(lattextstring) lattextcolor = scribus.getTextColor(lattextstring)
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
def handleEnd(self): self.linkType = self.gui.getLinkType() self.gliederung = self.gui.getGliederung() self.includeSub = self.gui.getIncludeSub() self.start = self.gui.getStart() self.end = self.gui.getEnd() pos1, pos2, tbox = self.toBeDelPosParam scribus.selectText(pos1, pos2 - pos1, tbox) scribus.deleteText(tbox) pagenum = scribus.pageCount() for page in range(1, pagenum + 1): scribus.gotoPage(page) pageitems = scribus.getPageItems() for item in pageitems: if item[1] != 4: continue self.textbox = item[0] self.evalTemplate() # hyphenate does not work # pagenum = scribus.pageCount() # for page in range(1, pagenum + 1): # scribus.gotoPage(page) # pageitems = scribus.getPageItems() # for item in pageitems: # if item[1] != 4: # continue # self.textbox = item[0] # b = scribus.hyphenateText(self.textbox) # seems to have no effect! pagenum = scribus.pageCount() for page in range(1, pagenum + 1): scribus.gotoPage(page) pageitems = scribus.getPageItems() for item in pageitems: if item[1] != 4: continue tbox = item[0] tbox2 = tbox while scribus.textOverflows(tbox2): tbox2 = self.createNewPage(tbox2) self.frameLinks[ tbox2] = tbox # frame tbox2 has tbox as root scribus.redrawAll() ausgabedatei = self.ausgabedatei if ausgabedatei is None or ausgabedatei == "": ausgabedatei = "ADFC_" + self.gliederung + ( "_I_" if self.includeSub else "_" ) + self.start + "-" + self.end + "_" + self.linkType[0] + ".sla" try: scribus.saveDocAs(ausgabedatei) except Exception as e: print("Ausgabedatei", ausgabedatei, "konnte nicht geschrieben werden") raise e finally: self.touren = [] self.termine = [] # self.gui.destroy() # self.gui.quit() self.gui.disableStart()
def parseParams(self): pagenum = scribus.pageCount() lines = [] for page in range(1, pagenum + 1): scribus.gotoPage(page) pageitems = scribus.getPageItems() for item in pageitems: if item[1] != 4: continue self.textbox = item[0] textlen = scribus.getTextLength(self.textbox) if textlen == 0: continue scribus.selectText(0, textlen, self.textbox) alltext = scribus.getAllText(self.textbox) pos1 = alltext.find("/parameter") if pos1 < 0: continue pos2 = alltext.find("/endparameter") if pos2 < 0: raise ValueError("kein /endparameter nach /parameter") pos2 += 13 # len("/endparameter") lines = alltext[pos1:pos2].split('\r')[1:-1] logger.debug("parsePar lines:%s %s", type(lines), str(lines)) self.toBeDelPosParam = (pos1, pos2, self.textbox) break if len(lines) != 0: break if len(lines) == 0: return self.includeSub = True lx = 0 selections = {} while lx < len(lines): line = lines[lx] words = line.split() if len(words) == 0: lx += 1 continue word0 = words[0].lower().replace(":", "") if len(words) > 1: if word0 == "linktyp": self.linkType = words[1].lower().capitalize() lx += 1 elif word0 == "ausgabedatei": self.ausgabedatei = words[1] lx += 1 else: raise ValueError("Unbekannter Parameter " + word0 + ", erwarte linktyp oder ausgabedatei") elif word0 not in [ "selektion", "terminselektion", "tourselektion" ]: raise ValueError( "Unbekannter Parameter " + word0 + ", erwarte selektion, terminselektion oder tourselektion") else: lx = self.parseSel(word0, lines, lx + 1, selections) selection = selections.get("selektion") self.gliederung = selection.get("gliederungen") self.includeSub = selection.get("mituntergliederungen") == "ja" self.start = selection.get("beginn") self.end = selection.get("ende") sels = selections.get("terminselektion") if sels is not None: for sel in sels.values(): self.terminselections[sel.get("name")] = sel for key in sel.keys(): if key != "name" and not isinstance(sel[key], list): sel[key] = [sel[key]] sels = selections.get("tourselektion") if sels is not None: for sel in sels.values(): self.tourselections[sel.get("name")] = sel for key in sel.keys(): if key != "name" and not isinstance(sel[key], list): sel[key] = [sel[key]]
# check opened document if not scribus.haveDoc(): scribus.messageBox('Scribus - Script Error', "No document open", scribus.ICON_WARNING, scribus.BUTTON_OK) sys.exit(1) scribus.setRedraw(False) selectionCount = scribus.selectionCount() # str('Selected: ' + str(selectionCount)) selected = [] # remember all selected objects for index in range(0, selectionCount): # str(index) selectedObject = scribus.getSelectedObject(index) # str(selectedObject) selected.append(selectedObject) scribus.deselectAll() # change style for each selected object for obj in selected: # str(obj) scribus.selectObject(obj) scribus.selectText(0, scribus.getTextLength(obj), obj) scribus.setStyle(style, obj) scribus.deselectAll() scribus.setRedraw(True) scribus.docChanged(True)
# encoding: utf-8 try: import scribus except ImportError: print('This script must be run from inside Scribus') text = scribus.getText() print(text) i = text.find('{') j = text.find('}', i) print(i) print(j) print(text[i+1:j]) scribus.selectText(i, j - i) text = scribus.getText() print('>>>>' + text) value = 'replacement' scribus.insertText(value, i + 1) # delete placelholder} scribus.selectText(i + len(value) + 1, j - i) scribus.deleteText() # { scribus.selectText(i, 1) scribus.deleteText()
item = scribus.getSelectedObject() if (scribus.getObjectType(item) != 'TextFrame'): scribus.messageBox('Usage Error', 'You need to select a text frame') sys.exit(2) print(scribus.getTextLength(item)) if scribus.getTextLength(item) > 0: scribus.messageBox('Usage Error', 'The text frame should be empty') sys.exit(2) answer = scribus.valueDialog('Numbered lines', 'Start number, step', '1,1') start, step = answer.split(',') start = int(start) step = int(step) i = start print(scribus.textOverflows(item)) while scribus.textOverflows(item) == 0: if i == start or i % step == 0: scribus.insertText(str(i) + "\n", -1, item) else: scribus.insertText("\n", -1, item) i += 1 length = scribus.getTextLength(item) while scribus.textOverflows(item) != 0: scribus.selectText(length - 2, 1, item) scribus.deleteText(item) length -= 1
for item in scribus.getPageItems(): if item[1] == 4: scribus.deselectAll() scribus.selectObject(item[0]) content = scribus.getFrameText() next_line_feed = content.find('\r') start_selection = 0 while next_line_feed >= 0: line = content[start_selection:next_line_feed] if len(line) > 0: scribus.selectFrameText(start_selection, 1) style = scribus.getParagraphStyle() if style in toc_styles: toc_content.append((content[start_selection:next_line_feed], page, toc_styles[style])) start_selection = next_line_feed + 1 next_line_feed = content.find('\r', next_line_feed + 1) scribus.deselectAll() scribus.selectObject(toc_frame) # print(toc_content) scribus.deleteText() position = 0 for toc_item in toc_content: toc_item_content = toc_item[0] + '\t' + str(toc_item[1]) scribus.insertText(toc_item_content, -1) scribus.selectText(position, 1) scribus.setParagraphStyle(toc_item[2]) scribus.insertText('\r', -1) position += len(toc_item_content) + 1
if scribus.getObjectType(bodyText) == "TextFrame": fileName = scribus.fileDialog("Open odt file", 'ODT files (*.odt)') text = removeEmptyStrings(parse(fileName)) header = detag(header(text)) body = body(text) scribus.deleteText(bodyText) scribus.insertText(lines(detag(body))[0], -1, bodyText) scribus.setStyle("first_paragraph", bodyText) for p in lines(detag(body))[1:]: scribus.insertText("\n" + p, -1, bodyText) scribus.setStyle("eot", bodyText) for tag in extractModifiers(body): scribus.selectText(tag['start'], tag['length'], bodyText) if tag['tag'] == "bold": scribus.setFont("Mysl Bold Cyrillic", bodyText) elif tag['tag'] == "italic": scribus.setFont("Mysl Italic Cyrillic", bodyText) else: scribus.setFont("Mysl BoldItalic Cyrillic", bodyText) scribus.insertText("\n" + authorName(detag(text)), -1, bodyText) scribus.setStyle("author name", bodyText) scribus.insertText("\n" + authorEmail(detag(text)), -1, bodyText) scribus.setStyle("author emali", bodyText) scribus.hyphenateText(bodyText)
def importSocietes(filename, fileCat, iPro): arrLines=[]#liste de lignes du fichier csv, chaque ligne est une liste de champs mapCol={}#table de correspondance entre les champs à importer et les numéros de colonne du fichier csv mapCat={}#table de correspondance entre numéro de catégorie et nom de catégorie nbCat=readSocietes(filename, fileCat, mapCat, arrLines, mapCol) (nbChg, nbPro)=(0,0) numPro=1 while scribus.getTextLength("txtPros%d" % numPro)>0 and numPro<=NB_TXT: numPro+=1 if iPro==1 and scribus.objectExists("txtBureauxChange"): scribus.deleteText("txtBureauxChange") scribus.progressTotal(len(arrLines)) strPro="txtPros%d"%numPro scribus.statusMessage("Remplissage du cadre de texte %s..."%strPro) bFirstPro=True strCat="#" for record in arrLines:#Pour chaque pro # log("nbPro=%d\n"%nbPro) if strCat != record[mapCol["cat"]]:#nouvelle categorie strCat=record[mapCol["cat"]] bNewCat=True else: bNewCat=False nbPro+=1 if nbPro<iPro:#déjà importé à l'exécution précédente continue try: scribus.progressSet(nbPro) if record[mapCol["chg"]]=="True" and scribus.objectExists("txtBureauxChange"): try: nbCarBureau=scribus.getTextLength("txtBureauxChange") appendText(u"● "+toUnicode(record[mapCol["nom"]])+"\n","styleChangeTitre","txtBureauxChange") appendText(toUnicode(record[mapCol["adr"]].replace("\\n"," - "))+"\n","styleChangeAdresse","txtBureauxChange") appendText(record[mapCol["post"]]+" "+toUnicode(record[mapCol["ville"]].upper()+"\n"),"styleChangeAdresse","txtBureauxChange") nbChg+=1 except Exception as ex: scribus.messageBox( "Erreur","Une erreur est survenue sur ce bureau de change: \n%s\n\n%s" %(record, str(ex))) sys.exit() else : nbCarBureau=0 nbCar=scribus.getTextLength(strPro) if bNewCat or bFirstPro: if bFirstPro and not bNewCat: appendText(toUnicode(strCat+" (suite)")+"\n","styleProCatSuite",strPro) else: appendText(toUnicode(strCat)+"\n","styleProCat",strPro) bFirstPro=False appendText(u"● "+toUnicode(record[mapCol["nom"]])+"\n","styleProTitre",strPro) if record[mapCol["chg"]]=="True" : appendText(u"\n","styleProBureau",strPro) #icone du bureau de change en police FontAwesome appendText(processDesc(toUnicode(record[mapCol["desc"]]))+"\n","styleProDesc",strPro) if bLivret: strAdr=toUnicode(record[mapCol["adr"]].replace("\\n"," - "))+" - " + toUnicode(record[mapCol["post"]])+" " strAdr+=processDesc(toUnicode(record[mapCol["ville"]].upper())) if record[mapCol["tel"]].strip(): strAdr+=" ("+toUnicode(record[mapCol["tel"]].strip().replace(" ","\xC2\xA0"))+")\n" #numéro de téléphone insécable else: strAdr+="\n" appendText(strAdr, "styleProAdresse", strPro) else: appendText(toUnicode(record[mapCol["adr"]].replace("\\n"," - "))+"\n","styleProAdresse",strPro) appendText(toUnicode(record[mapCol["post"]])+" "+processDesc(toUnicode(record[mapCol["ville"]]).upper())+"\n","styleProAdresse",strPro) if record[mapCol["tel"]].strip(): appendText(processTelephone(record[mapCol["tel"]])+"\n","styleProAdresse",strPro) if scribus.textOverflows(strPro, nolinks=1): #effacement du paragraphe de pro tronqué et du bureau de change en double scribus.selectText(nbCar, scribus.getTextLength(strPro)-nbCar, strPro) scribus.deleteText(strPro) if nbCarBureau: scribus.selectText(nbCarBureau, scribus.getTextLength("txtBureauxChange")-nbCarBureau, "txtBureauxChange") scribus.deleteText("txtBureauxChange") #log("Cadre rempli : le cadre de texte %s est plein à la ligne %d\n" % (strPro, nbPro)) break except Exception as exc: scribus.messageBox( "Erreur","Une erreur est survenue sur ce professionnel: \n%s\n\n%s" %(record, str(exc))) sys.exit() return (nbChg, nbPro, nbCat)
import sys try: import scribus except ImportError: print "This script only works from within Scribus" sys.exit(1) obj = scribus.getSelectedObject(0) sdir = 1 # options fs = 8 fsmax = 14 fsmin = 8 inc = 0.0005 ### tl = scribus.getTextLength() for c in range(tl - 1): scribus.selectText(c, 1, obj) if(sdir == 1): fs += inc if(fs > fsmax): sdir = 0 else: fs -= inc if(fs < fsmin): sdir = 1 scribus.setFontSize(fs,obj)