Пример #1
0
def main():
    """ Application/Dialog loop with Scribus sauce around """
    try:
        root = Tk()
        app = TkImageAlignmentWizard(root)
        root.mainloop()
    finally:
        if scribus.haveDoc():
            scribus.redrawAll()
def main():
    """ Application/Dialog loop with Scribus sauce around """
    try:
        root = Tk()
        app = TkImageAlignmentWizard(root)
        root.mainloop()
    finally:
        if scribus.haveDoc():
            scribus.redrawAll()
Пример #3
0
def main():
    try:
        scribus.statusMessage('Running script...')
        # scribus.progressReset()
        adfc_gui.main("-scribus")
    finally:
        if scribus.haveDoc() > 0:
            scribus.redrawAll()
        scribus.statusMessage('Done.')
Пример #4
0
 def makeToc(self, firstPageNr):
     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.evalTocTemplate(firstPageNr)
     scribus.redrawAll()
Пример #5
0
 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()
Пример #6
0
 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()
Пример #7
0
        #     framecount = 0
        # L is the frame at the top of each page showing the directory name
        # L = scribus.createText(15, 20, 200, 20)
        # scribus.setText("Dir: " + imagedir, L)
        # scribus.setTextAlignment(scribus.ALIGN_LEFT, L)
        # scribus.setFont(labelFont, L)
        # scribus.setFontSize(10, L)
        # Here is where we're loading images into the page, four at a time, then go back up for a newPage
        if imagecount < len(D):
            f = scribus.createImage(-3.175, -3.175, pwidth, pheight)
            scribus.loadImage(imagedir + '/' + D[imagecount], f)
            scribus.setScaleImageToFrame(scaletoframe=1, proportional=0, name=f)
            #lenfilename = len(D[imagecount])
            #Lpiclen = int(5.3 * lenfilename)
            # Lpic is the label for each picture, with position and length adjusted
            # according to the text length, so if you change the font or its size,
            # you may need to adjust this only approximate calculation.
            # Lpic = scribus.createText(x, y + 193, Lpiclen, 15)
            # scribus.setText(D[imagecount], Lpic)
            # scribus.setTextAlignment(scribus.ALIGN_RIGHT, Lpic)
            # scribus.setFont(labelFont, Lpic)
            # scribus.setFontSize(8, Lpic)
            # scribus.setFillColor("White", Lpic)
            imagecount += 1
            page += 1

    scribus.setRedraw(1)
    scribus.redrawAll()

else:
    result = scribus.messageBox('Not Found', 'No Images found with\n this search selection', scribus.BUTTON_OK)
Пример #8
0
    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()
WARNING: this script irreversibly scrambles your text on all pages.
You would be wise to work on a copy of the original to avoid 
accidentally saving this scrambled version only to lose the original.
"""

import scribus
import random
 
if scribus.haveDoc():
    c = 0
 
else:
    scribus.messageBox('Usage Error', 'You need a Document open', icon=0, button1=1)
    sys.exit(2)
scribus.messagebarText("Getting ready to process Page 1")  # a bit kludgey maybe, but gives an initial message about Page 1
scribus.redrawAll()
 
warnresult = scribus.valueDialog('Warning!', 'This script is going to irreversibly alter the text in your document.\nChange this default value to abort', 'Ok!')
 
if (warnresult != 'Ok!'):
    sys.exit(2)
 
page = 1
pagenum = scribus.pageCount()
while (page <= pagenum):
  scribus.gotoPage(page)
  scribus.messagebarText("Processing Page "+str(page)) # New Feature! - sends a message to message bar 
  scribus.redrawAll()                                  # this allows the message to show
 
  pageitems = scribus.getPageItems()
 
import scribus
import random

if scribus.haveDoc():
    c = 0

else:
    scribus.messageBox('Usage Error',
                       'You need a Document open',
                       icon=0,
                       button1=1)
    sys.exit(2)
scribus.messagebarText(
    "Getting ready to process Page 1"
)  # a bit kludgey maybe, but gives an initial message about Page 1
scribus.redrawAll()

warnresult = scribus.valueDialog(
    'Warning!',
    'This script is going to irreversibly alter the text in your document.\nChange this default value to abort',
    'Ok!')

if (warnresult != 'Ok!'):
    sys.exit(2)

page = 1
pagenum = scribus.pageCount()
while (page <= pagenum):
    scribus.gotoPage(page)
    scribus.messagebarText(
        "Processing Page " +
charsIgnore = ["-", "–", "­", " ", ".", ":", ";", ";", "?", "!", "\n", "'", "‘", "’", "," "\"", "“", "”", "\r"]

button = scribus.messageBox('Confirmation', 'You should only scramble a copy of your document', scribus.ICON_WARNING, scribus.BUTTON_OK, scribus.BUTTON_CANCEL)
print button
if button == scribus.BUTTON_CANCEL :
    sys.exit(2)

selectedFrame = []
textFrame = []
imageFrame = []
if scribus.selectionCount() == 0:
    for page in range(scribus.pageCount()) :
        scribus.gotoPage(page + 1)
        scribus.messagebarText("Processing Page "+str(page))
        scribus.redrawAll()
        for item in scribus.getPageItems() :
            if (item[1] == 4):
                textFrame.append(item[0])
            elif (item[1] == 2) :
                imageFrame.append(item[0])
else :
    for i in range(scribus.selectionCount()) :
        item = scribus.getSelectedObject(i)
        selectedFrame.append(item)
        if scribus.getObjectType(item) == "TextFrame" :
            textFrame.append(item)
        if scribus.getObjectType(item) == "ImageFrame" :
            imageFrame.append(item[0])

# print textFrame