Great thanks! I'll try it this afternoon. The value of 1000 was just an example, and the debugging works for me because i run the script from the script console. But the message boxes are a good idea anyway I'll have a look at them.
On Tuesday 03 March 2009 09:16:29 Patrick Wallace wrote: > Chantal on scribus-request at lists.scribus.info wrote: > > Hi, I am writing a script that loops through textboxes in a document and > > resizes them until the frame fits. > > Your script was not finished as it just attempted to add a single value > to the height of the text frames. > I cleaned up and simplified the logic and here is a working version of > your first draft for you to study and > continue to develop toward your goal. (You will probably want to use a > while-loop testing OverFlowChar.) > > For debugging, you cannot use print statements (you won't see them in > Scribus), so it might be more useful to > insert scribus.messageBox() commands to see intermediate variables, etc. > > Below, the script just adds 10 to the height (1,000 was way too big) and > I have verified that > the script runs and performs as expected in Scribus 1.3.5svn. > > # ---------------------------------------------------# > # check of het script vanuit scribus wordt gestart # > #----------------------------------------------------# > > import sys > try: > import scribus > > except ImportError: > print "This script only works from within Scribus" > sys.exit(1) > > pagenum = scribus.pageCount() # find out how many > pages we have page = 1 # > initialize at first page > InitialAddition=10 # define how much > to add to text frames > > while (page <= pagenum): > scribus.gotoPage(page) # move to the > current page ItemsOnpage = scribus.getPageItems() # how many > items are on this page for CurrentItem in ItemsOnpage: # > loop all items CurrentItemType=CurrentItem[1] > if CurrentItemType == 4: # type 4 is text > frame. We only bother with them. CurrentItemName = CurrentItem[0] > # get this frame's name so we can manipulate it OverflowChar = > scribus.textOverflows(CurrentItemName) if OverflowChar > 0: > (CurrentItemwidth, CurrentItemheight) = > scribus.getSize(CurrentItemName) # get width, height > scribus.sizeObject(CurrentItemwidth,CurrentItemheight+InitialAddition,Curre >ntItemName) # increase height page += 1 # increment to the next >page > (good programmers do this at the END of while loops) > > > > > _______________________________________________ > scribus mailing list > scribus at lists.scribus.info > http://lists.scribus.info/mailman/listinfo/scribus
